From fca2ee8d7aeee99e3e24a8cab90c17d7b7c34494 Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Tue, 25 Jan 2022 19:54:21 +0100 Subject: [feat] expose snowflake to ui --- gui/components/StatusBox.qml | 29 +++++++++++++- gui/components/VPNState.qml | 64 +++++++++++++++++++++++++++++++ gui/gui.qrc | 1 + gui/resources/snowflake.svg | 90 ++++++++++++++++++++++++++++++++++++++++++++ gui/themes/themes.js | 2 + 5 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 gui/resources/snowflake.svg (limited to 'gui') diff --git a/gui/components/StatusBox.qml b/gui/components/StatusBox.qml index 7715123..5929033 100644 --- a/gui/components/StatusBox.qml +++ b/gui/components/StatusBox.qml @@ -80,9 +80,32 @@ Item { anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter horizontalAlignment: Text.AlignHCenter - text: "" FadeBehavior on text { } } + Label { + id: snowflakeTip + anchors.top: connectionState.bottom + anchors.horizontalCenter: parent.horizontalCenter + anchors.topMargin: 20 + horizontalAlignment: Text.AlignHCenter + text: qsTr("This can take several minutes") + font.pixelSize: Theme.fontSize * 0.8 + visible: isSnowflakeOn() + } + ProgressBar { + id: snowflakeProgressBar + anchors.top: snowflakeTip.bottom + anchors.horizontalCenter: parent.horizontalCenter + visible: isSnowflakeOn() + value: 0 + } + Label { + id: snowflakeTag + anchors.top: snowflakeProgressBar.bottom + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignHCenter + visible: isSnowflakeOn() + } } Column { @@ -156,4 +179,8 @@ Item { } } } + + function isSnowflakeOn() { + return ctx != undefined && ctx.snowflakeProgress != "" && ctx.snowflakeProgress != "100" + } } diff --git a/gui/components/VPNState.qml b/gui/components/VPNState.qml index eeeb51d..3a8d49a 100644 --- a/gui/components/VPNState.qml +++ b/gui/components/VPNState.qml @@ -19,11 +19,38 @@ StateGroup { State { name: initializing }, + State { + when: ctx != undefined && ctx.snowflakeProgress != "" && ctx.snowflakeProgress != "100" + // TODO animate image + PropertyChanges { + target: connectionState + text: qsTr("Setting up") + font.pixelSize: Theme.fontSize * 1 + } + PropertyChanges { + target: snowflakeProgressBar + value: parseInt(ctx.snowflakeProgress)/100 + } + PropertyChanges { + target: snowflakeTag + text: getSnowflakeTag() + } + PropertyChanges { + target: statusBoxBackground + border.color: Theme.accentConnecting + } + PropertyChanges { + target: connectionImage + source: Theme.iconSnowflake + anchors.horizontalCenter: parent.horizontalCenter + } + }, State { when: ctx != undefined && ctx.status == "off" && startingUI == true PropertyChanges { target: connectionState text: qsTr("Connecting") + font.pixelSize: Theme.fontSize * 1.5 } PropertyChanges { target: statusBoxBackground @@ -56,6 +83,8 @@ StateGroup { PropertyChanges { target: connectionState text: qsTr("Unsecured\nConnection") + font.pixelSize: Theme.fontSize * 1.5 + visible: true } PropertyChanges { target: statusBoxBackground @@ -89,6 +118,8 @@ StateGroup { PropertyChanges { target: connectionState text: qsTr("Secured\nConnection") + font.pixelSize: Theme.fontSize * 1.5 + visible: true } PropertyChanges { target: statusBoxBackground @@ -123,6 +154,8 @@ StateGroup { PropertyChanges { target: connectionState text: qsTr("Connecting") + font.pixelSize: Theme.fontSize * 1.5 + visible: true } PropertyChanges { target: statusBoxBackground @@ -236,4 +269,35 @@ StateGroup { ctx.appName) // TODO failed is not handled yet } } + + function getSnowflakeTag() { + switch (ctx.snowflakeTag) { + case 'conn_pt': + return qsTr("pluggable transport connection") + case 'conn_done': + return qsTr("connection done") + case 'handshake': + return qsTr("doing handshake") + case 'handshake_done': + return qsTr("handshake done") + case 'onehop_create': + return qsTr("creating one-hop connection") + case 'requesting_status': + return qsTr("requesting status") + case 'loading_status': + return qsTr("loading status") + case 'loading_keys': + return qsTr("loading keys") + case 'requesting_descriptors': + return qsTr("requesting descriptors") + case 'loading_descriptors': + return qsTr("loading descriptors") + case 'circuit_create': + return qsTr("creating circuit") + case 'done': + return qsTr("done") + default: + return ctx.snowflakeTag + } + } } diff --git a/gui/gui.qrc b/gui/gui.qrc index 9e357bf..75ff8cf 100644 --- a/gui/gui.qrc +++ b/gui/gui.qrc @@ -67,6 +67,7 @@ resources/quit.svg resources/alert.svg resources/angle-right.svg + resources/snowflake.svg resources/ravens.svg diff --git a/gui/resources/snowflake.svg b/gui/resources/snowflake.svg new file mode 100644 index 0000000..bdc15ad --- /dev/null +++ b/gui/resources/snowflake.svg @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gui/themes/themes.js b/gui/themes/themes.js index 6c7ab4e..4c4d3a9 100644 --- a/gui/themes/themes.js +++ b/gui/themes/themes.js @@ -24,6 +24,8 @@ const maxTextWidth = 296; const windowMargin = 16; const popupMargin = 24; +const iconSnowflake = "../resources/snowflake.svg"; + // XXX unused? move definitions here const desktopAppHeight = 520; const desktopAppWidth = 360; -- cgit v1.2.3