summaryrefslogtreecommitdiff
path: root/gui/components
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2021-10-03 22:46:41 +0200
committerkali kaneko (leap communications) <kali@leap.se>2021-11-23 21:51:12 +0100
commitcae08421ac569ce773cc619ff8042ebe33700ff9 (patch)
tree2002a7900150e400ed27abadcfdb3f569bab872c /gui/components
parent79d25833bfd261c36d954cf57845e5a416aaf849 (diff)
[ui] systray actions
Diffstat (limited to 'gui/components')
-rw-r--r--gui/components/Systray.qml64
-rw-r--r--gui/components/VPNState.qml4
2 files changed, 67 insertions, 1 deletions
diff --git a/gui/components/Systray.qml b/gui/components/Systray.qml
index 9ed52f5..d23a7c4 100644
--- a/gui/components/Systray.qml
+++ b/gui/components/Systray.qml
@@ -17,6 +17,19 @@ Labs.SystemTrayIcon {
enabled: false
}
+ Labs.MenuItem {
+ id: vpnSystrayToggle
+ text: getConnectionText()
+ enabled: isConnectionTextEnabled()
+ onTriggered: {
+ if (ctx.status == "off") {
+ backend.switchOn()
+ } else if (ctx.status == "on") {
+ backend.switchOff()
+ }
+ }
+ }
+
Labs.MenuSeparator {}
Labs.MenuItem {
@@ -27,8 +40,59 @@ Labs.SystemTrayIcon {
Labs.MenuSeparator {}
Labs.MenuItem {
+ id: showAppItem
+ //: Part of the systray menu; show or hide the main app window
+ text: isVisible() ? qsTr("Hide") : qsTr("Show")
+ onTriggered: {
+ if (isVisible()) {
+ root.hide()
+ } else {
+ root.bringToFront()
+ }
+ }
+ }
+
+ Labs.MenuItem {
+ //: Part of the systray menu; quits que application
text: qsTr("Quit")
onTriggered: backend.quit()
}
}
+
+ function isVisible() {
+ return root.visibility != 0 && root.visibility != 3
+ }
+
+ function getConnectionText() {
+ if (!ctx) {
+ return ""
+ } else if (ctx.status == "off") {
+ // Not Turn on, because we will can later append "to <Location>"
+ if (ctx.locations && ctx.bestLocation) {
+ return qsTr("Connect to") + " " + getCanonicalLocation(ctx.bestLocation)
+ } else {
+ return qsTr("Connect")
+ }
+ } else if (ctx.status == "on") {
+ return qsTr("Disconnect")
+ }
+ return ""
+ }
+
+ function isConnectionTextEnabled() {
+ if (!ctx) {
+ return false
+ }
+ return ctx.status == "off" || ctx.status == "on"
+ }
+
+ // returns the composite of Location, CC
+ function getCanonicalLocation(label) {
+ try {
+ let loc = ctx.locationLabels[label]
+ return loc[0] + ", " + loc[1]
+ } catch(e) {
+ return "unknown"
+ }
+ }
}
diff --git a/gui/components/VPNState.qml b/gui/components/VPNState.qml
index d5115f2..189fd0b 100644
--- a/gui/components/VPNState.qml
+++ b/gui/components/VPNState.qml
@@ -37,7 +37,9 @@ StateGroup {
PropertyChanges {
target: toggleVPN
enabled: false
- text: ("...")
+ // XXX this is a fake cancel, won't do anything at this point. We need
+ // to queue this action for when the openvpn process becomes available.
+ text: ("Cancel")
}
PropertyChanges {
target: systray