From 6ca834c8d55345a117412fd98219333460f4fe1a Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Fri, 19 Feb 2021 01:05:07 +0100 Subject: [style] qmlfmt --- gui/qml/VpnState.qml | 184 +++++++++++++++++++++++++++++++++++++++++---------- gui/qml/main.qml | 93 ++++++++++++++------------ 2 files changed, 200 insertions(+), 77 deletions(-) (limited to 'gui/qml') diff --git a/gui/qml/VpnState.qml b/gui/qml/VpnState.qml index ea2a3b1..ffad207 100644 --- a/gui/qml/VpnState.qml +++ b/gui/qml/VpnState.qml @@ -6,59 +6,171 @@ StateGroup { state: ctx ? ctx.status : "" states: [ - State { name: "initializing" }, + State { + name: "initializing" + }, State { name: "off" - PropertyChanges { target: systray; tooltip: toHuman("off"); icon.source: icons["off"] } - PropertyChanges { target: statusItem; text: toHuman("off") } - PropertyChanges { target: mainStatus; text: toHuman("off") } - PropertyChanges { target: mainCurrentGateway; text: "" } - PropertyChanges { target: mainOnBtn; visible: true } - PropertyChanges { target: mainOffBtn; visible: false } - PropertyChanges { target: gwMarker; color: "red"} + PropertyChanges { + target: systray + tooltip: toHuman("off") + icon.source: icons["off"] + } + PropertyChanges { + target: statusItem + text: toHuman("off") + } + PropertyChanges { + target: mainStatus + text: toHuman("off") + } + PropertyChanges { + target: mainCurrentGateway + text: "" + } + PropertyChanges { + target: mainOnBtn + visible: true + } + PropertyChanges { + target: mainOffBtn + visible: false + } + PropertyChanges { + target: gwMarker + color: "red" + } }, State { name: "on" StateChangeScript { script: displayGatewayMarker() } - PropertyChanges { target: systray; tooltip: toHuman("on"); icon.source: icons["on"] } - PropertyChanges { target: statusItem; text: toHumanWithLocation("on") } - PropertyChanges { target: mainStatus; text: toHuman("on") } - PropertyChanges { target: mainCurrentGateway; text: qsTr("Connected to ") + ctx.currentGateway } - PropertyChanges { target: mainOnBtn; visible: false } - PropertyChanges { target: mainOffBtn; visible: true } - PropertyChanges { target: gwMarker; color: "green"} + PropertyChanges { + target: systray + tooltip: toHuman("on") + icon.source: icons["on"] + } + PropertyChanges { + target: statusItem + text: toHumanWithLocation("on") + } + PropertyChanges { + target: mainStatus + text: toHuman("on") + } + PropertyChanges { + target: mainCurrentGateway + text: qsTr("Connected to ") + ctx.currentGateway + } + PropertyChanges { + target: mainOnBtn + visible: false + } + PropertyChanges { + target: mainOffBtn + visible: true + } + PropertyChanges { + target: gwMarker + color: "green" + } }, State { name: "starting" - PropertyChanges { target: systray; tooltip: toHuman("connecting"); icon.source: icons["wait"] } - PropertyChanges { target: statusItem; text: toHumanWithLocation("connecting") } - PropertyChanges { target: mainStatus; text: qsTr("Connecting...") } - PropertyChanges { target: mainCurrentGateway; text: "" } - PropertyChanges { target: mainOnBtn; visible: false } - PropertyChanges { target: mainOffBtn; visible: true } - PropertyChanges { target: gwMarker; color: "orange"} + PropertyChanges { + target: systray + tooltip: toHuman("connecting") + icon.source: icons["wait"] + } + PropertyChanges { + target: statusItem + text: toHumanWithLocation("connecting") + } + PropertyChanges { + target: mainStatus + text: qsTr("Connecting...") + } + PropertyChanges { + target: mainCurrentGateway + text: "" + } + PropertyChanges { + target: mainOnBtn + visible: false + } + PropertyChanges { + target: mainOffBtn + visible: true + } + PropertyChanges { + target: gwMarker + color: "orange" + } }, State { name: "stopping" - PropertyChanges { target: systray; tooltip: toHuman("stopping"); icon.source: icons["wait"] } - PropertyChanges { target: statusItem; text: toHuman("stopping") } - PropertyChanges { target: mainStatus; text: toHuman("stopping") } - PropertyChanges { target: mainCurrentGateway; text: "" } - PropertyChanges { target: mainOnBtn; visible: true } - PropertyChanges { target: mainOffBtn; visible: false } - PropertyChanges { target: gwMarker; color: "orange"} + PropertyChanges { + target: systray + tooltip: toHuman("stopping") + icon.source: icons["wait"] + } + PropertyChanges { + target: statusItem + text: toHuman("stopping") + } + PropertyChanges { + target: mainStatus + text: toHuman("stopping") + } + PropertyChanges { + target: mainCurrentGateway + text: "" + } + PropertyChanges { + target: mainOnBtn + visible: true + } + PropertyChanges { + target: mainOffBtn + visible: false + } + PropertyChanges { + target: gwMarker + color: "orange" + } }, State { name: "failed" - PropertyChanges { target: systray; tooltip: toHuman("failed"); icon.source: icons["wait"] } - PropertyChanges { target: statusItem; text: toHuman("failed") } - PropertyChanges { target: mainStatus; text: toHuman("failed") } - PropertyChanges { target: mainCurrentGateway; text: "" } - PropertyChanges { target: mainOnBtn; visible: true } - PropertyChanges { target: mainOffBtn; visible: false } - PropertyChanges { target: gwMarker; color: "red"} + PropertyChanges { + target: systray + tooltip: toHuman("failed") + icon.source: icons["wait"] + } + PropertyChanges { + target: statusItem + text: toHuman("failed") + } + PropertyChanges { + target: mainStatus + text: toHuman("failed") + } + PropertyChanges { + target: mainCurrentGateway + text: "" + } + PropertyChanges { + target: mainOnBtn + visible: true + } + PropertyChanges { + target: mainOffBtn + visible: false + } + PropertyChanges { + target: gwMarker + color: "red" + } } ] } diff --git a/gui/qml/main.qml b/gui/qml/main.qml index bbc3f69..5401b97 100644 --- a/gui/qml/main.qml +++ b/gui/qml/main.qml @@ -18,10 +18,10 @@ ApplicationWindow { minimumWidth: 300 maximumHeight: 600 minimumHeight: 600 - // TODO get a nice background color flags: Qt.WindowsStaysOnTopHint | Qt.Popup + // TODO get a nice background color property var ctx property var loginDone property var allowEmptyPass @@ -42,14 +42,14 @@ ApplicationWindow { ColumnLayout { Layout.alignment: Qt.AlignHCenter - Text{ + Text { id: mainStatus text: "off" font.pixelSize: 26 Layout.alignment: Text.AlignHCenter } - Text{ + Text { id: mainCurrentGateway text: "" font.pixelSize: 20 @@ -79,8 +79,8 @@ ApplicationWindow { editable: false model: [qsTr("Automatic")] onActivated: { - console.debug("Selected gateway:", currentText); - backend.useGateway(currentText.toString()); + console.debug("Selected gateway:", currentText) + backend.useGateway(currentText.toString()) } } } @@ -110,18 +110,31 @@ ApplicationWindow { color: "red" z: worldMap.z + 1 } - } } - function displayGatewayMarker() { let coords = { - 'paris': {'x': 48, 'y': 2}, - 'miami': {'x': 25.7 , 'y': -80.2 }, - 'amsterdam': {'x': 52.4, 'y': 4.9 }, - 'montreal': {'x': 45.3, 'y': -73.4 }, - 'seattle': {'x': 47.4, 'y': -122.2 }, + "paris": { + "x": 48, + "y": 2 + }, + "miami": { + "x": 25.7, + "y": -80.2 + }, + "amsterdam": { + "x": 52.4, + "y": 4.9 + }, + "montreal": { + "x": 45.3, + "y": -73.4 + }, + "seattle": { + "x": 47.4, + "y": -122.2 + } } let city = ctx.currentGateway.split('-')[0] let coord = coords[city] @@ -130,16 +143,16 @@ ApplicationWindow { // our map, and this offset doesn't work with bigg-ish sizes. But good // enough for a proof of concept - if we avoid resizing the window. let xOffset = -1 * 0.10 * worldMap.width - let p = Maps.projectAbsolute(coord.x, coord.y, worldMap.width, 1, xOffset) + let p = Maps.projectAbsolute(coord.x, coord.y, worldMap.width, + 1, xOffset) gwMarker.x = p.x gwMarker.y = p.y } - Connections { target: jsonModel onDataChanged: { - ctx = JSON.parse(jsonModel.getJson()); + ctx = JSON.parse(jsonModel.getJson()) gwSelector.model = Object.keys(ctx.gateways) if (ctx.donateDialog == 'true') { @@ -220,9 +233,8 @@ ApplicationWindow { allowEmptyPass = shouldAllowEmptyPass() /* TODO get appVisible flag from backend */ - app.visible = true; - show(); - hide(); + app.visible = true + app.raise() } function toHuman(st) { @@ -247,24 +259,26 @@ ApplicationWindow { } function toHumanWithLocation(st) { - switch(st) { - case "off": - //: %1 -> application name - return qsTr("%1 off").arg(ctx.appName); - case "on": - //: %1 -> application name - //: %2 -> current gateway - return qsTr("%1 on - %2").arg(ctx.appName).arg(ctx.currentGateway); - case "connecting": - //: %1 -> application name - //: %2 -> current gateway - return qsTr("Connecting to %1 - %2").arg(ctx.appName).arg(ctx.currentGateway); - case "stopping": - //: %1 -> application name - return qsTr("Stopping %1").arg(ctx.appName); - case "failed": - //: %1 -> application name - return qsTr("%1 blocking internet").arg(ctx.appName); // TODO failed is not handed yet + switch (st) { + case "off": + //: %1 -> application name + return qsTr("%1 off").arg(ctx.appName) + case "on": + //: %1 -> application name + //: %2 -> current gateway + return qsTr("%1 on - %2").arg(ctx.appName).arg(ctx.currentGateway) + case "connecting": + //: %1 -> application name + //: %2 -> current gateway + return qsTr("Connecting to %1 - %2").arg(ctx.appName).arg( + ctx.currentGateway) + case "stopping": + //: %1 -> application name + return qsTr("Stopping %1").arg(ctx.appName) + case "failed": + //: %1 -> application name + return qsTr("%1 blocking internet").arg( + ctx.appName) // TODO failed is not handed yet } } @@ -279,7 +293,6 @@ ApplicationWindow { id: vpn } - SystemTrayIcon { LabsPlatform.SystemTrayIcon { id: systray @@ -298,13 +311,12 @@ ApplicationWindow { target: systray onActivatedSignal: { if (Qt.platform.os === "windows" || desktop === "LXQt") { - console.debug("open systray menu"); - systrayMenu.open(); + console.debug("open systray menu") + systrayMenu.open() } } } - LabsPlatform.MenuItem { id: statusItem text: qsTr("Checking status…") @@ -388,7 +400,6 @@ ApplicationWindow { } } - Component.onCompleted: { icon.source = icons["off"] tooltip = qsTr("Checking status…") -- cgit v1.2.3