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
|
2021-10-12 18:26:02 +00:00
|
|
|
|
2022-05-06 06:46:41 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
2021-10-20 12:23:58 +00:00
|
|
|
import StatusQ.Controls 0.1 as StatusQControls
|
2022-05-06 06:46:41 +00:00
|
|
|
import StatusQ.Popups 0.1
|
2021-10-20 12:23:58 +00:00
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.popups 1.0
|
|
|
|
import shared.status 1.0
|
|
|
|
import shared.controls 1.0
|
2022-04-07 19:02:54 +00:00
|
|
|
import shared.controls.chat 1.0
|
2022-05-06 06:46:41 +00:00
|
|
|
import "../panels"
|
2021-10-12 18:26:02 +00:00
|
|
|
import "../popups"
|
|
|
|
import "../stores"
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2021-10-20 22:47:23 +00:00
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
import utils 1.0
|
2020-05-27 07:15:42 +00:00
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
Item {
|
|
|
|
property bool loading: false
|
2022-05-11 14:45:15 +00:00
|
|
|
signal addNewUserClicked()
|
2022-03-15 22:27:36 +00:00
|
|
|
signal addExistingKeyClicked()
|
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
|
|
|
|
|
2021-09-13 11:51:47 +00:00
|
|
|
function doLogin(password) {
|
|
|
|
if (loading || password.length === 0)
|
|
|
|
return
|
|
|
|
|
|
|
|
loading = true
|
2021-10-12 18:26:02 +00:00
|
|
|
LoginStore.login(password)
|
2021-09-13 11:51:47 +00:00
|
|
|
txtPassword.textField.clear()
|
|
|
|
}
|
|
|
|
|
|
|
|
function resetLogin() {
|
2021-10-17 10:44:21 +00:00
|
|
|
if(localAccountSettings.storeToKeychainValue === Constants.storeToKeychainValueStore)
|
2021-09-13 11:51:47 +00:00
|
|
|
{
|
|
|
|
connection.enabled = true
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
txtPassword.visible = true
|
|
|
|
txtPassword.forceActiveFocus(Qt.MouseFocusReason)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
Component.onCompleted: {
|
2021-09-13 11:51:47 +00:00
|
|
|
resetLogin()
|
|
|
|
}
|
|
|
|
|
2021-10-17 10:44:21 +00:00
|
|
|
Connections{
|
|
|
|
id: connection
|
|
|
|
target: LoginStore.loginModuleInst
|
2021-09-13 11:51:47 +00:00
|
|
|
|
2021-10-17 10:44:21 +00:00
|
|
|
onObtainingPasswordError: {
|
|
|
|
enabled = false
|
|
|
|
obtainingPasswordErrorNotification.confirmationText = errorDescription
|
|
|
|
obtainingPasswordErrorNotification.open()
|
|
|
|
}
|
2021-09-13 11:51:47 +00:00
|
|
|
|
2021-10-17 10:44:21 +00:00
|
|
|
onObtainingPasswordSuccess: {
|
|
|
|
enabled = false
|
|
|
|
doLogin(password)
|
|
|
|
}
|
|
|
|
}
|
2021-09-13 11:51:47 +00:00
|
|
|
|
|
|
|
ConfirmationDialog {
|
|
|
|
id: obtainingPasswordErrorNotification
|
|
|
|
height: 270
|
|
|
|
confirmButtonLabel: qsTr("Ok")
|
|
|
|
|
|
|
|
onConfirmButtonClicked: {
|
|
|
|
close()
|
|
|
|
}
|
|
|
|
|
|
|
|
onClosed: {
|
|
|
|
txtPassword.visible = true
|
|
|
|
}
|
2020-05-28 04:06:57 +00:00
|
|
|
}
|
2020-06-30 20:01:37 +00:00
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
Item {
|
|
|
|
id: element
|
|
|
|
width: 360
|
2022-05-06 06:46:41 +00:00
|
|
|
height: childrenRect.height
|
2020-06-11 21:23:27 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2020-05-27 07:15:42 +00:00
|
|
|
|
2022-05-06 06:46:41 +00:00
|
|
|
Image {
|
|
|
|
id: statusIcon
|
|
|
|
width: 140
|
|
|
|
height: 140
|
|
|
|
fillMode: Image.PreserveAspectFit
|
2022-06-20 12:28:36 +00:00
|
|
|
source: Style.png("status-logo")
|
2020-06-11 21:23:27 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2020-06-04 13:00:17 +00:00
|
|
|
}
|
2020-05-27 07:15:42 +00:00
|
|
|
|
2022-05-06 06:46:41 +00:00
|
|
|
StatusBaseText {
|
|
|
|
id: welcomeBackText
|
|
|
|
text: qsTr("Welcome back")
|
2020-06-11 21:23:27 +00:00
|
|
|
font.weight: Font.Bold
|
|
|
|
font.pixelSize: 17
|
2022-05-06 06:46:41 +00:00
|
|
|
anchors.top: statusIcon.bottom
|
|
|
|
anchors.topMargin: 10
|
2020-05-27 07:15:42 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2022-05-06 06:46:41 +00:00
|
|
|
color: Theme.palette.directColor1
|
2020-05-27 07:15:42 +00:00
|
|
|
}
|
|
|
|
|
2020-06-12 20:47:44 +00:00
|
|
|
ConfirmAddExistingKeyModal {
|
|
|
|
id: confirmAddExstingKeyModal
|
2022-03-15 22:27:36 +00:00
|
|
|
onOpenModalClicked: {
|
|
|
|
addExistingKeyClicked()
|
2020-06-12 20:47:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
SelectAnotherAccountModal {
|
|
|
|
id: selectAnotherAccountModal
|
2022-03-15 22:27:36 +00:00
|
|
|
onAccountSelected: {
|
2021-10-12 18:26:02 +00:00
|
|
|
LoginStore.setCurrentAccount(index)
|
2021-09-13 11:51:47 +00:00
|
|
|
resetLogin()
|
2020-06-11 21:23:27 +00:00
|
|
|
}
|
2022-03-15 22:27:36 +00:00
|
|
|
onOpenModalClicked: {
|
|
|
|
addExistingKeyClicked()
|
2020-06-12 20:47:44 +00:00
|
|
|
}
|
2020-06-11 21:23:27 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 06:46:41 +00:00
|
|
|
Item {
|
|
|
|
id: userInfo
|
|
|
|
height: userImage.height
|
|
|
|
anchors.top: welcomeBackText.bottom
|
|
|
|
anchors.topMargin: 64
|
|
|
|
width: 318
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
UserImage {
|
|
|
|
id: userImage
|
|
|
|
image: LoginStore.currentAccount.thumbnailImage
|
|
|
|
name: LoginStore.currentAccount.username
|
|
|
|
colorId: LoginStore.currentAccount.colorId
|
|
|
|
colorHash: LoginStore.currentAccount.colorHash
|
|
|
|
anchors.left: parent.left
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: usernameText
|
|
|
|
text: LoginStore.currentAccount.username
|
|
|
|
font.pixelSize: 17
|
|
|
|
anchors.left: userImage.right
|
|
|
|
anchors.leftMargin: 16
|
|
|
|
anchors.verticalCenter: userImage.verticalCenter
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusQControls.StatusFlatRoundButton {
|
|
|
|
icon.name: "chevron-down"
|
|
|
|
type: StatusQControls.StatusFlatRoundButton.Type.Tertiary
|
|
|
|
width: 24
|
|
|
|
height: 24
|
|
|
|
id: changeAccountBtn
|
|
|
|
anchors.verticalCenter: usernameText.verticalCenter
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
if (accountsPopup.opened) {
|
|
|
|
accountsPopup.close()
|
|
|
|
} else {
|
|
|
|
accountsPopup.popup(width-userInfo.width-16, userInfo.height+4)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusPopupMenu {
|
|
|
|
id: accountsPopup
|
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
|
|
|
|
width: 346
|
|
|
|
dim: false
|
|
|
|
Repeater {
|
|
|
|
id: accounts
|
|
|
|
model: LoginStore.loginModuleInst.accountsModel
|
|
|
|
delegate: AccountMenuItemPanel {
|
|
|
|
label: model.username
|
|
|
|
image: model.thumbnailImage
|
|
|
|
colorId: model.colorId
|
|
|
|
colorHash: model.colorHash
|
|
|
|
onClicked: {
|
|
|
|
LoginStore.setCurrentAccount(index)
|
|
|
|
resetLogin()
|
|
|
|
accountsPopup.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AccountMenuItemPanel {
|
2022-05-11 14:45:15 +00:00
|
|
|
label: qsTr("Add new user")
|
2022-05-06 06:46:41 +00:00
|
|
|
onClicked: {
|
|
|
|
accountsPopup.close()
|
2022-05-11 14:45:15 +00:00
|
|
|
addNewUserClicked();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AccountMenuItemPanel {
|
|
|
|
label: qsTr("Add existing Status user")
|
|
|
|
iconSettings.name: "wallet"
|
|
|
|
onClicked: {
|
|
|
|
accountsPopup.close()
|
|
|
|
addExistingKeyClicked();
|
2020-06-12 20:47:44 +00:00
|
|
|
}
|
2022-05-06 06:46:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-03 06:38:26 +00:00
|
|
|
}
|
|
|
|
|
2020-05-29 19:54:06 +00:00
|
|
|
Input {
|
|
|
|
id: txtPassword
|
2022-05-06 06:46:41 +00:00
|
|
|
anchors.top: userInfo.bottom
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.topMargin: Style.current.padding * 2
|
2022-05-06 06:46:41 +00:00
|
|
|
anchors.left: undefined
|
|
|
|
anchors.right: undefined
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
width: 318
|
2021-07-21 05:50:35 +00:00
|
|
|
enabled: !loading
|
2021-10-14 08:04:15 +00:00
|
|
|
placeholderText: loading ?
|
2022-04-04 11:26:30 +00:00
|
|
|
qsTr("Connecting...") :
|
2022-07-07 14:12:43 +00:00
|
|
|
qsTr("Password")
|
2020-06-04 14:53:10 +00:00
|
|
|
textField.echoMode: TextInput.Password
|
2020-05-29 19:54:06 +00:00
|
|
|
Keys.onReturnPressed: {
|
2021-09-13 11:51:47 +00:00
|
|
|
doLogin(textField.text)
|
2020-05-27 07:15:42 +00:00
|
|
|
}
|
2021-01-26 18:37:58 +00:00
|
|
|
onTextEdited: {
|
|
|
|
errMsg.visible = false
|
|
|
|
loading = false
|
|
|
|
}
|
2020-05-27 07:15:42 +00:00
|
|
|
}
|
2021-07-21 05:50:35 +00:00
|
|
|
|
2021-10-25 19:37:44 +00:00
|
|
|
StatusQControls.StatusRoundButton {
|
2020-09-29 18:32:36 +00:00
|
|
|
id: submitBtn
|
2021-10-25 19:37:44 +00:00
|
|
|
width: 40
|
|
|
|
height: 40
|
|
|
|
type: StatusQControls.StatusRoundButton.Type.Secondary
|
2020-09-29 06:39:29 +00:00
|
|
|
icon.name: "arrow-right"
|
2021-07-21 05:50:35 +00:00
|
|
|
opacity: (loading || txtPassword.text.length > 0) ? 1 : 0
|
2022-05-06 06:46:41 +00:00
|
|
|
anchors.left: txtPassword.right
|
2021-07-21 05:50:35 +00:00
|
|
|
anchors.leftMargin: (loading || txtPassword.text.length > 0) ? Style.current.padding : Style.current.smallPadding
|
2022-05-06 06:46:41 +00:00
|
|
|
anchors.verticalCenter: txtPassword.verticalCenter
|
2020-09-29 06:39:29 +00:00
|
|
|
state: loading ? "pending" : "default"
|
2020-06-11 21:23:27 +00:00
|
|
|
onClicked: {
|
2021-09-13 11:51:47 +00:00
|
|
|
doLogin(txtPassword.textField.text)
|
2021-07-21 05:50:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// https://www.figma.com/file/BTS422M9AkvWjfRrXED3WC/%F0%9F%91%8B-Onboarding%E2%8E%9CDesktop?node-id=6%3A0
|
|
|
|
Behavior on opacity {
|
|
|
|
OpacityAnimator {
|
|
|
|
from: 0.5
|
|
|
|
duration: 200
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Behavior on anchors.leftMargin {
|
|
|
|
NumberAnimation {
|
|
|
|
duration: 200
|
|
|
|
}
|
2020-06-11 21:23:27 +00:00
|
|
|
}
|
2020-06-22 19:32:00 +00:00
|
|
|
}
|
|
|
|
|
2021-10-15 19:47:43 +00:00
|
|
|
Connections {
|
2021-10-17 10:44:21 +00:00
|
|
|
target: LoginStore.loginModuleInst
|
2021-10-15 19:47:43 +00:00
|
|
|
onAccountLoginError: {
|
|
|
|
if (error) {
|
|
|
|
// SQLITE_NOTADB: "file is not a database"
|
|
|
|
if (error === "file is not a database") {
|
|
|
|
errMsg.text = errMsg.incorrectPasswordMsg
|
|
|
|
} else {
|
2022-04-04 11:26:30 +00:00
|
|
|
errMsg.text = qsTr("Login failed: %1").arg(error.toUpperCase())
|
2021-10-15 19:47:43 +00:00
|
|
|
}
|
|
|
|
errMsg.visible = true
|
|
|
|
loading = false
|
|
|
|
txtPassword.textField.forceActiveFocus()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-27 07:15:42 +00:00
|
|
|
|
2021-01-26 18:37:58 +00:00
|
|
|
StyledText {
|
|
|
|
id: errMsg
|
2022-07-15 08:41:23 +00:00
|
|
|
readonly property string incorrectPasswordMsg: qsTr("Password incorrect")
|
2022-05-06 06:46:41 +00:00
|
|
|
anchors.top: txtPassword.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
2021-01-26 18:37:58 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
visible: false
|
2021-07-21 05:50:35 +00:00
|
|
|
text: incorrectPasswordMsg
|
2021-01-26 18:37:58 +00:00
|
|
|
font.pixelSize: 13
|
|
|
|
color: Style.current.danger
|
|
|
|
}
|
2020-05-27 07:15:42 +00:00
|
|
|
}
|
|
|
|
}
|