From 39855241fcd0747ebe95e2e92cd5cfcb2d5a64be Mon Sep 17 00:00:00 2001 From: xiphon Date: Wed, 24 Oct 2018 03:50:56 +0000 Subject: [PATCH] password dialog: show error in place --- components/PasswordDialog.qml | 20 +++++++++++++++++++- components/Style.qml | 1 + js/Utils.js | 7 +------ main.qml | 15 ++------------- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/components/PasswordDialog.qml b/components/PasswordDialog.qml index 1da76a6d..230db37f 100644 --- a/components/PasswordDialog.qml +++ b/components/PasswordDialog.qml @@ -42,15 +42,17 @@ Item { property alias password: passwordInput.text property string walletName + property string errorText // same signals as Dialog has signal accepted() signal rejected() signal closeCallback() - function open(walletName) { + function open(walletName, errorText) { inactiveOverlay.visible = true // draw appwindow inactive root.walletName = walletName ? walletName : "" + root.errorText = errorText ? errorText : ""; leftPanel.enabled = false middlePanel.enabled = false titleBar.enabled = false @@ -60,6 +62,10 @@ Item { passwordInput.text = "" } + function showError(errorText) { + open(root.walletName, errorText); + } + function close() { inactiveOverlay.visible = false leftPanel.enabled = true @@ -93,6 +99,18 @@ Item { color: MoneroComponents.Style.defaultFontColor } + Label { + text: root.errorText + visible: root.errorText + + anchors.left: parent.left + color: MoneroComponents.Style.errorColor + font.pixelSize: 16 * scaleRatio + font.family: MoneroComponents.Style.fontLight.name + Layout.fillWidth: true + wrapMode: Text.Wrap + } + TextField { id : passwordInput Layout.topMargin: 6 diff --git a/components/Style.qml b/components/Style.qml index bf0a5084..f57dcfe4 100644 --- a/components/Style.qml +++ b/components/Style.qml @@ -12,6 +12,7 @@ QtObject { property string defaultFontColor: "white" property string dimmedFontColor: "#BBBBBB" + property string errorColor: "#FA6800" property string inputBoxBackground: "black" property string inputBoxBackgroundError: "#FFDDDD" property string inputBoxColor: "white" diff --git a/js/Utils.js b/js/Utils.js index 9a6e4829..dad1f143 100644 --- a/js/Utils.js +++ b/js/Utils.js @@ -39,12 +39,7 @@ function showSeedPage() { // Load keys page appWindow.showPageRequest("Keys"); } else { - informationPopup.title = qsTr("Error") + translationManager.emptyString; - informationPopup.text = qsTr("Wrong password"); - informationPopup.open() - informationPopup.onCloseCallback = function() { - passwordDialog.open() - } + passwordDialog.showError(qsTr("Wrong password")); } } passwordDialog.onRejectedCallback = function() { diff --git a/main.qml b/main.qml index 534c1aca..ae2445db 100644 --- a/main.qml +++ b/main.qml @@ -397,15 +397,9 @@ ApplicationWindow { } // opening with password but password doesn't match console.error("Error opening wallet with password: ", wallet.errorString); - informationPopup.title = qsTr("Error") + translationManager.emptyString; - informationPopup.text = qsTr("Couldn't open wallet: ") + wallet.errorString; - informationPopup.icon = StandardIcon.Critical + passwordDialog.showError(qsTr("Couldn't open wallet: ") + wallet.errorString); console.log("closing wallet async : " + wallet.address) closeWallet(); - informationPopup.open() - informationPopup.onCloseCallback = function() { - passwordDialog.open(walletName) - } return; } @@ -1064,12 +1058,7 @@ ApplicationWindow { handleTransactionConfirmed() } } else { - informationPopup.title = qsTr("Error") + translationManager.emptyString; - informationPopup.text = qsTr("Wrong password"); - informationPopup.open() - informationPopup.onCloseCallback = function() { - passwordDialog.open() - } + passwordDialog.showError(qsTr("Wrong password")); } } passwordDialog.onRejectedCallback = null;