Skip to content

Commit

Permalink
Merge pull request #16 from korapp/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
korapp committed Dec 10, 2022
2 parents c704edf + 33dbe0c commit 69a6961
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 30 deletions.
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()
}
})
}
}

0 comments on commit 69a6961

Please sign in to comment.