From df09d6d2217e16e5f3fbc18b6e438f31fbc8a64e Mon Sep 17 00:00:00 2001 From: Xavier Michelon Date: Thu, 24 Aug 2023 15:24:11 +0200 Subject: [PATCH] feat(GODT-2772): back button. --- .../bridge-gui/bridge-gui/Resources.qrc | 1 + .../bridge-gui/qml/Proton/Button.qml | 8 +++-- .../qml/SetupWizard/SetupWizard.qml | 31 +++++++++++++++++++ .../bridge-gui/qml/icons/ic-chevron-left.svg | 3 ++ 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 internal/frontend/bridge-gui/bridge-gui/qml/icons/ic-chevron-left.svg diff --git a/internal/frontend/bridge-gui/bridge-gui/Resources.qrc b/internal/frontend/bridge-gui/bridge-gui/Resources.qrc index aa184628..aeea603f 100644 --- a/internal/frontend/bridge-gui/bridge-gui/Resources.qrc +++ b/internal/frontend/bridge-gui/bridge-gui/Resources.qrc @@ -23,6 +23,7 @@ qml/icons/ic-card-identity.svg qml/icons/ic-check.svg qml/icons/ic-chevron-down.svg + qml/icons/ic-chevron-left.svg qml/icons/ic-chevron-right.svg qml/icons/ic-chevron-up.svg qml/icons/ic-cog-wheel.svg diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/Proton/Button.qml b/internal/frontend/bridge-gui/bridge-gui/qml/Proton/Button.qml index f505bca1..82817c76 100644 --- a/internal/frontend/bridge-gui/bridge-gui/qml/Proton/Button.qml +++ b/internal/frontend/bridge-gui/bridge-gui/qml/Proton/Button.qml @@ -23,14 +23,15 @@ T.Button { property bool borderless: false property ColorScheme colorScheme readonly property bool hasTextAndIcon: (control.text !== "") && (iconImage.source.toString().length > 0) + property bool iconOnTheLeft: false readonly property bool isIcon: control.text === "" property int labelType: Proton.Label.LabelType.Body property bool loading: false readonly property bool primary: !secondary property alias secondary: control.flat + property bool secondaryIsOpaque: false property alias textHorizontalAlignment: label.horizontalAlignment property alias textVerticalAlignment: label.verticalAlignment - property bool secondaryIsOpaque: false; font: label.font horizontalPadding: 16 @@ -78,7 +79,7 @@ T.Button { if (control.loading) { return control.colorScheme.interaction_default_hover; } - return secondaryIsOpaque ? control.colorScheme.background_norm: control.colorScheme.interaction_default; + return secondaryIsOpaque ? control.colorScheme.background_norm : control.colorScheme.interaction_default; } } else { if (primary) { @@ -116,6 +117,7 @@ T.Button { } contentItem: RowLayout { id: _contentItem + layoutDirection: iconOnTheLeft ? Qt.RightToLeft : Qt.LeftToRight spacing: control.hasTextAndIcon ? control.spacing : 0 Proton.Label { @@ -135,8 +137,8 @@ T.Button { opacity: control.enabled || control.loading ? 1.0 : 0.5 text: control.text type: labelType - visible: !control.isIcon verticalAlignment: Text.AlignVCenter + visible: !control.isIcon } ColorImage { id: iconImage diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/SetupWizard/SetupWizard.qml b/internal/frontend/bridge-gui/bridge-gui/qml/SetupWizard/SetupWizard.qml index 609b50d2..16ff35b0 100644 --- a/internal/frontend/bridge-gui/bridge-gui/qml/SetupWizard/SetupWizard.qml +++ b/internal/frontend/bridge-gui/bridge-gui/qml/SetupWizard/SetupWizard.qml @@ -36,6 +36,7 @@ Item { } property string address + property var backAction: null property int client property ColorScheme colorScheme property var user @@ -43,6 +44,9 @@ Item { signal showBugReport signal wizardEnded + function _showClientConfig() { + showClientConfig(root.user, root.address); + } function clientIconSource() { switch (client) { case SetupWizard.Client.AppleMail: @@ -77,11 +81,13 @@ Item { wizardEnded(); } function showAppleMailAutoConfig() { + backAction = _showClientConfig; rootStackLayout.currentIndex = SetupWizard.RootStack.TwoPanesView; rightContent.currentIndex = SetupWizard.ContentStack.ClientConfigAppleMail; clientConfigAppleMail.showAutoconfig(); // This will trigger signals that will display the appropriate left content. } function showClientConfig(user, address) { + backAction = null; root.user = user; root.address = address; rootStackLayout.currentIndex = SetupWizard.RootStack.TwoPanesView; @@ -89,12 +95,15 @@ Item { rightContent.currentIndex = SetupWizard.ContentStack.ClientConfigSelector; } function showClientConfigEnd() { + backAction = null; rootStackLayout.currentIndex = SetupWizard.RootStack.ClientConfigEnd; } function showClientParams() { + backAction = _showClientConfig; rootStackLayout.currentIndex = SetupWizard.RootStack.ClientConfigParameters; } function showLogin(username = "") { + backAction = null; rootStackLayout.currentIndex = SetupWizard.RootStack.TwoPanesView; root.address = ""; leftContent.showLogin(); @@ -103,6 +112,7 @@ Item { login.reset(false); } function showOnboarding() { + backAction = null; rootStackLayout.currentIndex = SetupWizard.RootStack.TwoPanesView; root.address = ""; root.user = null; @@ -238,5 +248,26 @@ Item { HelpButton { wizard: root } + Button { + id: backButton + anchors.left: parent.left + anchors.leftMargin: 40 + anchors.top: parent.top + anchors.topMargin: 40 + colorScheme: root.colorScheme + icon.source: "/qml/icons/ic-chevron-left.svg" + iconOnTheLeft: true + secondary: true + secondaryIsOpaque: true + spacing: 8 + text: qsTr("Back") + visible: backAction != null + + onClicked: { + if (backAction) { + backAction(); + } + } + } } diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/icons/ic-chevron-left.svg b/internal/frontend/bridge-gui/bridge-gui/qml/icons/ic-chevron-left.svg new file mode 100644 index 00000000..13be3148 --- /dev/null +++ b/internal/frontend/bridge-gui/bridge-gui/qml/icons/ic-chevron-left.svg @@ -0,0 +1,3 @@ + + +