2021-10-15 21:01:40 +02:00
|
|
|
/* * This file is part of the Flowee project
|
2022-10-21 16:58:04 +02:00
|
|
|
* Copyright (C) 2021-2022 Tom Zander <tom@flowee.org>
|
2021-10-15 21:01:40 +02:00
|
|
|
*
|
|
|
|
|
* 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/>.
|
|
|
|
|
*/
|
2022-11-26 10:46:57 +01:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import QtQuick.Layouts
|
2022-11-14 21:19:31 +01:00
|
|
|
import "../Flowee" 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 {
|
2023-02-21 16:40:46 +01:00
|
|
|
color: palette.window
|
2021-10-15 21:01:40 +02:00
|
|
|
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
|
|
|
|
2021-11-02 19:32:13 +01: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 {
|
2021-10-18 22:14:12 +02:00
|
|
|
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
|
2021-10-18 22:14:12 +02:00
|
|
|
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;
|
2022-06-30 17:57:54 +02:00
|
|
|
property int selectedKey: 1
|
2022-10-21 16:58:04 +02:00
|
|
|
|
|
|
|
|
function cardClicked(key) {
|
|
|
|
|
if (selectedKey !== key)
|
|
|
|
|
selectedKey = key;
|
|
|
|
|
else // move scroll area.
|
|
|
|
|
contentArea.flick(0, -1000);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-21 15:47:12 +01:00
|
|
|
Flowee.CardTypeSelector {
|
2021-10-15 21:01:40 +02:00
|
|
|
id: accountTypeBasic
|
2022-06-30 17:57:54 +02:00
|
|
|
key: 0
|
2021-10-15 21:01:40 +02:00
|
|
|
title: qsTr("Basic")
|
|
|
|
|
width: parent.selectorWidth
|
2022-10-21 16:58:04 +02:00
|
|
|
onClicked: parent.cardClicked(key);
|
2021-10-15 21:01:40 +02:00
|
|
|
|
|
|
|
|
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")
|
|
|
|
|
]
|
|
|
|
|
}
|
2022-11-21 15:47:12 +01:00
|
|
|
Flowee.CardTypeSelector {
|
2021-10-15 21:01:40 +02:00
|
|
|
id: accountTypePreferred
|
2022-06-30 17:57:54 +02:00
|
|
|
key: 1
|
2021-10-15 21:01:40 +02:00
|
|
|
title: qsTr("HD wallet")
|
|
|
|
|
width: parent.selectorWidth
|
2022-10-21 16:58:04 +02:00
|
|
|
onClicked: parent.cardClicked(key);
|
2021-10-15 21:01:40 +02:00
|
|
|
|
|
|
|
|
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
|
|
|
]
|
|
|
|
|
}
|
2022-11-21 15:47:12 +01:00
|
|
|
Flowee.CardTypeSelector {
|
2021-10-15 21:01:40 +02:00
|
|
|
id: accountTypeImport
|
2022-06-30 17:57:54 +02:00
|
|
|
key: 2
|
2021-10-15 21:01:40 +02:00
|
|
|
title: qsTr("Import")
|
|
|
|
|
width: parent.selectorWidth
|
2022-11-21 15:45:16 +01:00
|
|
|
onClicked: parent.cardClicked(key);
|
2021-10-15 21:01:40 +02:00
|
|
|
|
|
|
|
|
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: {
|
2022-06-30 17:57:54 +02:00
|
|
|
var type = optionsRow.selectedKey
|
2021-10-15 21:01:40 +02:00
|
|
|
if (type == 0)
|
2021-10-18 22:14:12 +02:00
|
|
|
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
|
2022-06-30 17:57:54 +02:00
|
|
|
currentIndex: optionsRow.selectedKey
|
2021-10-15 21:01:40 +02:00
|
|
|
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
|
2022-09-07 20:32:05 +02:00
|
|
|
Keys.onPressed: (event)=> {
|
2021-10-15 21:01:40 +02:00
|
|
|
if (event.key === Qt.Key_Escape) {
|
|
|
|
|
root.visible = false;
|
|
|
|
|
event.accepted = true;
|
|
|
|
|
}
|
2021-10-18 22:14:12 +02:00
|
|
|
else if (event.key === Qt.Key_Left && optionsRow.activeFocus) {
|
2022-06-30 17:57:54 +02:00
|
|
|
optionsRow.selectedKey = Math.max(0, optionsRow.selectedKey - 1)
|
2021-10-15 21:01:40 +02:00
|
|
|
event.accepted = true;
|
|
|
|
|
}
|
2021-10-18 22:14:12 +02:00
|
|
|
else if (event.key === Qt.Key_Right && optionsRow.activeFocus) {
|
2022-06-30 17:57:54 +02:00
|
|
|
optionsRow.selectedKey = Math.min(2, optionsRow.selectedKey + 1)
|
2021-10-15 21:01:40 +02:00
|
|
|
event.accepted = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|