Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #16

Merged
merged 6 commits into from
Dec 10, 2022
Merged

Dev #16

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
changelog: ${{ steps.tag_version.outputs.changelog }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v5.5
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: false
Expand All @@ -30,7 +30,7 @@ jobs:
if: ${{ needs.bump.outputs.new_tag != null }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set env
run: |
Expand Down
12 changes: 9 additions & 3 deletions plasmoid/contents/ui/Exec.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ PlasmaCore.DataSource {
}

function exec(cmd) {
return new Promise((resolve, reject) => {
callbacks[cmd] = { resolve, reject }
connectSource(cmd)
if (callbacks[cmd]) {
return callbacks[cmd].promise
}
let resolve, reject, promise = new Promise((_resolve, _reject) => {
resolve = _resolve
reject = _reject
})
callbacks[cmd] = { resolve, reject, promise }
connectSource(cmd)
return promise
}
}
28 changes: 15 additions & 13 deletions plasmoid/contents/ui/FullRepresentation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@ import org.kde.plasma.extras 2.0 as PlasmaExtras
import "../code/globals.js" as Globals

PlasmaComponents3.Page {
readonly property var appletInterface: plasmoid.self

property ListModel favorites: ListModel {}
property alias servers: nordVpnModel.servers
property alias allGroups: nordVpnModel.allGroups
property alias functionalGroups: nordVpnModel.functionalGroups
readonly property bool loadModel: plasmoid.expanded && nordvpn.isServiceRunning

NordVPNModel {
id: nordVpnModel
source: nordvpn
}

Connections {
target: plasmoid
onExpandedChanged: {
if (expanded) {
loadFavorites()
root.onFavoriteConnectionsChanged.connect(loadFavorites)
nordVpnModel.loadData()
} else {
nordVpnModel.clear()
root.onFavoriteConnectionsChanged.disconnect(loadFavorites)
favorites.clear()
}
onLoadModelChanged: {
if (loadModel) {
loadFavorites()
root.onFavoriteConnectionsChanged.connect(loadFavorites)
nordVpnModel.loadData()
} else {
nordVpnModel.clear()
root.onFavoriteConnectionsChanged.disconnect(loadFavorites)
favorites.clear()
}
}

Expand Down Expand Up @@ -75,7 +75,8 @@ PlasmaComponents3.Page {

PlasmaComponents3.ScrollView {
Layout.fillWidth: true
implicitHeight: PlasmaCore.Units.iconSizes.large
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
contentHeight: contentItem.contentItem.childrenRect.height
visible: favorites.count > 0
ListView {
currentIndex: -1
Expand Down Expand Up @@ -115,6 +116,7 @@ PlasmaComponents3.Page {
PlasmaComponents3.ScrollView {
Layout.fillHeight: true
Layout.fillWidth: true
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff

ListView {
id: serverList
Expand Down
6 changes: 5 additions & 1 deletion plasmoid/contents/ui/NordVPN.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ Item {
id: statusSource
engine: "executable"
connectedSources: ["nordvpn status"]
interval: p.isOperationInProgress ? 0 : 1000
interval: {
if (p.isOperationInProgress) return 0
if (p.isServiceRunning) return 1000
return Math.random() * 5000 + 5000 | 0
}
onNewData: p.updateStatus(data)
}

Expand Down
10 changes: 0 additions & 10 deletions plasmoid/contents/ui/NordVPNModel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,4 @@ QtObject {
function updateCurrentConnectionItem() {
servers.set(0, getCurrentConnectionItem())
}

Component.onCompleted: {
source.onIsServiceRunningChanged.connect(() => {
if (source.isServiceRunning) {
loadData()
} else {
clear()
}
})
}
}