From 7973d0cbcc5646a401132aa320fe801c2e58e2b1 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Tue, 1 Nov 2016 15:01:24 +0300 Subject: [PATCH 1/3] Custom password dialog. fixes issue with standard dialog --- components/PasswordDialog.qml | 132 ++++++++++++++++++++++++++++------ main.qml | 6 +- pages/Settings.qml | 4 +- 3 files changed, 115 insertions(+), 27 deletions(-) diff --git a/components/PasswordDialog.qml b/components/PasswordDialog.qml index 69a2ae91..c93a94ec 100644 --- a/components/PasswordDialog.qml +++ b/components/PasswordDialog.qml @@ -31,37 +31,129 @@ import QtQuick.Controls 1.4 import QtQuick.Dialogs 1.2 import QtQuick.Layouts 1.1 import QtQuick.Controls.Styles 1.4 +import QtQuick.Window 2.0 -// import "../components" +import "../components" as MoneroComponents -Dialog { +Window { id: root + modality: Qt.ApplicationModal + flags: Qt.Window | Qt.FramelessWindowHint property alias password: passwordInput.text - standardButtons: StandardButton.Ok + StandardButton.Cancel + + // same signals as Dialog has + signal accepted() + signal rejected() + + + function open() { + show() + } + + // TODO: implement without hardcoding sizes + width: 480 + height: 200 + ColumnLayout { - id: column - anchors.fill: parent + id: mainLayout + spacing: 10 + anchors { fill: parent; margins: 35 } - Label { - text: qsTr("Please enter wallet password") - Layout.columnSpan: 2 - Layout.fillWidth: true - font.family: "Arial" - font.pixelSize: 32 + ColumnLayout { + id: column + //anchors {fill: parent; margins: 16 } + Layout.alignment: Qt.AlignHCenter + + Label { + text: qsTr("Please enter wallet password") + Layout.alignment: Qt.AlignHCenter + Layout.columnSpan: 2 + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + font.pixelSize: 24 + font.family: "Arial" + color: "#555555" + } + + TextField { + id : passwordInput + focus:true + Layout.fillWidth: true + Layout.alignment: Qt.AlignHCenter + horizontalAlignment: TextInput.AlignHCenter + verticalAlignment: TextInput.AlignVCenter + font.family: "Arial" + font.pixelSize: 32 + echoMode: TextInput.Password + style: TextFieldStyle { + renderType: Text.NativeRendering + textColor: "#35B05A" + passwordCharacter: "•" + // no background + background: Rectangle { + radius: 0 + border.width: 0 + } + } + + } + // underline + Rectangle { + height: 1 + color: "#DBDBDB" + Layout.fillWidth: true + Layout.alignment: Qt.AlignHCenter + anchors.bottomMargin: 3 + + } + // padding + Rectangle { + Layout.fillWidth: true + Layout.alignment: Qt.AlignHCenter + height: 10 + opacity: 0 + color: "black" + } } + // Ok/Cancel buttons + RowLayout { + id: buttons + spacing: 60 + Layout.alignment: Qt.AlignHCenter - TextField { - id : passwordInput + MoneroComponents.StandardButton { + id: okButton + width: 120 + fontSize: 14 + shadowReleasedColor: "#FF4304" + shadowPressedColor: "#B32D00" + releasedColor: "#FF6C3C" + pressedColor: "#FF4304" + text: qsTr("Ok") - echoMode: TextInput.Password - focus: true - Layout.fillWidth: true - font.family: "Arial" - font.pixelSize: 24 - style: TextFieldStyle { - passwordCharacter: "•" + onClicked: { + accepted() + close() + } + } + + MoneroComponents.StandardButton { + id: cancelButton + width: 120 + fontSize: 14 + shadowReleasedColor: "#FF4304" + shadowPressedColor: "#B32D00" + releasedColor: "#FF6C3C" + pressedColor: "#FF4304" + text: qsTr("Cancel") + onClicked: { + rejected() + close() + } } } } } + + diff --git a/main.qml b/main.qml index 440b79f4..d9b68283 100644 --- a/main.qml +++ b/main.qml @@ -495,7 +495,7 @@ ApplicationWindow { PasswordDialog { id: passwordDialog - standardButtons: StandardButton.Ok + StandardButton.Cancel + onAccepted: { appWindow.currentWallet = null appWindow.initialize(); @@ -503,9 +503,7 @@ ApplicationWindow { onRejected: { appWindow.enableUI(false) } - onDiscard: { - appWindow.enableUI(false) - } + } diff --git a/pages/Settings.qml b/pages/Settings.qml index 8bfb4d2e..4ddbb8b9 100644 --- a/pages/Settings.qml +++ b/pages/Settings.qml @@ -70,7 +70,7 @@ Rectangle { PasswordDialog { id: settingsPasswordDialog - standardButtons: StandardButton.Ok + StandardButton.Cancel + onAccepted: { if(appWindow.password === settingsPasswordDialog.password){ memoTextInput.text = currentWallet.seed @@ -81,9 +81,7 @@ Rectangle { onRejected: { } - onDiscard: { - } } From 513f7ebc3aad72215a65568891487ea6198b6f0f Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Wed, 2 Nov 2016 16:25:26 +0300 Subject: [PATCH 2/3] StandardButton: indicating "focused" state --- components/StandardButton.qml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/StandardButton.qml b/components/StandardButton.qml index 5a088fbf..17f56c3d 100644 --- a/components/StandardButton.qml +++ b/components/StandardButton.qml @@ -41,6 +41,7 @@ Item { property alias text: label.text signal clicked() + Rectangle { anchors.left: parent.left anchors.right: parent.right @@ -51,6 +52,9 @@ Item { parent.enabled ? (buttonArea.pressed ? parent.shadowPressedColor : parent.shadowReleasedColor) : Qt.lighter(parent.shadowReleasedColor) } + border.color: Qt.darker(parent.releasedColor) + border.width: parent.focus ? 1 : 0 + } Rectangle { @@ -64,6 +68,8 @@ Item { } //radius: 4 + + } Text { @@ -92,4 +98,7 @@ Item { anchors.fill: parent onClicked: parent.clicked() } + + Keys.onSpacePressed: clicked() + Keys.onReturnPressed: clicked() } From 550087f4a14df7e5b4ff6592be9e9cd64162b801 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Wed, 2 Nov 2016 16:26:07 +0300 Subject: [PATCH 3/3] PasswordDialog: accept/reject with Enter/Esc, Tab navigation --- components/PasswordDialog.qml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/components/PasswordDialog.qml b/components/PasswordDialog.qml index c93a94ec..79765f7d 100644 --- a/components/PasswordDialog.qml +++ b/components/PasswordDialog.qml @@ -77,7 +77,7 @@ Window { TextField { id : passwordInput - focus:true + focus: true Layout.fillWidth: true Layout.alignment: Qt.AlignHCenter horizontalAlignment: TextInput.AlignHCenter @@ -85,6 +85,8 @@ Window { font.family: "Arial" font.pixelSize: 32 echoMode: TextInput.Password + KeyNavigation.tab: okButton + style: TextFieldStyle { renderType: Text.NativeRendering textColor: "#35B05A" @@ -95,6 +97,16 @@ Window { border.width: 0 } } + Keys.onReturnPressed: { + root.accepted() + root.close() + } + + Keys.onEscapePressed: { + root.rejected() + root.close() + } + } // underline @@ -130,10 +142,10 @@ Window { releasedColor: "#FF6C3C" pressedColor: "#FF4304" text: qsTr("Ok") - + KeyNavigation.tab: cancelButton onClicked: { - accepted() - close() + root.accepted() + root.close() } } @@ -146,13 +158,15 @@ Window { releasedColor: "#FF6C3C" pressedColor: "#FF4304" text: qsTr("Cancel") + KeyNavigation.tab: passwordInput onClicked: { - rejected() - close() + root.rejected() + root.close() } } } } + }