2020-05-19 13:22:38 +00:00
|
|
|
import QtQuick 2.3
|
|
|
|
import QtQuick.Controls 2.4
|
|
|
|
import QtQuick.Layouts 1.11
|
|
|
|
import QtQuick.Window 2.11
|
|
|
|
import QtQuick.Dialogs 1.3
|
2020-06-02 08:41:24 +00:00
|
|
|
import "../imports"
|
2020-05-29 19:15:55 +00:00
|
|
|
import "../shared"
|
2020-05-19 13:22:38 +00:00
|
|
|
|
|
|
|
SwipeView {
|
2020-05-21 15:25:33 +00:00
|
|
|
id: swipeView
|
|
|
|
anchors.fill: parent
|
|
|
|
currentIndex: 0
|
|
|
|
|
2020-06-02 08:41:24 +00:00
|
|
|
property alias btnExistingKey: btnExistingKey
|
|
|
|
|
2020-05-21 15:25:33 +00:00
|
|
|
onCurrentItemChanged: {
|
2020-06-02 08:41:24 +00:00
|
|
|
currentItem.txtPassword.textField.focus = true;
|
2020-05-21 15:25:33 +00:00
|
|
|
}
|
|
|
|
|
2020-05-19 13:22:38 +00:00
|
|
|
Item {
|
2020-06-02 08:41:24 +00:00
|
|
|
id: wizardStep1
|
2020-05-21 15:25:33 +00:00
|
|
|
property int selectedIndex: 0
|
2020-06-02 08:41:24 +00:00
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
2020-05-27 17:26:21 +00:00
|
|
|
|
|
|
|
Text {
|
|
|
|
id: title
|
|
|
|
text: "Generated accounts"
|
|
|
|
font.pointSize: 36
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 20
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
anchors.top: title.bottom
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.topMargin: 20
|
2020-05-19 13:22:38 +00:00
|
|
|
|
2020-05-21 15:25:33 +00:00
|
|
|
|
2020-06-02 08:41:24 +00:00
|
|
|
ButtonGroup {
|
|
|
|
id: accountGroup
|
|
|
|
}
|
2020-05-21 15:25:33 +00:00
|
|
|
|
2020-06-02 08:41:24 +00:00
|
|
|
Component {
|
|
|
|
id: addressViewDelegate
|
|
|
|
|
|
|
|
Item {
|
|
|
|
height: 56
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 0
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 0
|
|
|
|
|
|
|
|
Row {
|
|
|
|
RadioButton {
|
|
|
|
checked: index == 0 ? true : false
|
|
|
|
ButtonGroup.group: accountGroup
|
|
|
|
onClicked: {
|
|
|
|
wizardStep1.selectedIndex = index
|
2020-05-27 17:26:21 +00:00
|
|
|
}
|
2020-06-02 08:41:24 +00:00
|
|
|
}
|
|
|
|
Column {
|
|
|
|
Image {
|
|
|
|
source: identicon
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Column {
|
|
|
|
Text {
|
|
|
|
text: username
|
2020-05-27 17:26:21 +00:00
|
|
|
}
|
2020-06-02 08:41:24 +00:00
|
|
|
Text {
|
|
|
|
text: key
|
|
|
|
width: 160
|
|
|
|
elide: Text.ElideMiddle
|
2020-05-27 17:26:21 +00:00
|
|
|
}
|
2020-05-21 15:25:33 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-27 17:26:21 +00:00
|
|
|
}
|
2020-06-02 08:41:24 +00:00
|
|
|
}
|
2020-05-21 15:25:33 +00:00
|
|
|
|
2020-06-02 08:41:24 +00:00
|
|
|
ListView {
|
|
|
|
id: addressesView
|
|
|
|
contentWidth: 200
|
|
|
|
model: onboardingModel
|
|
|
|
delegate: addressViewDelegate
|
|
|
|
anchors.fill: parent
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2020-05-21 15:25:33 +00:00
|
|
|
|
2020-06-02 08:41:24 +00:00
|
|
|
Item {
|
|
|
|
id: footer
|
|
|
|
width: btnExistingKey.width + selectBtn.width + Theme.padding
|
|
|
|
height: btnExistingKey.height
|
2020-05-27 07:15:42 +00:00
|
|
|
anchors.bottom: parent.bottom
|
2020-06-02 08:41:24 +00:00
|
|
|
anchors.bottomMargin: Theme.padding
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
StyledButton {
|
|
|
|
id: btnExistingKey
|
|
|
|
label: "Access existing key"
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledButton {
|
|
|
|
id: selectBtn
|
|
|
|
anchors.left: btnExistingKey.right
|
|
|
|
anchors.leftMargin: Theme.padding
|
|
|
|
label: "Select"
|
|
|
|
|
|
|
|
onClicked: {
|
2020-06-03 06:38:26 +00:00
|
|
|
onboardingModel.setCurrentAccount(wizardStep1.selectedIndex)
|
2020-06-02 08:41:24 +00:00
|
|
|
swipeView.incrementCurrentIndex()
|
|
|
|
}
|
2020-05-19 13:22:38 +00:00
|
|
|
}
|
2020-05-27 07:15:42 +00:00
|
|
|
}
|
|
|
|
|
2020-05-21 15:25:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
2020-06-02 08:41:24 +00:00
|
|
|
id: wizardStep2
|
2020-05-21 15:25:33 +00:00
|
|
|
property Item txtPassword: txtPassword
|
|
|
|
|
|
|
|
Text {
|
2020-06-03 06:38:26 +00:00
|
|
|
id: step2Title
|
2020-05-21 15:25:33 +00:00
|
|
|
text: "Enter password"
|
|
|
|
font.pointSize: 36
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 20
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
|
|
|
|
2020-06-03 06:38:26 +00:00
|
|
|
Row {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: step2Title.bottom
|
|
|
|
anchors.topMargin: 30
|
|
|
|
Column {
|
|
|
|
Image {
|
|
|
|
source: onboardingModel.currentAccount.identicon
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Column {
|
|
|
|
Text {
|
|
|
|
text: onboardingModel.currentAccount.username
|
|
|
|
}
|
|
|
|
Text {
|
|
|
|
text: onboardingModel.currentAccount.address
|
|
|
|
width: 160
|
|
|
|
elide: Text.ElideMiddle
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-02 08:41:24 +00:00
|
|
|
Input {
|
|
|
|
id: txtPassword
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.rightMargin: Theme.padding
|
|
|
|
anchors.leftMargin: Theme.padding
|
2020-05-21 15:25:33 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2020-06-02 08:41:24 +00:00
|
|
|
placeholderText: "Enter password"
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
this.textField.echoMode = TextInput.Password
|
|
|
|
}
|
|
|
|
Keys.onReturnPressed: {
|
|
|
|
btnNext.clicked()
|
2020-05-19 13:22:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-29 19:15:55 +00:00
|
|
|
StyledButton {
|
2020-06-02 08:41:24 +00:00
|
|
|
id: btnNext
|
2020-05-29 19:15:55 +00:00
|
|
|
label: "Next"
|
2020-05-21 15:25:33 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: 20
|
|
|
|
onClicked: {
|
2020-05-27 07:15:42 +00:00
|
|
|
swipeView.incrementCurrentIndex();
|
2020-05-21 15:25:33 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-19 13:22:38 +00:00
|
|
|
}
|
|
|
|
|
2020-05-21 15:25:33 +00:00
|
|
|
Item {
|
2020-06-02 08:41:24 +00:00
|
|
|
id: wizardStep3
|
2020-05-21 15:25:33 +00:00
|
|
|
property Item txtPassword: txtConfirmPassword
|
2020-05-19 13:22:38 +00:00
|
|
|
|
2020-05-21 15:25:33 +00:00
|
|
|
Text {
|
2020-06-03 06:38:26 +00:00
|
|
|
id: step3Title
|
2020-05-21 15:25:33 +00:00
|
|
|
text: "Confirm password"
|
|
|
|
font.pointSize: 36
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 20
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
2020-05-19 13:22:38 +00:00
|
|
|
|
2020-06-03 06:38:26 +00:00
|
|
|
Row {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: step3Title.bottom
|
|
|
|
anchors.topMargin: 30
|
|
|
|
Column {
|
|
|
|
Image {
|
|
|
|
source: onboardingModel.currentAccount.identicon
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Column {
|
|
|
|
Text {
|
|
|
|
text: onboardingModel.currentAccount.username
|
|
|
|
}
|
|
|
|
Text {
|
|
|
|
text: onboardingModel.currentAccount.address
|
|
|
|
width: 160
|
|
|
|
elide: Text.ElideMiddle
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-02 08:41:24 +00:00
|
|
|
Input {
|
|
|
|
id: txtConfirmPassword
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.rightMargin: Theme.padding
|
|
|
|
anchors.leftMargin: Theme.padding
|
2020-05-21 15:25:33 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2020-06-02 08:41:24 +00:00
|
|
|
placeholderText: "Confirm entered password"
|
2020-05-19 13:22:38 +00:00
|
|
|
|
2020-06-02 08:41:24 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
this.textField.echoMode = TextInput.Password
|
|
|
|
}
|
|
|
|
Keys.onReturnPressed: {
|
|
|
|
btnFinish.clicked()
|
2020-05-21 15:25:33 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-19 13:22:38 +00:00
|
|
|
|
2020-05-21 15:25:33 +00:00
|
|
|
MessageDialog {
|
|
|
|
id: passwordsDontMatchError
|
|
|
|
title: "Error"
|
|
|
|
text: "Passwords don't match"
|
|
|
|
icon: StandardIcon.Warning
|
|
|
|
standardButtons: StandardButton.Ok
|
|
|
|
onAccepted: {
|
2020-05-27 07:15:42 +00:00
|
|
|
txtConfirmPassword.clear();
|
|
|
|
swipeView.currentIndex = 1;
|
|
|
|
txtPassword.focus = true;
|
2020-05-21 15:25:33 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-19 13:22:38 +00:00
|
|
|
|
2020-05-21 15:25:33 +00:00
|
|
|
MessageDialog {
|
|
|
|
id: storeAccountAndLoginError
|
|
|
|
title: "Error storing account and logging in"
|
|
|
|
text: "An error occurred while storing your account and logging in: "
|
2020-05-27 07:15:42 +00:00
|
|
|
icon: StandardIcon.Critical
|
2020-05-21 15:25:33 +00:00
|
|
|
standardButtons: StandardButton.Ok
|
2020-05-19 13:22:38 +00:00
|
|
|
}
|
2020-05-20 19:20:31 +00:00
|
|
|
|
2020-05-27 07:15:42 +00:00
|
|
|
Connections {
|
|
|
|
target: onboardingModel
|
2020-06-02 08:41:24 +00:00
|
|
|
ignoreUnknownSignals: true
|
2020-05-27 07:15:42 +00:00
|
|
|
onLoginResponseChanged: {
|
2020-06-02 08:41:24 +00:00
|
|
|
if(error){
|
|
|
|
storeAccountAndLoginError.text += error;
|
2020-05-27 07:15:42 +00:00
|
|
|
storeAccountAndLoginError.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-29 19:15:55 +00:00
|
|
|
StyledButton {
|
2020-06-02 08:41:24 +00:00
|
|
|
id: btnFinish
|
2020-05-29 19:15:55 +00:00
|
|
|
label: "Finish"
|
2020-05-21 15:25:33 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: 20
|
|
|
|
onClicked: {
|
2020-06-02 08:41:24 +00:00
|
|
|
if (txtConfirmPassword.textField.text != txtPassword.textField.text) {
|
2020-05-27 07:15:42 +00:00
|
|
|
return passwordsDontMatchError.open();
|
2020-05-21 15:25:33 +00:00
|
|
|
}
|
2020-06-02 08:41:24 +00:00
|
|
|
const selectedAccountIndex = wizardStep1.selectedIndex
|
|
|
|
onboardingModel.storeAccountAndLogin(selectedAccountIndex, txtPassword.textField.text)
|
2020-05-21 15:25:33 +00:00
|
|
|
}
|
2020-05-19 13:22:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-21 15:25:33 +00:00
|
|
|
|
2020-05-19 13:22:38 +00:00
|
|
|
/*##^##
|
|
|
|
Designer {
|
2020-05-27 17:26:21 +00:00
|
|
|
D{i:0;autoSize:true;formeditorColor:"#ffffff";height:480;width:640}
|
2020-05-19 13:22:38 +00:00
|
|
|
}
|
|
|
|
##^##*/
|
2020-05-27 17:26:21 +00:00
|
|
|
|