2020-05-27 07:15:42 +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-05-29 19:15:55 +00:00
|
|
|
import "../shared"
|
|
|
|
import "../imports"
|
2020-06-03 20:50:59 +00:00
|
|
|
import "./Login"
|
2020-05-27 07:15:42 +00:00
|
|
|
|
|
|
|
SwipeView {
|
2020-06-03 20:50:59 +00:00
|
|
|
property alias btnGenKey: accountSelection.btnGenKey
|
2020-06-01 14:36:06 +00:00
|
|
|
|
2020-05-27 07:15:42 +00:00
|
|
|
id: swipeView
|
|
|
|
anchors.fill: parent
|
|
|
|
currentIndex: 0
|
2020-06-02 08:41:24 +00:00
|
|
|
interactive: false
|
2020-05-27 07:15:42 +00:00
|
|
|
|
2020-05-28 04:06:57 +00:00
|
|
|
onCurrentItemChanged: {
|
2020-06-02 08:41:24 +00:00
|
|
|
if(currentItem.txtPassword) {
|
|
|
|
currentItem.txtPassword.textField.focus = true
|
|
|
|
}
|
2020-05-28 04:06:57 +00:00
|
|
|
}
|
2020-05-27 07:15:42 +00:00
|
|
|
|
2020-06-03 20:50:59 +00:00
|
|
|
AccountSelection {
|
|
|
|
id: accountSelection
|
2020-06-04 13:00:17 +00:00
|
|
|
onAccountSelect: function() {
|
|
|
|
loginModel.setCurrentAccount(this.selectedIndex)
|
|
|
|
swipeView.incrementCurrentIndex()
|
|
|
|
}
|
2020-05-27 07:15:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
2020-05-29 19:15:55 +00:00
|
|
|
id: wizardStep2
|
2020-05-27 07:15:42 +00:00
|
|
|
property Item txtPassword: txtPassword
|
|
|
|
|
|
|
|
Text {
|
2020-06-03 06:38:26 +00:00
|
|
|
id: step2Title
|
2020-05-27 07:15:42 +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: loginModel.currentAccount.identicon
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Column {
|
|
|
|
Text {
|
|
|
|
text: loginModel.currentAccount.username
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-29 19:54:06 +00:00
|
|
|
Input {
|
|
|
|
id: txtPassword
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.rightMargin: Theme.padding
|
|
|
|
anchors.leftMargin: Theme.padding
|
2020-05-27 07:15:42 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2020-06-02 08:41:24 +00:00
|
|
|
placeholderText: "Enter password"
|
2020-06-04 14:53:10 +00:00
|
|
|
textField.echoMode: TextInput.Password
|
2020-05-29 19:54:06 +00:00
|
|
|
Keys.onReturnPressed: {
|
|
|
|
submitBtn.clicked()
|
2020-05-27 07:15:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageDialog {
|
|
|
|
id: loginError
|
|
|
|
title: "Login failed"
|
|
|
|
text: "Login failed. Please re-enter your password and try again."
|
|
|
|
icon: StandardIcon.Critical
|
|
|
|
standardButtons: StandardButton.Ok
|
|
|
|
onAccepted: {
|
2020-05-29 19:54:06 +00:00
|
|
|
txtPassword.textField.clear()
|
|
|
|
txtPassword.textField.focus = true
|
2020-05-27 07:15:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: loginModel
|
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){
|
|
|
|
loginError.open()
|
|
|
|
}
|
2020-05-27 07:15:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-29 19:15:55 +00:00
|
|
|
StyledButton {
|
|
|
|
id: submitBtn
|
|
|
|
label: "Finish"
|
2020-05-27 07:15:42 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: 20
|
|
|
|
onClicked: {
|
2020-06-03 20:50:59 +00:00
|
|
|
const selectedAccountIndex = accountSelection.selectedIndex
|
2020-05-29 19:54:06 +00:00
|
|
|
const response = loginModel.login(selectedAccountIndex, txtPassword.textField.text)
|
2020-05-29 19:15:55 +00:00
|
|
|
// TODO: replace me with something graphical (ie spinner)
|
|
|
|
console.log("Logging in...")
|
2020-05-27 07:15:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;autoSize:true;height:480;width:640}
|
|
|
|
}
|
|
|
|
##^##*/
|
2020-05-29 19:15:55 +00:00
|
|
|
|