summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2021-05-28 12:26:11 +0200
committerkali kaneko (leap communications) <kali@leap.se>2021-06-01 12:31:48 +0200
commit1bd2637e3133d895d1e73931f8b3466a5761d9ef (patch)
tree1bd75f2a91f30d996030a8531fefbb29f7c41831 /gui
parentc6c0209ad45fb7d2e45370ee3a39f2dd437603b0 (diff)
[feat] expose set transport
webapi mainly for tests, but it's usable too
Diffstat (limited to 'gui')
-rw-r--r--gui/backend.go5
-rw-r--r--gui/gui.qrc1
-rw-r--r--gui/handlers.cpp10
-rw-r--r--gui/handlers.h2
-rw-r--r--gui/qml/main.qml224
5 files changed, 165 insertions, 77 deletions
diff --git a/gui/backend.go b/gui/backend.go
index d4f5738..38f40a8 100644
--- a/gui/backend.go
+++ b/gui/backend.go
@@ -48,6 +48,11 @@ func UseTransport(transport string) {
backend.UseTransport(transport)
}
+//export GetTransport
+func GetTransport() *C.char {
+ return (*C.char)(backend.GetTransport())
+}
+
//export Quit
func Quit() {
backend.Quit()
diff --git a/gui/gui.qrc b/gui/gui.qrc
index 22b3b73..be0d3e9 100644
--- a/gui/gui.qrc
+++ b/gui/gui.qrc
@@ -22,6 +22,7 @@
<file>assets/icon/png/white/vpn_wait_1.png</file>
<file>assets/icon/png/white/vpn_wait_2.png</file>
<file>assets/icon/png/white/vpn_wait_3.png</file>
+ <file>assets/img/bird.jpg</file>
<file alias="providers.json">providers/providers.json</file>
</qresource>
diff --git a/gui/handlers.cpp b/gui/handlers.cpp
index 9f68834..cec43ca 100644
--- a/gui/handlers.cpp
+++ b/gui/handlers.cpp
@@ -52,6 +52,16 @@ void Backend::useAutomaticGateway()
UseAutomaticGateway();
}
+void Backend::useTransport(QString transport)
+{
+ UseTransport(toGoStr(transport));
+}
+
+QString Backend::getTransport()
+{
+ return QString(GetTransport());
+}
+
void Backend::login(QString username, QString password)
{
Login(toGoStr(username), toGoStr(password));
diff --git a/gui/handlers.h b/gui/handlers.h
index 3415b7e..9c11b60 100644
--- a/gui/handlers.h
+++ b/gui/handlers.h
@@ -38,6 +38,8 @@ public slots:
void donateSeen();
void useLocation(QString username);
void useAutomaticGateway();
+ void useTransport(QString transport);
+ QString getTransport();
void login(QString username, QString password);
void resetError(QString errlabel);
void resetNotification(QString label);
diff --git a/gui/qml/main.qml b/gui/qml/main.qml
index 1399f0f..7048a81 100644
--- a/gui/qml/main.qml
+++ b/gui/qml/main.qml
@@ -8,9 +8,9 @@ import Qt.labs.platform 1.0
ApplicationWindow {
id: app
visible: true
- width: 500
+ width: 300
height: 600
- maximumWidth: 600
+ maximumWidth: 300
minimumWidth: 300
maximumHeight: 500
minimumHeight: 300
@@ -24,17 +24,20 @@ ApplicationWindow {
console.debug(msg)
}
- // TODO get a nice background color for this mainwindow. It should be customizable.
- // TODO refactorize all this mess into discrete components.
+ // TODO refactor into discrete components.
+
TabBar {
id: bar
width: parent.width
TabButton {
- text: qsTr("Info")
+ text: qsTr("Status")
}
TabButton {
text: qsTr("Location")
}
+ TabButton {
+ text: qsTr("Bridges")
+ }
}
StackLayout {
@@ -47,93 +50,121 @@ ApplicationWindow {
id: infoTab
anchors.centerIn: parent
- Column {
+ Rectangle {
+ id: background
+ anchors.fill: parent;
+ anchors.topMargin: 40;
+ Image {
+ source: "qrc:/assets/img/bird.jpg";
+ fillMode: Image.PreserveAspectCrop;
+ anchors.fill: parent;
+ opacity: 0.8;
+ }
+ }
+
+ Item {
+ id: connBox
anchors.centerIn: parent
- spacing: 5
- Text {
- id: mainStatus
- text: "off"
- font.pixelSize: 26
- anchors.horizontalCenter: parent.horizontalCenter
- }
+ width: 300
+ height: 300
- Text {
- id: mainCurrentGateway
- text: ""
- font.pixelSize: 20
- anchors.horizontalCenter: parent.horizontalCenter
+ Rectangle {
+ anchors.fill: parent
+ color: "white"
+ opacity: 0.3
+ layer.enabled: true
}
- SwitchDelegate {
+ Column {
- id: vpntoggle
+ anchors.centerIn: parent
+ spacing: 5
- text: qsTr("")
- checked: false
- anchors.horizontalCenter: parent.horizontalCenter
+ Text {
+ id: mainStatus
+ text: "off"
+ font.pixelSize: 26
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
- Connections {
- function onCheckedChanged() {
- if (vpntoggle.checked == true
- && ctx.status == "off") {
- backend.switchOn()
- }
- if (vpntoggle.checked === false
- && ctx.status == "on") {
- backend.switchOff()
+ Text {
+ id: mainCurrentGateway
+ text: ""
+ font.pixelSize: 20
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ SwitchDelegate {
+
+ id: vpntoggle
+
+ text: qsTr("")
+ checked: false
+ anchors.horizontalCenter: parent.horizontalCenter
+
+ Connections {
+ function onCheckedChanged() {
+ if (vpntoggle.checked == true
+ && ctx.status == "off") {
+ backend.switchOn()
+ }
+ if (vpntoggle.checked === false
+ && ctx.status == "on") {
+ backend.switchOff()
+ }
}
}
- }
- contentItem: Text {
- rightPadding: vpntoggle.indicator.width + vpntoggle.spacing
- text: vpntoggle.text
- font: vpntoggle.font
- opacity: enabled ? 1.0 : 0.3
- color: vpntoggle.down ? "#17a81a" : "#21be2b"
- elide: Text.ElideRight
- verticalAlignment: Text.AlignVCenter
- }
+ contentItem: Text {
+ rightPadding: vpntoggle.indicator.width + vpntoggle.spacing
+ text: vpntoggle.text
+ font: vpntoggle.font
+ opacity: enabled ? 1.0 : 0.5
+ color: vpntoggle.down ? "#17a81a" : "#21be2b"
+ elide: Text.ElideRight
+ verticalAlignment: Text.AlignVCenter
+ }
- indicator: Rectangle {
- implicitWidth: 48
- implicitHeight: 26
- x: vpntoggle.width - width - vpntoggle.rightPadding
- y: parent.height / 2 - height / 2
- radius: 13
- color: vpntoggle.checked ? "#17a81a" : "transparent"
- border.color: vpntoggle.checked ? "#17a81a" : "#cccccc"
-
- Rectangle {
- x: vpntoggle.checked ? parent.width - width : 0
- width: 26
- height: 26
+ indicator: Rectangle {
+ implicitWidth: 48
+ implicitHeight: 26
+ x: vpntoggle.width - width - vpntoggle.rightPadding
+ y: parent.height / 2 - height / 2
radius: 13
- color: vpntoggle.down ? "#cccccc" : "#ffffff"
- border.color: vpntoggle.checked ? (vpntoggle.down ? "#17a81a" : "#21be2b") : "#999999"
+ color: vpntoggle.checked ? "#17a81a" : "transparent"
+ border.color: vpntoggle.checked ? "#17a81a" : "#cccccc"
+
+ Rectangle {
+ x: vpntoggle.checked ? parent.width - width : 0
+ width: 26
+ height: 26
+ radius: 13
+ color: vpntoggle.down ? "#cccccc" : "#ffffff"
+ border.color: vpntoggle.checked ? (vpntoggle.down ? "#17a81a" : "#21be2b") : "#999999"
+ }
}
- }
- background: Rectangle {
- implicitWidth: 100
- implicitHeight: 40
- visible: vpntoggle.down || vpntoggle.highlighted
- color: vpntoggle.down ? "#bdbebf" : "#eeeeee"
+ background: Rectangle {
+ implicitWidth: 100
+ implicitHeight: 40
+ visible: vpntoggle.down || vpntoggle.highlighted
+ color: vpntoggle.down ? "#17a81a" : "#eeeeee"
+ }
+ } // end switchdelegate
+
+ Text {
+ id: manualOverrideWarning
+ font.pixelSize: 10
+ color: "grey"
+ text: qsTr("Location has been manually set.")
+ anchors.horizontalCenter: parent.horizontalCenter
+ visible: isManualLocation()
}
- } // end switchdelegate
-
- Text {
- id: manualOverrideWarning
- font.pixelSize: 10
- color: "grey"
- text: qsTr("Location has been manually set.")
- anchors.horizontalCenter: parent.horizontalCenter
- visible: isManualLocation()
- }
- }
- }
+ } // end column
+ } // end inner item
+ } // end outer item
Item {
@@ -148,7 +179,7 @@ ApplicationWindow {
RadioButton {
id: autoSelectionButton
checked: !isManualLocation()
- text: qsTr("Best")
+ text: qsTr("Recommended")
onClicked: backend.useAutomaticGateway()
}
RadioButton {
@@ -163,7 +194,7 @@ ApplicationWindow {
visible: manualSelectionButton.checked
anchors.horizontalCenter: parent.horizontalCenter
- model: [qsTr("Best")]
+ model: [qsTr("Recommended")]
onActivated: {
console.debug("Selected gateway:", currentText)
backend.useLocation(currentText.toString())
@@ -200,6 +231,45 @@ ApplicationWindow {
}
} // end column
} // end item
+
+ Item {
+
+ id: bridgesTab
+ anchors.centerIn: parent
+ width: parent.width
+
+ Column {
+
+ anchors.centerIn: parent
+ spacing: 10
+ width: parent.width
+
+ CheckBox {
+ checked: false
+ text: qsTr("Use obfs4 bridges")
+ font.pixelSize: 14
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ id: bridgesInfo
+ width: 250
+ color: "grey"
+ text: qsTr("Select a bridge only if you know that you need it to evade censorship in your country or local network.")
+ anchors.horizontalCenter: parent.horizontalCenter
+ wrapMode: Text.WordWrap
+ }
+ Text {
+ id: bridgeReconnect
+ width: 250
+ font.pixelSize: 12
+ color: "red"
+ text: qsTr("The change will take effect next time you connect to the VPN.")
+ anchors.horizontalCenter: parent.horizontalCenter
+ wrapMode: Text.WordWrap
+ visible: true
+ }
+ } // end column
+ } // end item
} // end stacklayout
Connections {