|
|
|
@ -29,12 +29,16 @@
|
|
|
|
|
import QtQuick 2.2
|
|
|
|
|
import moneroComponents.TranslationManager 1.0
|
|
|
|
|
import QtQuick.Dialogs 1.2
|
|
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
|
import QtQuick.Layouts 1.2
|
|
|
|
|
import "../components"
|
|
|
|
|
import 'utils.js' as Utils
|
|
|
|
|
|
|
|
|
|
// Reusable component for managing wallet (account name, path, private key)
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
ColumnLayout {
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
spacing: 5
|
|
|
|
|
|
|
|
|
|
property alias titleText: titleText.text
|
|
|
|
|
property alias accountNameText: accountName.text
|
|
|
|
@ -45,15 +49,49 @@ Item {
|
|
|
|
|
property alias restoreHeightVisible: restoreHeightItem.visible
|
|
|
|
|
property alias walletName : accountName.text
|
|
|
|
|
property alias progressDotsModel : progressDots.model
|
|
|
|
|
property alias recoverFromKeysAddress: addressLine.text;
|
|
|
|
|
property alias recoverFromKeysViewKey: viewKeyLine.text;
|
|
|
|
|
property alias recoverFromKeysSpendKey: spendKeyLine.text;
|
|
|
|
|
// recover mode or create new wallet
|
|
|
|
|
property bool recoverMode: false
|
|
|
|
|
// Recover form seed or keys
|
|
|
|
|
property bool recoverFromSeedMode: true
|
|
|
|
|
|
|
|
|
|
// TODO extend properties if needed
|
|
|
|
|
function checkFields(){
|
|
|
|
|
var addressOK = walletManager.addressValid(addressLine.text, wizard.settings.testnet)
|
|
|
|
|
var viewKeyOK = walletManager.keyValid(viewKeyLine.text, addressLine.text, true, wizard.settings.testnet)
|
|
|
|
|
// Spendkey is optional
|
|
|
|
|
var spendKeyOK = (spendKeyLine.text.length > 0)? walletManager.keyValid(spendKeyLine.text, addressLine.text, false, wizard.settings.testnet) : true
|
|
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
Row {
|
|
|
|
|
addressLine.error = !addressOK && addressLine.text.length != 0
|
|
|
|
|
viewKeyLine.error = !viewKeyOK && viewKeyLine.text.length != 0
|
|
|
|
|
spendKeyLine.error = !spendKeyOK && spendKeyLine.text.length != 0
|
|
|
|
|
|
|
|
|
|
return addressOK && viewKeyOK && spendKeyOK
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function checkNextButton(){
|
|
|
|
|
wizard.nextButton.enabled = false
|
|
|
|
|
console.log("check next", recoverFromSeed.visible)
|
|
|
|
|
if(recoverMode && !recoverFromSeedMode) {
|
|
|
|
|
console.log("checking key fields")
|
|
|
|
|
wizard.nextButton.enabled = checkFields();
|
|
|
|
|
} else if (recoverMode && recoverFromSeedMode) {
|
|
|
|
|
wizard.nextButton.enabled = checkSeed()
|
|
|
|
|
} else
|
|
|
|
|
wizard.nextButton.enabled = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function checkSeed() {
|
|
|
|
|
console.log("Checking seed")
|
|
|
|
|
var wordsArray = Utils.lineBreaksToSpaces(uiItem.wordsTextItem.memoText).split(" ");
|
|
|
|
|
return wordsArray.length === 25
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
|
id: dotsRow
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.topMargin: 85
|
|
|
|
|
Layout.topMargin: 85
|
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
|
spacing: 6
|
|
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
@ -75,180 +113,173 @@ Item {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
RowLayout {
|
|
|
|
|
id: headerColumn
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.leftMargin: 16
|
|
|
|
|
anchors.rightMargin: 16
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 74
|
|
|
|
|
spacing: 24
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
id: titleText
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
width: headerColumn.width - dotsRow.width - 16
|
|
|
|
|
font.family: "Arial"
|
|
|
|
|
font.pixelSize: 28
|
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
//renderType: Text.NativeRendering
|
|
|
|
|
color: "#3F3F3F"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
font.family: "Arial"
|
|
|
|
|
font.pixelSize: 18
|
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
//renderType: Text.NativeRendering
|
|
|
|
|
color: "#4A4646"
|
|
|
|
|
text: qsTr("or use the name suggested below:") + translationManager.emptyString
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: walletNameItem
|
|
|
|
|
anchors.top: headerColumn.bottom
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
anchors.topMargin: 24
|
|
|
|
|
width: 300
|
|
|
|
|
height: 62
|
|
|
|
|
ColumnLayout {
|
|
|
|
|
|
|
|
|
|
TextInput {
|
|
|
|
|
Label {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.topMargin: 20
|
|
|
|
|
fontSize: 14
|
|
|
|
|
text: qsTr("Wallet name")
|
|
|
|
|
+ translationManager.emptyString
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LineEdit {
|
|
|
|
|
id: accountName
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
horizontalAlignment: TextInput.AlignHCenter
|
|
|
|
|
verticalAlignment: TextInput.AlignVCenter
|
|
|
|
|
font.family: "Arial"
|
|
|
|
|
font.pixelSize: 32
|
|
|
|
|
renderType: Text.NativeRendering
|
|
|
|
|
color: "#FF6C3C"
|
|
|
|
|
focus: true
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
text: defaultAccountName
|
|
|
|
|
selectByMouse: true
|
|
|
|
|
onTextUpdated: checkNextButton()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Keys.onReleased: {
|
|
|
|
|
wizard.nextButton.enabled = (accountName.length > 0)
|
|
|
|
|
RowLayout{
|
|
|
|
|
visible: recoverMode
|
|
|
|
|
StandardButton {
|
|
|
|
|
id: recoverFromSeedButton
|
|
|
|
|
text: qsTr("Restore from seed") + translationManager.emptyString
|
|
|
|
|
shadowReleasedColor: "#FF4304"
|
|
|
|
|
shadowPressedColor: "#B32D00"
|
|
|
|
|
releasedColor: "#FF6C3C"
|
|
|
|
|
pressedColor: "#FF4304"
|
|
|
|
|
enabled: recoverFromKeys.visible
|
|
|
|
|
onClicked: {
|
|
|
|
|
recoverFromSeedMode = true;
|
|
|
|
|
checkNextButton();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
height: 1
|
|
|
|
|
color: "#DBDBDB"
|
|
|
|
|
StandardButton {
|
|
|
|
|
id: recoverFromKeysButton
|
|
|
|
|
text: qsTr("Restore from keys") + translationManager.emptyString
|
|
|
|
|
shadowReleasedColor: "#FF4304"
|
|
|
|
|
shadowPressedColor: "#B32D00"
|
|
|
|
|
releasedColor: "#FF6C3C"
|
|
|
|
|
pressedColor: "#FF4304"
|
|
|
|
|
enabled: recoverFromSeed.visible
|
|
|
|
|
onClicked: {
|
|
|
|
|
recoverFromSeedMode = false;
|
|
|
|
|
checkNextButton();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
id: frameHeader
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.leftMargin: 16
|
|
|
|
|
anchors.rightMargin: 16
|
|
|
|
|
anchors.top: walletNameItem.bottom
|
|
|
|
|
anchors.topMargin: 24
|
|
|
|
|
font.family: "Arial"
|
|
|
|
|
font.pixelSize: 24
|
|
|
|
|
font.bold: true
|
|
|
|
|
//renderType: Text.NativeRendering
|
|
|
|
|
color: "#4A4646"
|
|
|
|
|
elide: Text.ElideRight
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
// Recover from seed
|
|
|
|
|
RowLayout {
|
|
|
|
|
id: recoverFromSeed
|
|
|
|
|
visible: !recoverMode || ( recoverMode && recoverFromSeedMode)
|
|
|
|
|
WizardMemoTextInput {
|
|
|
|
|
id : memoTextItem
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.preferredWidth: 600
|
|
|
|
|
Layout.minimumWidth: 300
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Recover from keys
|
|
|
|
|
GridLayout {
|
|
|
|
|
id: recoverFromKeys
|
|
|
|
|
visible: recoverMode && !recoverFromSeedMode
|
|
|
|
|
columns: 1
|
|
|
|
|
LineEdit {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
id: addressLine
|
|
|
|
|
placeholderText: qsTr("Account address (public)")
|
|
|
|
|
onTextUpdated: checkNextButton()
|
|
|
|
|
}
|
|
|
|
|
LineEdit {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
id: viewKeyLine
|
|
|
|
|
placeholderText: qsTr("View key (private)")
|
|
|
|
|
onTextUpdated: checkNextButton()
|
|
|
|
|
|
|
|
|
|
WizardMemoTextInput {
|
|
|
|
|
id : memoTextItem
|
|
|
|
|
width: parent.width
|
|
|
|
|
anchors.top : frameHeader.bottom
|
|
|
|
|
anchors.topMargin: 16
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Restore Height
|
|
|
|
|
LineEdit {
|
|
|
|
|
id: restoreHeightItem
|
|
|
|
|
anchors.top: memoTextItem.bottom
|
|
|
|
|
width: 250
|
|
|
|
|
anchors.topMargin: 20
|
|
|
|
|
placeholderText: qsTr("Restore height (optional)")
|
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
|
validator: IntValidator {
|
|
|
|
|
bottom:0
|
|
|
|
|
}
|
|
|
|
|
LineEdit {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
id: spendKeyLine
|
|
|
|
|
placeholderText: qsTr("Spend key (private)")
|
|
|
|
|
onTextUpdated: checkNextButton()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Row {
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.top: (restoreHeightItem.visible)? restoreHeightItem.bottom : (memoTextItem.visible)? memoTextItem.bottom : frameHeader.bottom
|
|
|
|
|
anchors.topMargin: 24
|
|
|
|
|
spacing: 16
|
|
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
|
Text {
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
visible: false
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
id: frameHeader
|
|
|
|
|
font.family: "Arial"
|
|
|
|
|
font.pixelSize: 18
|
|
|
|
|
//renderType: Text.NativeRendering
|
|
|
|
|
font.pixelSize: 24
|
|
|
|
|
font.bold: true
|
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
|
color: "#4A4646"
|
|
|
|
|
text: qsTr("Your wallet is stored in") + translationManager.emptyString
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
width: parent.width - x
|
|
|
|
|
height: 34
|
|
|
|
|
|
|
|
|
|
FileDialog {
|
|
|
|
|
id: fileDialog
|
|
|
|
|
selectMultiple: false
|
|
|
|
|
selectFolder: true
|
|
|
|
|
title: qsTr("Please choose a directory") + translationManager.emptyString
|
|
|
|
|
onAccepted: {
|
|
|
|
|
fileUrlInput.text = walletManager.urlToLocalPath(fileDialog.folder)
|
|
|
|
|
fileDialog.visible = false
|
|
|
|
|
}
|
|
|
|
|
onRejected: {
|
|
|
|
|
fileDialog.visible = false
|
|
|
|
|
}
|
|
|
|
|
RowLayout {
|
|
|
|
|
// Restore Height
|
|
|
|
|
LineEdit {
|
|
|
|
|
id: restoreHeightItem
|
|
|
|
|
Layout.preferredWidth: 250
|
|
|
|
|
placeholderText: qsTr("Restore height (optional)")
|
|
|
|
|
validator: IntValidator {
|
|
|
|
|
bottom:0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextInput {
|
|
|
|
|
id: fileUrlInput
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
anchors.leftMargin: 5
|
|
|
|
|
anchors.rightMargin: 5
|
|
|
|
|
clip: true
|
|
|
|
|
font.family: "Arial"
|
|
|
|
|
font.pixelSize: 18
|
|
|
|
|
color: "#6B0072"
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
selectByMouse: true
|
|
|
|
|
ColumnLayout {
|
|
|
|
|
|
|
|
|
|
text: moneroAccountsDir + "/"
|
|
|
|
|
// workaround for the bug "filechooser only opens once"
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
onClicked: {
|
|
|
|
|
mouse.accepted = false
|
|
|
|
|
fileDialog.folder = walletManager.localPathToUrl(fileUrlInput.text)
|
|
|
|
|
fileDialog.open()
|
|
|
|
|
fileUrlInput.focus = true
|
|
|
|
|
}
|
|
|
|
|
Label {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.topMargin: 20
|
|
|
|
|
fontSize: 14
|
|
|
|
|
text: qsTr("Your wallet is stored in") + translationManager.emptyString
|
|
|
|
|
+ translationManager.emptyString
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextInput {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
id: fileUrlInput
|
|
|
|
|
clip: true
|
|
|
|
|
font.family: "Arial"
|
|
|
|
|
font.pixelSize: 18
|
|
|
|
|
color: "#6B0072"
|
|
|
|
|
selectByMouse: true
|
|
|
|
|
text: moneroAccountsDir + "/"
|
|
|
|
|
// workaround for the bug "filechooser only opens once"
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
onClicked: {
|
|
|
|
|
mouse.accepted = false
|
|
|
|
|
fileDialog.folder = walletManager.localPathToUrl(fileUrlInput.text)
|
|
|
|
|
fileDialog.open()
|
|
|
|
|
fileUrlInput.focus = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
height: 1
|
|
|
|
|
color: "#DBDBDB"
|
|
|
|
|
FileDialog {
|
|
|
|
|
id: fileDialog
|
|
|
|
|
selectMultiple: false
|
|
|
|
|
selectFolder: true
|
|
|
|
|
title: qsTr("Please choose a directory") + translationManager.emptyString
|
|
|
|
|
onAccepted: {
|
|
|
|
|
fileUrlInput.text = walletManager.urlToLocalPath(fileDialog.folder)
|
|
|
|
|
fileDialog.visible = false
|
|
|
|
|
}
|
|
|
|
|
onRejected: {
|
|
|
|
|
fileDialog.visible = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|