Files
pay/desktop/NewAccountPane.qml
T

163 lines
5.4 KiB
QML
Raw Permalink Normal View History

2021-10-15 21:01:40 +02:00
/* * This file is part of the Flowee project
* Copyright (C) 2021 Tom Zander <tom@flowee.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.11
import QtQuick.Controls 2.11
import QtQuick.Layouts 1.11
import "widgets" as Flowee
2021-10-15 21:01:40 +02:00
FocusScope {
id: root
anchors.fill: parent
focus: true
Rectangle {
color: "black"
anchors.fill: parent
opacity: 0.4
MouseArea {
anchors.fill: parent
onClicked: root.visible = false
}
}
Rectangle {
color: mainWindow.palette.window
anchors.fill: contentArea
2021-10-28 17:40:10 +02:00
anchors.margins: -10 // have an inset
2021-10-15 21:01:40 +02:00
MouseArea { anchors.fill: parent }
}
Flickable {
id: contentArea
anchors.fill: parent
anchors.margins: 50
contentWidth: width
contentHeight: contentAreaColumn.height + 20
flickableDirection: Flickable.VerticalFlick
clip: true
2021-10-30 16:37:33 +02:00
ScrollBar.vertical: ScrollBar { }
2021-10-15 21:01:40 +02:00
Flowee.CloseIcon {
2021-10-30 16:17:02 +02:00
id: closeIcon
anchors.margins: 6
anchors.right: parent.right
onClicked: root.visible = false
}
2021-10-15 21:01:40 +02:00
Column {
id: contentAreaColumn
width: contentArea.width
y: 10
2021-11-10 12:36:12 +01:00
spacing: 20
2021-10-15 21:01:40 +02:00
Label {
text: qsTr("New Bitcoin Cash Wallet")
2021-10-15 21:01:40 +02:00
anchors.horizontalCenter: parent.horizontalCenter
font.pointSize: 14
}
Flow {
id: optionsRow
anchors.horizontalCenter: parent.horizontalCenter
activeFocusOnTab: true
focus: true
2021-10-15 21:01:40 +02:00
height: 320
spacing: 20
width: Math.min(contentArea.width - 30, 900) // smaller is OK, wider not
property int selectorWidth: (width - spacing * 2) / 3;
property int selectedAccountType: 1
AccountTypeSelector {
id: accountTypeBasic
accountType: 0
title: qsTr("Basic")
width: parent.selectorWidth
features: [
2021-11-10 11:07:00 +01:00
qsTr("Private keys based", "Property of a wallet"),
qsTr("Difficult to backup", "Context: wallet type"),
2021-10-15 21:01:40 +02:00
qsTr("Great for brief usage", "Context: wallet type")
]
}
AccountTypeSelector {
id: accountTypePreferred
accountType: 1
title: qsTr("HD wallet")
width: parent.selectorWidth
features: [
2021-11-09 21:34:40 +01:00
qsTr("Seed-phrase based", "Context: wallet type"),
2021-10-15 21:01:40 +02:00
qsTr("Easy to backup", "Context: wallet type"),
2021-10-28 17:40:10 +02:00
qsTr("Most compatible", "The most compatible wallet type")
2021-10-15 21:01:40 +02:00
]
}
AccountTypeSelector {
id: accountTypeImport
accountType: 2
title: qsTr("Import")
width: parent.selectorWidth
features: [
2021-11-09 21:34:40 +01:00
qsTr("Imports seed-phrase"),
2021-11-10 11:07:00 +01:00
qsTr("Imports private key")
2021-10-15 21:01:40 +02:00
]
}
}
Label {
id: description
anchors.left: optionsRow.left
text: {
var type = optionsRow.selectedAccountType
if (type == 0)
return qsTr("Basic wallet with private keys")
2021-10-15 21:01:40 +02:00
if (type == 1)
2021-11-09 21:34:40 +01:00
return qsTr("Seed-phrase wallet")
2021-11-10 11:07:00 +01:00
return qsTr("Import of an existing wallet")
2021-10-15 21:01:40 +02:00
}
font.pointSize: 14
}
StackLayout {
id: stack
currentIndex: optionsRow.selectedAccountType
anchors.left: optionsRow.left
anchors.right: optionsRow.right
2021-10-25 19:42:13 +02:00
width: parent.width
2021-10-15 21:01:40 +02:00
2021-10-25 19:42:13 +02:00
NewAccountCreateBasicAccount { }
NewAccountCreateHDAccount { }
NewAccountImportAccount { }
2021-10-15 21:01:40 +02:00
}
}
}
Component.onCompleted: forceActiveFocus() // we assume this component is used in a Loader
Keys.onPressed: {
if (event.key === Qt.Key_Escape) {
root.visible = false;
event.accepted = true;
}
else if (event.key === Qt.Key_Left && optionsRow.activeFocus) {
2021-10-15 21:01:40 +02:00
optionsRow.selectedAccountType = Math.max(0, optionsRow.selectedAccountType - 1)
event.accepted = true;
}
else if (event.key === Qt.Key_Right && optionsRow.activeFocus) {
2021-10-15 21:01:40 +02:00
optionsRow.selectedAccountType = Math.min(2, optionsRow.selectedAccountType + 1)
event.accepted = true;
}
}
}