2020-08-03 13:27:42 -04:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2020 by Savoir-faire Linux
|
|
|
|
|
* Author: Yang Wang <yang.wang@savoirfairelinux.com>
|
|
|
|
|
*
|
|
|
|
|
* 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 <https://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.14
|
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
|
import QtQuick.Controls 2.14
|
2020-08-04 20:54:02 -04:00
|
|
|
import Qt.labs.platform 1.1
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
|
import "../"
|
|
|
|
|
import "../../constant"
|
|
|
|
|
import "../../commoncomponents"
|
2020-08-04 20:54:02 -04:00
|
|
|
import "../../settingsview/components"
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
Rectangle {
|
|
|
|
|
id: root
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
property alias text_usernameEditAlias: usernameEdit.text
|
2020-08-03 13:27:42 -04:00
|
|
|
property int nameRegistrationUIState: WizardView.BLANK
|
2020-08-04 20:54:02 -04:00
|
|
|
property alias text_passwordEditAlias: passwordEdit.text
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
signal createAccount
|
|
|
|
|
signal leavePage
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
|
function initializeOnShowUp() {
|
2020-08-04 20:54:02 -04:00
|
|
|
createAccountStack.currentIndex = 0
|
2020-08-03 13:27:42 -04:00
|
|
|
clearAllTextFields()
|
2020-08-04 20:54:02 -04:00
|
|
|
passwordSwitch.checked = false
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function clearAllTextFields() {
|
|
|
|
|
usernameEdit.clear()
|
2020-08-04 20:54:02 -04:00
|
|
|
passwordEdit.clear()
|
|
|
|
|
passwordConfirmEdit.clear()
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
anchors.fill: parent
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
color: JamiTheme.backgroundColor
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
/*
|
|
|
|
|
* JamiFileDialog for exporting account
|
|
|
|
|
*/
|
|
|
|
|
JamiFileDialog {
|
|
|
|
|
id: exportBtn_Dialog
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
mode: JamiFileDialog.SaveFile
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
title: qsTr("Export Account Here")
|
|
|
|
|
folder: StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/Desktop"
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
nameFilters: [qsTr("Jami archive files") + " (*.gz)", qsTr(
|
|
|
|
|
"All files") + " (*)"]
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
onAccepted: {
|
|
|
|
|
export_Btn_FileDialogAccepted(true, file)
|
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
onRejected: {
|
|
|
|
|
export_Btn_FileDialogAccepted(false, folder)
|
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
onVisibleChanged: {
|
|
|
|
|
if (!visible) {
|
|
|
|
|
rejected()
|
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
2020-08-04 20:54:02 -04:00
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
StackLayout {
|
|
|
|
|
id: createAccountStack
|
|
|
|
|
anchors.verticalCenter: root.verticalCenter
|
|
|
|
|
anchors.horizontalCenter: root.horizontalCenter
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
ColumnLayout {
|
|
|
|
|
spacing: 12
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
Layout.preferredWidth: root.width
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
RowLayout {
|
|
|
|
|
spacing: 12
|
|
|
|
|
height: 48
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2020-08-04 20:54:02 -04:00
|
|
|
anchors.left: usernameEdit.left
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
Label {
|
|
|
|
|
text: qsTr("Choose a username for your account")
|
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
Label {
|
|
|
|
|
text: qsTr("Recommended")
|
|
|
|
|
color: "white"
|
|
|
|
|
padding: 8
|
|
|
|
|
anchors.right: parent.right
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
background: Rectangle {
|
|
|
|
|
color: "#aed581"
|
|
|
|
|
radius: 24
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MaterialLineEdit {
|
|
|
|
|
id: usernameEdit
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
|
selectByMouse: true
|
2020-08-04 20:54:02 -04:00
|
|
|
placeholderText: qsTr("Choose your username")
|
2020-08-03 13:27:42 -04:00
|
|
|
font.pointSize: 10
|
|
|
|
|
font.kerning: true
|
|
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
borderColorMode: nameRegistrationUIState === WizardView.BLANK ? MaterialLineEdit.NORMAL
|
|
|
|
|
: nameRegistrationUIState >= WizardView.FREE ? MaterialLineEdit.NORMAL : MaterialLineEdit.ERROR
|
|
|
|
|
|
|
|
|
|
fieldLayoutWidth: chooseUsernameButton.width
|
|
|
|
|
Layout.topMargin: 32
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
Label {
|
|
|
|
|
text: {
|
|
|
|
|
switch(nameRegistrationUIState){
|
|
|
|
|
case WizardView.BLANK:
|
|
|
|
|
case WizardView.SEARCHING:
|
|
|
|
|
case WizardView.FREE:
|
|
|
|
|
return ""
|
|
|
|
|
case WizardView.INVALID:
|
|
|
|
|
return qsTr("Invalid username")
|
|
|
|
|
case WizardView.TAKEN:
|
|
|
|
|
return qsTr("Username already taken")
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
anchors.left: usernameEdit.left
|
|
|
|
|
anchors.right: usernameEdit.right
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
font.pointSize: JamiTheme.textFontSize
|
|
|
|
|
color: "red"
|
|
|
|
|
|
|
|
|
|
height: 32
|
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
MaterialButton {
|
|
|
|
|
id: chooseUsernameButton
|
|
|
|
|
text: qsTr("CHOOSE USERNAME")
|
|
|
|
|
color: nameRegistrationUIState === WizardView.FREE?
|
|
|
|
|
JamiTheme.buttonTintedGrey
|
|
|
|
|
: JamiTheme.buttonTintedGreyInactive
|
2020-08-25 21:12:14 -04:00
|
|
|
hoveredColor: JamiTheme.buttonTintedGreyHovered
|
|
|
|
|
pressedColor: JamiTheme.buttonTintedGreyPressed
|
2020-08-04 20:54:02 -04:00
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
|
if (nameRegistrationUIState === WizardView.FREE)
|
|
|
|
|
createAccountStack.currentIndex = createAccountStack.currentIndex + 1
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
MaterialButton {
|
|
|
|
|
text: qsTr("SKIP CHOOSING USERNAME")
|
|
|
|
|
color: JamiTheme.buttonTintedGrey
|
2020-08-25 21:12:14 -04:00
|
|
|
hoveredColor: JamiTheme.buttonTintedGreyHovered
|
|
|
|
|
pressedColor: JamiTheme.buttonTintedGreyPressed
|
2020-08-04 20:54:02 -04:00
|
|
|
outlined: true
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
onClicked: {
|
|
|
|
|
createAccountStack.currentIndex = createAccountStack.currentIndex + 1
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ColumnLayout {
|
2020-08-04 20:54:02 -04:00
|
|
|
spacing: 12
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
Layout.preferredWidth: root.width
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
RowLayout {
|
|
|
|
|
spacing: 12
|
|
|
|
|
height: 48
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
anchors.right: createAccountButton.right
|
|
|
|
|
anchors.left: createAccountButton.left
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
Label {
|
|
|
|
|
text: qsTr("Encrypt account with password")
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
font.pointSize: JamiTheme.textFontSize + 3
|
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
Label {
|
|
|
|
|
text: qsTr("Optional")
|
|
|
|
|
color: "white"
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
padding: 8
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
background: Rectangle {
|
|
|
|
|
color: "#28b1ed"
|
|
|
|
|
radius: 24
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
RowLayout {
|
|
|
|
|
spacing: 12
|
|
|
|
|
height: 48
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
anchors.right: createAccountButton.right
|
|
|
|
|
anchors.left: createAccountButton.left
|
|
|
|
|
|
|
|
|
|
Label {
|
|
|
|
|
text: qsTr("Choose a password to encrypt the account key on this device")
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
font.pointSize: JamiTheme.textFontSize
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
Switch {
|
|
|
|
|
id: passwordSwitch
|
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
MaterialLineEdit {
|
|
|
|
|
id: passwordEdit
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
visible: passwordSwitch.checked
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
fieldLayoutWidth: createAccountButton.width
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
|
|
|
|
|
selectByMouse: true
|
2020-08-04 20:54:02 -04:00
|
|
|
echoMode: TextInput.Password
|
|
|
|
|
placeholderText: qsTr("Password")
|
2020-08-03 13:27:42 -04:00
|
|
|
font.pointSize: 10
|
|
|
|
|
font.kerning: true
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
MaterialLineEdit {
|
|
|
|
|
id: passwordConfirmEdit
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
visible: passwordSwitch.checked
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
fieldLayoutWidth: createAccountButton.width
|
|
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
|
|
|
|
|
selectByMouse: true
|
|
|
|
|
echoMode: TextInput.Password
|
|
|
|
|
placeholderText: qsTr("Confirm password")
|
|
|
|
|
font.pointSize: 10
|
|
|
|
|
font.kerning: true
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
Label {
|
|
|
|
|
anchors.right: createAccountButton.right
|
|
|
|
|
anchors.left: createAccountButton.left
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
text: qsTr("Note that the password cannot be recovered")
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
font.pointSize: JamiTheme.textFontSize
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MaterialButton {
|
|
|
|
|
id: createAccountButton
|
|
|
|
|
text: qsTr("CREATE ACCOUNT")
|
|
|
|
|
color: !passwordSwitch.checked ||
|
|
|
|
|
(passwordEdit.text === passwordConfirmEdit.text && passwordEdit.text.length !== 0)?
|
|
|
|
|
JamiTheme.wizardBlueButtons : JamiTheme.buttonTintedGreyInactive
|
2020-08-25 21:12:14 -04:00
|
|
|
hoveredColor: JamiTheme.buttonTintedBlueHovered
|
|
|
|
|
pressedColor: JamiTheme.buttonTintedBluePressed
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
onClicked: {
|
|
|
|
|
createAccount()
|
|
|
|
|
createAccountStack.currentIndex = createAccountStack.currentIndex + 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
RowLayout {
|
|
|
|
|
spacing: 12
|
|
|
|
|
height: 48
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
anchors.top: createAccountStack.bottom
|
|
|
|
|
anchors.horizontalCenter: root.horizontalCenter
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
Rectangle {
|
|
|
|
|
color: usernameEdit.visible? JamiTheme.wizardBlueButtons : "grey"
|
|
|
|
|
radius: height / 2
|
|
|
|
|
height: 12
|
|
|
|
|
width: 12
|
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
Rectangle {
|
|
|
|
|
color: createAccountButton.visible? JamiTheme.wizardBlueButtons : "grey"
|
|
|
|
|
radius: height / 2
|
|
|
|
|
height: 12
|
|
|
|
|
width: 12
|
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
Rectangle {
|
|
|
|
|
color: "grey"
|
|
|
|
|
radius: height / 2
|
|
|
|
|
height: 12
|
|
|
|
|
width: 12
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
HoverableButton {
|
|
|
|
|
id: cancelButton
|
|
|
|
|
z: 2
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.top: parent.top
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
rightPadding: 90
|
|
|
|
|
topPadding: 90
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
Layout.preferredWidth: 96
|
|
|
|
|
Layout.preferredHeight: 96
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
backgroundColor: "transparent"
|
|
|
|
|
onEnterColor: "transparent"
|
|
|
|
|
onPressColor: "transparent"
|
|
|
|
|
onReleaseColor: "transparent"
|
|
|
|
|
onExitColor: "transparent"
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
buttonImageHeight: 48
|
|
|
|
|
buttonImageWidth: 48
|
|
|
|
|
source: "qrc:/images/icons/ic_close_white_24dp.png"
|
|
|
|
|
radius: 48
|
|
|
|
|
baseColor: "#7c7c7c"
|
|
|
|
|
toolTipText: qsTr("Return to welcome page")
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
Shortcut {
|
|
|
|
|
sequence: StandardKey.Cancel
|
|
|
|
|
enabled: parent.visible
|
|
|
|
|
onActivated: leavePage()
|
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
onClicked: {
|
|
|
|
|
leavePage()
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|