2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-05-27 07:15:42 +00:00
|
|
|
import QtQuick.Dialogs 1.3
|
2020-06-17 19:18:31 +00:00
|
|
|
import QtGraphicalEffects 1.13
|
2020-05-29 19:15:55 +00:00
|
|
|
import "../shared"
|
|
|
|
import "../imports"
|
2020-06-30 20:01:37 +00:00
|
|
|
import "../sounds"
|
2020-06-03 20:50:59 +00:00
|
|
|
import "./Login"
|
2020-05-27 07:15:42 +00:00
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
Item {
|
2020-06-12 20:47:44 +00:00
|
|
|
property var onGenKeyClicked: function () {}
|
|
|
|
property var onExistingKeyClicked: function () {}
|
2020-06-11 21:23:27 +00:00
|
|
|
property bool loading: false
|
2020-06-01 14:36:06 +00:00
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
id: loginView
|
2020-05-27 07:15:42 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
|
2020-06-29 19:49:34 +00:00
|
|
|
function setCurrentFlow(isLogin) {
|
|
|
|
loginModel.isCurrentFlow = isLogin;
|
|
|
|
onboardingModel.isCurrentFlow = !isLogin;
|
|
|
|
}
|
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
txtPassword.forceActiveFocus(Qt.MouseFocusReason)
|
2020-05-28 04:06:57 +00:00
|
|
|
}
|
2020-06-30 20:01:37 +00:00
|
|
|
|
|
|
|
ErrorSound {
|
|
|
|
id: errorSound
|
|
|
|
}
|
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
Item {
|
|
|
|
id: element
|
|
|
|
width: 360
|
|
|
|
height: 200
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2020-05-27 07:15:42 +00:00
|
|
|
|
2020-06-24 03:23:49 +00:00
|
|
|
Identicon {
|
2020-06-11 21:23:27 +00:00
|
|
|
id: userImage
|
|
|
|
width: 40
|
|
|
|
height: 40
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
source: loginModel.currentAccount.identicon
|
2020-06-04 13:00:17 +00:00
|
|
|
}
|
2020-05-27 07:15:42 +00:00
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-06-11 21:23:27 +00:00
|
|
|
id: usernameText
|
|
|
|
text: loginModel.currentAccount.username
|
|
|
|
font.weight: Font.Bold
|
|
|
|
font.pixelSize: 17
|
|
|
|
anchors.top: userImage.bottom
|
|
|
|
anchors.topMargin: 4
|
2020-05-27 07:15:42 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
|
|
|
|
2020-06-12 20:47:44 +00:00
|
|
|
ConfirmAddExistingKeyModal {
|
|
|
|
id: confirmAddExstingKeyModal
|
|
|
|
onOpenModalClick: function () {
|
2020-06-29 19:49:34 +00:00
|
|
|
setCurrentFlow(false);
|
2020-06-12 20:47:44 +00:00
|
|
|
onExistingKeyClicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
SelectAnotherAccountModal {
|
|
|
|
id: selectAnotherAccountModal
|
|
|
|
onAccountSelect: function (index) {
|
|
|
|
loginModel.setCurrentAccount(index)
|
|
|
|
}
|
2020-06-12 20:47:44 +00:00
|
|
|
onOpenModalClick: function () {
|
2020-06-29 19:49:34 +00:00
|
|
|
setCurrentFlow(true);
|
2020-07-01 15:26:19 +00:00
|
|
|
onExistingKeyClicked()()
|
2020-06-12 20:47:44 +00:00
|
|
|
}
|
2020-06-11 21:23:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
property bool isHovered: false
|
|
|
|
id: changeAccountBtn
|
|
|
|
width: 24
|
|
|
|
height: 24
|
|
|
|
anchors.left: usernameText.right
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
anchors.verticalCenter: usernameText.verticalCenter
|
|
|
|
|
2020-07-02 15:14:31 +00:00
|
|
|
color: isHovered ? Style.current.grey : Style.current.transparent
|
2020-06-11 21:23:27 +00:00
|
|
|
|
|
|
|
radius: 4
|
|
|
|
|
2020-06-25 13:23:17 +00:00
|
|
|
SVGImage {
|
2020-06-11 21:23:27 +00:00
|
|
|
id: caretImg
|
|
|
|
width: 10
|
|
|
|
height: 6
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
source: "../app/img/caret.svg"
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
}
|
|
|
|
ColorOverlay {
|
|
|
|
anchors.fill: caretImg
|
|
|
|
source: caretImg
|
2020-07-02 15:14:31 +00:00
|
|
|
color: Style.current.darkGrey
|
2020-06-03 06:38:26 +00:00
|
|
|
}
|
2020-06-11 21:23:27 +00:00
|
|
|
MouseArea {
|
|
|
|
hoverEnabled: true
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onEntered: {
|
|
|
|
changeAccountBtn.isHovered = true
|
|
|
|
}
|
|
|
|
onExited: {
|
|
|
|
changeAccountBtn.isHovered = false
|
|
|
|
}
|
|
|
|
onClicked: {
|
2020-06-12 20:47:44 +00:00
|
|
|
if (loginModel.rowCount() > 1) {
|
|
|
|
selectAnotherAccountModal.open()
|
|
|
|
} else {
|
2020-07-01 15:26:19 +00:00
|
|
|
confirmAddExstingKeyModal.open()
|
2020-06-12 20:47:44 +00:00
|
|
|
}
|
2020-06-03 06:38:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-06-11 21:23:27 +00:00
|
|
|
id: addressText
|
|
|
|
width: 90
|
2020-07-02 15:14:31 +00:00
|
|
|
color: Style.current.darkGrey
|
2020-06-11 21:23:27 +00:00
|
|
|
text: loginModel.currentAccount.address
|
2020-07-02 15:14:31 +00:00
|
|
|
font.family: Style.current.fontHexRegular.name
|
2020-06-11 21:23:27 +00:00
|
|
|
elide: Text.ElideMiddle
|
|
|
|
font.pixelSize: 15
|
|
|
|
anchors.top: usernameText.bottom
|
|
|
|
anchors.topMargin: 4
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
|
|
|
|
2020-05-29 19:54:06 +00:00
|
|
|
Input {
|
|
|
|
id: txtPassword
|
2020-06-11 21:23:27 +00:00
|
|
|
anchors.top: addressText.bottom
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.topMargin: Style.current.padding * 2
|
2020-06-02 08:41:24 +00:00
|
|
|
placeholderText: "Enter password"
|
2020-06-04 14:53:10 +00:00
|
|
|
textField.echoMode: TextInput.Password
|
2020-06-11 21:23:27 +00:00
|
|
|
textField.focus: true
|
2020-05-29 19:54:06 +00:00
|
|
|
Keys.onReturnPressed: {
|
|
|
|
submitBtn.clicked()
|
2020-05-27 07:15:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
Button {
|
|
|
|
id: submitBtn
|
2020-06-22 19:32:00 +00:00
|
|
|
visible: !loading && txtPassword.text.length > 0
|
2020-06-11 21:23:27 +00:00
|
|
|
width: 40
|
|
|
|
height: 40
|
|
|
|
anchors.left: txtPassword.right
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.leftMargin: Style.current.padding
|
2020-06-11 21:23:27 +00:00
|
|
|
anchors.verticalCenter: txtPassword.verticalCenter
|
|
|
|
onClicked: {
|
|
|
|
if (loading) {
|
|
|
|
return;
|
|
|
|
}
|
2020-06-29 19:49:34 +00:00
|
|
|
setCurrentFlow(true);
|
2020-06-11 21:23:27 +00:00
|
|
|
loading = true
|
|
|
|
loginModel.login(txtPassword.textField.text)
|
|
|
|
}
|
2020-06-25 13:23:17 +00:00
|
|
|
SVGImage {
|
2020-06-11 21:23:27 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2020-06-22 19:32:00 +00:00
|
|
|
source: "../app/img/arrowUp.svg"
|
2020-06-11 21:23:27 +00:00
|
|
|
width: 13.5
|
|
|
|
height: 17.5
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
rotation: 90
|
|
|
|
}
|
|
|
|
background: Rectangle {
|
2020-07-02 15:14:31 +00:00
|
|
|
color: Style.current.blue
|
2020-06-11 21:23:27 +00:00
|
|
|
radius: 50
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: {
|
|
|
|
submitBtn.onClicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-23 18:59:16 +00:00
|
|
|
SVGImage {
|
2020-06-22 19:32:00 +00:00
|
|
|
id: loadingImg
|
|
|
|
visible: loading
|
|
|
|
anchors.left: txtPassword.right
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.leftMargin: Style.current.padding
|
2020-06-22 19:32:00 +00:00
|
|
|
anchors.verticalCenter: txtPassword.verticalCenter
|
2020-06-25 19:31:30 +00:00
|
|
|
// TODO replace by a real loading image
|
2020-06-22 19:32:00 +00:00
|
|
|
source: "../app/img/settings.svg"
|
|
|
|
width: 30
|
|
|
|
height: 30
|
|
|
|
fillMode: Image.Stretch
|
|
|
|
RotationAnimator {
|
|
|
|
target: loadingImg;
|
|
|
|
from: 0;
|
|
|
|
to: 360;
|
|
|
|
duration: 1200
|
|
|
|
running: true
|
|
|
|
loops: Animation.Infinite
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-06-11 21:23:27 +00:00
|
|
|
loading = false
|
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-11 21:23:27 +00:00
|
|
|
if (error) {
|
2020-06-30 20:01:37 +00:00
|
|
|
errorSound.play()
|
2020-06-11 21:23:27 +00:00
|
|
|
loginError.open()
|
|
|
|
}
|
2020-05-27 07:15:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
MouseArea {
|
2020-06-12 20:47:44 +00:00
|
|
|
id: generateKeysLink
|
|
|
|
width: generateKeysLinkText.width
|
|
|
|
height: generateKeysLinkText.height
|
2020-06-11 21:23:27 +00:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.top: txtPassword.bottom
|
|
|
|
anchors.topMargin: 26
|
2020-05-27 07:15:42 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2020-06-12 20:47:44 +00:00
|
|
|
onClicked: {
|
2020-06-29 19:49:34 +00:00
|
|
|
setCurrentFlow(false);
|
2020-06-12 20:47:44 +00:00
|
|
|
onGenKeyClicked()
|
|
|
|
}
|
2020-06-11 21:23:27 +00:00
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-06-12 20:47:44 +00:00
|
|
|
id: generateKeysLinkText
|
2020-07-02 15:14:31 +00:00
|
|
|
color: Style.current.blue
|
2020-06-11 21:23:27 +00:00
|
|
|
text: qsTr("Generate new keys")
|
|
|
|
font.pixelSize: 13
|
2020-05-27 07:15:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
2020-06-11 21:23:27 +00:00
|
|
|
D{i:0;autoSize:true;formeditorColor:"#ffffff";formeditorZoom:0.75;height:480;width:640}
|
2020-05-27 07:15:42 +00:00
|
|
|
}
|
|
|
|
##^##*/
|