2015-04-01 08:56:05 +00:00
|
|
|
// Copyright (c) 2014-2015, The Monero Project
|
|
|
|
//
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without modification, are
|
|
|
|
// permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
|
|
// conditions and the following disclaimer.
|
|
|
|
//
|
|
|
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
|
|
// of conditions and the following disclaimer in the documentation and/or other
|
|
|
|
// materials provided with the distribution.
|
|
|
|
//
|
|
|
|
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
|
|
|
// used to endorse or promote products derived from this software without specific
|
|
|
|
// prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
|
|
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
|
|
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
|
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2014-08-19 12:58:02 +00:00
|
|
|
import QtQuick 2.2
|
2016-06-15 10:25:45 +00:00
|
|
|
import Qt.labs.settings 1.0
|
|
|
|
|
2014-08-29 08:44:31 +00:00
|
|
|
import "../components"
|
2014-08-19 12:58:02 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: wizard
|
2016-01-25 21:17:55 +00:00
|
|
|
property alias nextButton : nextButton
|
2016-01-26 07:30:07 +00:00
|
|
|
property var settings : ({})
|
|
|
|
property int currentPage: 0
|
2016-02-06 16:19:54 +00:00
|
|
|
|
|
|
|
property var paths: {
|
|
|
|
"create_wallet" : [welcomePage, optionsPage, createWalletPage, passwordPage, donationPage, finishPage ],
|
|
|
|
"recovery_wallet" : [welcomePage, optionsPage, recoveryWalletPage, passwordPage, donationPage, finishPage ]
|
|
|
|
}
|
|
|
|
property string currentPath: "create_wallet"
|
|
|
|
property var pages: paths[currentPath]
|
2016-01-25 21:17:55 +00:00
|
|
|
|
2014-08-29 08:44:31 +00:00
|
|
|
signal useMoneroClicked()
|
2014-08-19 12:58:02 +00:00
|
|
|
border.color: "#DBDBDB"
|
|
|
|
border.width: 1
|
|
|
|
color: "#FFFFFF"
|
|
|
|
|
2016-01-25 21:17:55 +00:00
|
|
|
function switchPage(next) {
|
2016-01-26 07:30:07 +00:00
|
|
|
// save settings for current page;
|
2016-06-14 13:09:14 +00:00
|
|
|
if (next && typeof pages[currentPage].onPageClosed !== 'undefined') {
|
|
|
|
if (pages[currentPage].onPageClosed(settings) !== true) {
|
|
|
|
print ("Can't go to the next page");
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
|
2016-01-26 07:30:07 +00:00
|
|
|
}
|
2016-07-21 10:56:17 +00:00
|
|
|
print ("switchpage: currentPage: ", currentPage);
|
2016-01-26 07:30:07 +00:00
|
|
|
|
2016-02-02 21:09:45 +00:00
|
|
|
if (currentPage > 0 || currentPage < pages.length - 1) {
|
|
|
|
pages[currentPage].opacity = 0
|
|
|
|
var step_value = next ? 1 : -1
|
|
|
|
currentPage += step_value
|
|
|
|
pages[currentPage].opacity = 1;
|
2016-06-14 13:09:14 +00:00
|
|
|
|
2016-07-21 10:56:17 +00:00
|
|
|
var nextButtonVisible = pages[currentPage] !== optionsPage;
|
|
|
|
nextButton.visible = nextButtonVisible;
|
|
|
|
|
2016-06-14 13:09:14 +00:00
|
|
|
if (next && typeof pages[currentPage].onPageOpened !== 'undefined') {
|
|
|
|
pages[currentPage].onPageOpened(settings)
|
|
|
|
}
|
2016-07-21 10:56:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-01-25 21:17:55 +00:00
|
|
|
}
|
2016-02-02 21:09:45 +00:00
|
|
|
}
|
|
|
|
|
2016-01-25 21:17:55 +00:00
|
|
|
|
2016-06-10 13:41:13 +00:00
|
|
|
|
2016-02-02 21:09:45 +00:00
|
|
|
function openCreateWalletPage() {
|
|
|
|
print ("show create wallet page");
|
|
|
|
pages[currentPage].opacity = 0;
|
|
|
|
createWalletPage.opacity = 1
|
2016-02-06 16:19:54 +00:00
|
|
|
currentPath = "create_wallet"
|
|
|
|
pages = paths[currentPath]
|
2016-02-02 21:09:45 +00:00
|
|
|
currentPage = pages.indexOf(createWalletPage)
|
2016-02-23 15:59:26 +00:00
|
|
|
createWalletPage.createWallet(settings)
|
2016-07-21 10:56:17 +00:00
|
|
|
wizard.nextButton.visible = true
|
|
|
|
createWalletPage.onPageOpened(settings);
|
|
|
|
|
2016-02-23 15:59:26 +00:00
|
|
|
|
2016-02-02 21:09:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function openRecoveryWalletPage() {
|
|
|
|
print ("show recovery wallet page");
|
|
|
|
pages[currentPage].opacity = 0
|
|
|
|
recoveryWalletPage.opacity = 1
|
2016-02-06 16:19:54 +00:00
|
|
|
currentPath = "recovery_wallet"
|
|
|
|
pages = paths[currentPath]
|
2016-02-02 21:09:45 +00:00
|
|
|
currentPage = pages.indexOf(recoveryWalletPage)
|
2016-07-21 10:56:17 +00:00
|
|
|
wizard.nextButton.visible = true
|
|
|
|
recoveryWalletPage.onPageOpened(settings);
|
|
|
|
|
2016-02-02 21:09:45 +00:00
|
|
|
}
|
|
|
|
|
2016-06-14 13:09:14 +00:00
|
|
|
//! actually writes the wallet
|
|
|
|
function applySettings() {
|
2016-08-16 20:21:46 +00:00
|
|
|
console.log("Here we apply the settings");
|
2016-06-14 13:09:14 +00:00
|
|
|
// here we need to actually move wallet to the new location
|
2016-08-16 20:21:46 +00:00
|
|
|
|
2016-06-14 13:09:14 +00:00
|
|
|
var new_wallet_filename = settings.wallet_path + "/"
|
|
|
|
+ settings.account_name + "/"
|
|
|
|
+ settings.account_name;
|
|
|
|
|
|
|
|
// moving wallet files to the new destination, if user changed it
|
|
|
|
if (new_wallet_filename !== settings.wallet_filename) {
|
|
|
|
// using previously saved wallet;
|
|
|
|
settings.wallet.store(new_wallet_filename);
|
|
|
|
}
|
|
|
|
|
2016-08-16 20:21:46 +00:00
|
|
|
// protecting wallet with password
|
|
|
|
settings.wallet.setPassword(settings.wallet_password);
|
|
|
|
|
2016-06-14 13:09:14 +00:00
|
|
|
// saving wallet_filename;
|
|
|
|
settings['wallet_filename'] = new_wallet_filename;
|
2016-06-15 10:25:45 +00:00
|
|
|
|
|
|
|
// persist settings
|
2016-06-15 13:34:55 +00:00
|
|
|
appWindow.persistentSettings.language = settings.language
|
2016-07-19 20:45:12 +00:00
|
|
|
appWindow.persistentSettings.locale = settings.locale
|
2016-06-15 13:34:55 +00:00
|
|
|
appWindow.persistentSettings.account_name = settings.account_name
|
|
|
|
appWindow.persistentSettings.wallet_path = settings.wallet_path
|
|
|
|
appWindow.persistentSettings.allow_background_mining = settings.allow_background_mining
|
|
|
|
appWindow.persistentSettings.auto_donations_enabled = settings.auto_donations_enabled
|
|
|
|
appWindow.persistentSettings.auto_donations_amount = settings.auto_donations_amount
|
2016-09-22 21:05:20 +00:00
|
|
|
appWindow.persistentSettings.daemon_address = settings.daemon_address
|
|
|
|
appWindow.persistentSettings.testnet = settings.testnet
|
|
|
|
|
2016-06-14 13:09:14 +00:00
|
|
|
}
|
|
|
|
|
2016-06-15 10:25:45 +00:00
|
|
|
// reading settings from persistent storage
|
|
|
|
Component.onCompleted: {
|
2016-06-15 13:34:55 +00:00
|
|
|
console.log("rootItem: ", appWindow);
|
|
|
|
settings['allow_background_mining'] = appWindow.persistentSettings.allow_background_mining
|
|
|
|
settings['auto_donations_enabled'] = appWindow.persistentSettings.auto_donations_enabled
|
|
|
|
settings['auto_donations_amount'] = appWindow.persistentSettings.auto_donations_amount
|
2016-06-15 10:25:45 +00:00
|
|
|
}
|
2016-02-02 21:09:45 +00:00
|
|
|
|
|
|
|
|
2014-08-19 12:58:02 +00:00
|
|
|
Rectangle {
|
|
|
|
id: nextButton
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 50
|
2014-08-21 10:09:52 +00:00
|
|
|
visible: wizard.currentPage !== 1 && wizard.currentPage !== 6
|
2014-08-19 12:58:02 +00:00
|
|
|
width: 50; height: 50
|
|
|
|
radius: 25
|
2016-01-29 19:08:17 +00:00
|
|
|
color: enabled ? nextArea.containsMouse ? "#FF4304" : "#FF6C3C" : "#DBDBDB"
|
|
|
|
|
2014-08-19 12:58:02 +00:00
|
|
|
|
|
|
|
Image {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
anchors.horizontalCenterOffset: 3
|
|
|
|
source: "qrc:///images/nextPage.png"
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: nextArea
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onClicked: wizard.switchPage(true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-26 07:30:07 +00:00
|
|
|
|
2014-08-19 12:58:02 +00:00
|
|
|
WizardWelcome {
|
|
|
|
id: welcomePage
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: nextButton.left
|
|
|
|
anchors.left: prevButton.right
|
|
|
|
anchors.leftMargin: 50
|
|
|
|
anchors.rightMargin: 50
|
|
|
|
}
|
|
|
|
|
|
|
|
WizardOptions {
|
|
|
|
id: optionsPage
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: nextButton.left
|
|
|
|
anchors.left: prevButton.right
|
|
|
|
anchors.leftMargin: 50
|
|
|
|
anchors.rightMargin: 50
|
2016-02-02 21:09:45 +00:00
|
|
|
onCreateWalletClicked: wizard.openCreateWalletPage()
|
|
|
|
onRecoveryWalletClicked: wizard.openRecoveryWalletPage()
|
2014-08-20 19:19:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WizardCreateWallet {
|
|
|
|
id: createWalletPage
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: nextButton.left
|
|
|
|
anchors.left: prevButton.right
|
|
|
|
anchors.leftMargin: 50
|
|
|
|
anchors.rightMargin: 50
|
2014-08-19 12:58:02 +00:00
|
|
|
}
|
|
|
|
|
2016-02-02 21:09:45 +00:00
|
|
|
WizardRecoveryWallet {
|
|
|
|
id: recoveryWalletPage
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: nextButton.left
|
|
|
|
anchors.left: prevButton.right
|
|
|
|
anchors.leftMargin: 50
|
|
|
|
anchors.rightMargin: 50
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-21 10:09:52 +00:00
|
|
|
WizardPassword {
|
|
|
|
id: passwordPage
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: nextButton.left
|
|
|
|
anchors.left: prevButton.right
|
|
|
|
anchors.leftMargin: 50
|
|
|
|
anchors.rightMargin: 50
|
|
|
|
}
|
|
|
|
|
|
|
|
WizardDonation {
|
|
|
|
id: donationPage
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: nextButton.left
|
|
|
|
anchors.left: prevButton.right
|
|
|
|
anchors.leftMargin: 50
|
|
|
|
anchors.rightMargin: 50
|
|
|
|
}
|
|
|
|
|
|
|
|
WizardFinish {
|
|
|
|
id: finishPage
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: nextButton.left
|
|
|
|
anchors.left: prevButton.right
|
|
|
|
anchors.leftMargin: 50
|
|
|
|
anchors.rightMargin: 50
|
|
|
|
}
|
|
|
|
|
2014-08-19 12:58:02 +00:00
|
|
|
Rectangle {
|
|
|
|
id: prevButton
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 50
|
|
|
|
visible: parent.currentPage > 0
|
|
|
|
|
|
|
|
width: 50; height: 50
|
|
|
|
radius: 25
|
|
|
|
color: prevArea.containsMouse ? "#FF4304" : "#FF6C3C"
|
|
|
|
|
|
|
|
Image {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
anchors.horizontalCenterOffset: -3
|
|
|
|
source: "qrc:///images/prevPage.png"
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: prevArea
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onClicked: wizard.switchPage(false)
|
|
|
|
}
|
|
|
|
}
|
2014-08-29 08:44:31 +00:00
|
|
|
|
|
|
|
StandardButton {
|
|
|
|
id: sendButton
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.margins: 50
|
|
|
|
width: 110
|
2016-07-20 19:28:11 +00:00
|
|
|
text: qsTr("USE MONERO") + translationManager.emptyString
|
2014-08-29 08:44:31 +00:00
|
|
|
shadowReleasedColor: "#FF4304"
|
|
|
|
shadowPressedColor: "#B32D00"
|
|
|
|
releasedColor: "#FF6C3C"
|
|
|
|
pressedColor: "#FF4304"
|
2016-02-06 16:19:54 +00:00
|
|
|
visible: parent.paths[currentPath][currentPage] === finishPage
|
2016-06-14 13:09:14 +00:00
|
|
|
onClicked: {
|
|
|
|
wizard.applySettings();
|
|
|
|
wizard.useMoneroClicked()
|
|
|
|
}
|
2014-08-29 08:44:31 +00:00
|
|
|
}
|
2014-08-19 12:58:02 +00:00
|
|
|
}
|