From 68f566cf7fddbe9e5eb08c4c07a76375148b682b Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Tue, 1 Sep 2020 22:15:39 +0200 Subject: [feat] svg map for gateway panel --- gui/assets/svg/world.svg | 2 ++ gui/gui.qrc | 2 +- gui/qml/main.qml | 51 ++++++++++++++++++++++++++++++++++++++++++++++-- pkg/vpn/openvpn.go | 2 +- pkg/vpn/status.go | 1 + 5 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 gui/assets/svg/world.svg diff --git a/gui/assets/svg/world.svg b/gui/assets/svg/world.svg new file mode 100644 index 0000000..84597b8 --- /dev/null +++ b/gui/assets/svg/world.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/gui/gui.qrc b/gui/gui.qrc index 36252dd..5e0d4ae 100644 --- a/gui/gui.qrc +++ b/gui/gui.qrc @@ -23,6 +23,6 @@ assets/icon/png/white/vpn_wait_3.png providers/providers.json - + assets/svg/world.svg diff --git a/gui/qml/main.qml b/gui/qml/main.qml index aed08ea..98a4445 100644 --- a/gui/qml/main.qml +++ b/gui/qml/main.qml @@ -1,6 +1,7 @@ import QtQuick 2.9 import QtQuick.Controls 1.4 import QtQuick.Dialogs 1.2 +import QtQuick.Layouts 1.0 import QtQuick.Extras 1.2 import Qt.labs.platform 1.1 as LabsPlatform @@ -8,7 +9,9 @@ import Qt.labs.platform 1.1 as LabsPlatform ApplicationWindow { id: app - visible: false + visible: true + width: 700 + height: 700 flags: Qt.WindowsStaysOnTopHint | Qt.Popup @@ -16,6 +19,48 @@ ApplicationWindow { property var loginDone property var allowEmptyPass + ColumnLayout{ + anchors.centerIn: parent + width: parent.width + Layout.preferredHeight: parent.height + visible: true + + Text{ + id: mainStatus + text: "Status: off" + font.pixelSize: 22 + Layout.preferredWidth: parent.width + horizontalAlignment: Text.AlignHCenter + } + + Label { + text: "gateway selection:" + font.pixelSize: 20 + } + + ComboBox { + id: comboGw + editable: false + model: [ qsTr("Automatic"), qsTr("Paris"), qsTr("Amsterdam") ] + onAccepted: { + if (combo.find(currentText) === -1) { + currentIndex = combo.find(editText) + } + } + } + + ColumnLayout{ + width: parent.width + + Image { + id: worldMap + source: "qrc:/assets/svg/world.svg" + fillMode: Image.PreserveAspectCrop + } + } + } + + Connections { target: jsonModel onDataChanged: { @@ -99,7 +144,9 @@ ApplicationWindow { allowEmptyPass = shouldAllowEmptyPass() /* TODO get appVisible flag from backend */ - app.visible = false + app.visible = true; + show(); + hide(); } function toHuman(st) { diff --git a/pkg/vpn/openvpn.go b/pkg/vpn/openvpn.go index d5f9dc2..b6593f2 100644 --- a/pkg/vpn/openvpn.go +++ b/pkg/vpn/openvpn.go @@ -245,7 +245,7 @@ func (b *Bitmask) ListGateways(provider string) ([]string, error) { // UseGateway selects name as the default gateway func (b *Bitmask) UseGateway(name string) error { - b.bonafide.SetDefaultGateway(name) + b.bonafide.SetManualGateway(name) return nil } diff --git a/pkg/vpn/status.go b/pkg/vpn/status.go index cc2fb62..7901276 100644 --- a/pkg/vpn/status.go +++ b/pkg/vpn/status.go @@ -74,6 +74,7 @@ func (b *Bitmask) eventHandler(eventCh <-chan openvpn.Event) { } if statusName == "CONNECTED" { b.onGateway = strings.Split(stateEvent.String(), ": ")[1] + log.Println(">>> CONNECTED TO", b.onGateway) } } b.statusCh <- Off -- cgit v1.2.3