From eb457019dde0d15c5cb0fc940e1d05c76cbe8235 Mon Sep 17 00:00:00 2001 From: Sander Ferdinand Date: Wed, 18 Jul 2018 16:51:56 +0200 Subject: [PATCH] Move function to show the seed page to Utils.js --- js/Utils.js | 27 +++++++++++++++++++++++++++ main.qml | 27 ++------------------------- pages/settings/SettingsWallet.qml | 4 +--- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/js/Utils.js b/js/Utils.js index fdf24c6b..56953f50 100644 --- a/js/Utils.js +++ b/js/Utils.js @@ -26,4 +26,31 @@ function formatDate( date, params ) { function isNumeric(n) { return !isNaN(parseFloat(n)) && isFinite(n); +} + +function showSeedPage() { + // Shows `Settings->Seed & keys`. Prompts a password dialog. + passwordDialog.onAcceptedCallback = function() { + if(walletPassword === passwordDialog.password){ + if(currentWallet.seedLanguage == "") { + console.log("No seed language set. Using English as default"); + currentWallet.setSeedLanguage("English"); + } + // Load keys page + middlePanel.state = "Keys" + } else { + informationPopup.title = qsTr("Error") + translationManager.emptyString; + informationPopup.text = qsTr("Wrong password"); + informationPopup.open() + informationPopup.onCloseCallback = function() { + passwordDialog.open() + } + } + } + passwordDialog.onRejectedCallback = function() { + appWindow.showPageRequest("Settings"); + } + passwordDialog.open(); + if(isMobile) hideMenu(); + updateBalance(); } \ No newline at end of file diff --git a/main.qml b/main.qml index 4b6a6942..a842e098 100644 --- a/main.qml +++ b/main.qml @@ -40,6 +40,7 @@ import moneroComponents.NetworkType 1.0 import "components" import "wizard" +import "../js/Utils.js" as Utils import "js/Windows.js" as Windows ApplicationWindow { @@ -1415,31 +1416,7 @@ ApplicationWindow { updateBalance(); } - onKeysClicked: { - passwordDialog.onAcceptedCallback = function() { - if(walletPassword === passwordDialog.password){ - if(currentWallet.seedLanguage == "") { - console.log("No seed language set. Using English as default"); - currentWallet.setSeedLanguage("English"); - } - // Load keys page - middlePanel.state = "Keys" - } else { - informationPopup.title = qsTr("Error") + translationManager.emptyString; - informationPopup.text = qsTr("Wrong password"); - informationPopup.open() - informationPopup.onCloseCallback = function() { - passwordDialog.open() - } - } - } - passwordDialog.onRejectedCallback = function() { - appWindow.showPageRequest("Settings"); - } - passwordDialog.open(); - if(isMobile) hideMenu(); - updateBalance(); - } + onKeysClicked: Utils.showSeedPage(); } RightPanel { diff --git a/pages/settings/SettingsWallet.qml b/pages/settings/SettingsWallet.qml index ef2c43df..6536d7c7 100644 --- a/pages/settings/SettingsWallet.qml +++ b/pages/settings/SettingsWallet.qml @@ -286,9 +286,7 @@ Rectangle { MouseArea { cursorShape: Qt.PointingHandCursor anchors.fill: parent - onClicked: { - Utils.showSeedPage(); - } + onClicked: Utils.showSeedPage(); } } }