2020-08-03 13:27:42 -04:00
|
|
|
/*
|
2021-07-16 10:34:50 -04:00
|
|
|
* Copyright (C) 2021 by Savoir-faire Linux
|
2020-08-03 13:27:42 -04:00
|
|
|
* Author: Yang Wang <yang.wang@savoirfairelinux.com>
|
2021-07-16 10:34:50 -04:00
|
|
|
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
|
2020-08-03 13:27:42 -04:00
|
|
|
*
|
|
|
|
* 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
|
2020-10-06 13:58:44 +02:00
|
|
|
import QtQuick.Layouts 1.14
|
2020-08-03 13:27:42 -04:00
|
|
|
import QtQuick.Controls 2.14
|
2021-03-17 14:23:21 -04:00
|
|
|
|
2020-12-05 14:05:57 +01:00
|
|
|
import net.jami.Models 1.0
|
|
|
|
import net.jami.Constants 1.0
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
import "../../commoncomponents"
|
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
Rectangle {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property string errorText: ""
|
2020-09-17 16:09:06 -04:00
|
|
|
property int preferredHeight: importFromDevicePageColumnLayout.implicitHeight
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2021-07-16 10:34:50 -04:00
|
|
|
signal showThisPage
|
2020-09-04 14:57:36 -04:00
|
|
|
|
2020-08-03 13:27:42 -04:00
|
|
|
function initializeOnShowUp() {
|
|
|
|
clearAllTextFields()
|
|
|
|
}
|
|
|
|
|
|
|
|
function clearAllTextFields() {
|
2020-09-04 14:57:36 -04:00
|
|
|
connectBtn.spinnerTriggered = false
|
2020-08-03 13:27:42 -04:00
|
|
|
pinFromDevice.clear()
|
|
|
|
passwordFromDevice.clear()
|
|
|
|
}
|
|
|
|
|
2020-09-04 14:57:36 -04:00
|
|
|
function errorOccured(errorMessage) {
|
|
|
|
errorText = errorMessage
|
|
|
|
connectBtn.spinnerTriggered = false
|
|
|
|
}
|
|
|
|
|
2021-07-16 10:34:50 -04:00
|
|
|
Connections {
|
|
|
|
target: WizardViewStepModel
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2021-07-16 10:34:50 -04:00
|
|
|
function onMainStepChanged() {
|
|
|
|
if (WizardViewStepModel.mainStep === WizardViewStepModel.MainSteps.AccountCreation &&
|
|
|
|
WizardViewStepModel.accountCreationOption ===
|
2021-08-11 16:05:32 -04:00
|
|
|
WizardViewStepModel.AccountCreationOption.ImportFromDevice) {
|
|
|
|
clearAllTextFields()
|
2021-07-16 10:34:50 -04:00
|
|
|
root.showThisPage()
|
2021-08-11 16:05:32 -04:00
|
|
|
}
|
2021-07-16 10:34:50 -04:00
|
|
|
}
|
2020-09-04 14:57:36 -04:00
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2021-07-16 10:34:50 -04:00
|
|
|
color: JamiTheme.backgroundColor
|
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
ColumnLayout {
|
2020-09-17 16:09:06 -04:00
|
|
|
id: importFromDevicePageColumnLayout
|
|
|
|
|
2021-07-16 10:34:50 -04:00
|
|
|
spacing: JamiTheme.wizardViewPageLayoutSpacing
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-03 09:58:01 -04:00
|
|
|
// Prevent possible anchor loop detected on centerIn.
|
2020-08-04 20:54:02 -04:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
Text {
|
2020-09-03 09:58:01 -04:00
|
|
|
Layout.alignment: Qt.AlignCenter
|
2021-07-16 10:34:50 -04:00
|
|
|
Layout.topMargin: JamiTheme.wizardViewPageBackButtonMargins
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-11 17:30:46 -04:00
|
|
|
text: JamiStrings.mainAccountPassword
|
2020-11-28 16:14:25 -05:00
|
|
|
color: JamiTheme.textColor
|
2020-08-04 20:54:02 -04:00
|
|
|
font.pointSize: JamiTheme.menuFontSize
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
MaterialLineEdit {
|
|
|
|
id: passwordFromDevice
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2021-08-02 17:31:46 -04:00
|
|
|
objectName: "passwordFromDevice"
|
|
|
|
|
2020-09-03 09:58:01 -04:00
|
|
|
Layout.preferredHeight: fieldLayoutHeight
|
|
|
|
Layout.preferredWidth: connectBtn.width
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
selectByMouse: true
|
2021-07-16 10:34:50 -04:00
|
|
|
placeholderText: JamiStrings.password
|
|
|
|
font.pointSize: JamiTheme.textFontSize
|
2020-08-04 20:54:02 -04:00
|
|
|
font.kerning: true
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
echoMode: TextInput.Password
|
|
|
|
borderColorMode: MaterialLineEdit.NORMAL
|
2020-09-04 14:57:36 -04:00
|
|
|
|
2021-08-02 14:52:08 -04:00
|
|
|
KeyNavigation.tab: pinFromDevice
|
|
|
|
KeyNavigation.up: {
|
|
|
|
if (backButton.visible)
|
|
|
|
return backButton
|
|
|
|
return pinFromDevice
|
|
|
|
}
|
|
|
|
KeyNavigation.down: KeyNavigation.tab
|
|
|
|
|
2020-09-04 14:57:36 -04:00
|
|
|
onTextChanged: errorText = ""
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
Text {
|
2021-07-16 10:34:50 -04:00
|
|
|
property int preferredHeight: JamiTheme.wizardViewPageLayoutSpacing
|
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
|
2020-09-03 09:58:01 -04:00
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
Layout.preferredWidth: connectBtn.width
|
|
|
|
Layout.preferredHeight: preferredHeight
|
|
|
|
|
2020-09-11 17:30:46 -04:00
|
|
|
text: JamiStrings.enterPIN
|
2020-11-28 16:14:25 -05:00
|
|
|
color: JamiTheme.textColor
|
2020-08-04 20:54:02 -04:00
|
|
|
wrapMode: Text.Wrap
|
2020-09-03 09:58:01 -04:00
|
|
|
|
|
|
|
onTextChanged: {
|
|
|
|
var boundingRect = JamiQmlUtils.getTextBoundingRect(font, text)
|
|
|
|
preferredHeight += (boundingRect.width / connectBtn.preferredWidth)
|
|
|
|
* boundingRect.height
|
|
|
|
}
|
2020-08-04 20:54:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MaterialLineEdit {
|
|
|
|
id: pinFromDevice
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2021-08-02 17:31:46 -04:00
|
|
|
objectName: "pinFromDevice"
|
|
|
|
|
2020-09-03 09:58:01 -04:00
|
|
|
Layout.preferredHeight: fieldLayoutHeight
|
|
|
|
Layout.preferredWidth: connectBtn.width
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
|
2021-07-16 10:34:50 -04:00
|
|
|
focus: visible
|
|
|
|
|
2020-08-03 13:27:42 -04:00
|
|
|
selectByMouse: true
|
2021-07-16 10:34:50 -04:00
|
|
|
placeholderText: JamiStrings.pin
|
|
|
|
font.pointSize: JamiTheme.textFontSize
|
2020-08-04 20:54:02 -04:00
|
|
|
font.kerning: true
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
borderColorMode: MaterialLineEdit.NORMAL
|
2020-09-04 14:57:36 -04:00
|
|
|
|
2021-08-02 14:52:08 -04:00
|
|
|
KeyNavigation.tab: {
|
|
|
|
if (connectBtn.enabled)
|
|
|
|
return connectBtn
|
|
|
|
else if (connectBtn.spinnerTriggered)
|
|
|
|
return passwordFromDevice
|
|
|
|
return backButton
|
|
|
|
}
|
|
|
|
KeyNavigation.up: passwordFromDevice
|
|
|
|
KeyNavigation.down: KeyNavigation.tab
|
|
|
|
|
2020-09-04 14:57:36 -04:00
|
|
|
onTextChanged: errorText = ""
|
2020-08-04 20:54:02 -04:00
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-04 14:57:36 -04:00
|
|
|
SpinnerButton {
|
2020-08-04 20:54:02 -04:00
|
|
|
id: connectBtn
|
2020-09-03 09:58:01 -04:00
|
|
|
|
2021-08-02 17:31:46 -04:00
|
|
|
objectName: "importFromDevicePageConnectBtn"
|
|
|
|
|
2020-09-03 09:58:01 -04:00
|
|
|
Layout.alignment: Qt.AlignCenter
|
2021-07-16 10:34:50 -04:00
|
|
|
Layout.bottomMargin: errorLabel.visible ? 0 : JamiTheme.wizardViewPageBackButtonMargins
|
2020-09-03 09:58:01 -04:00
|
|
|
Layout.preferredWidth: preferredWidth
|
|
|
|
Layout.preferredHeight: preferredHeight
|
|
|
|
|
2021-07-16 10:34:50 -04:00
|
|
|
spinnerTriggeredtext: JamiStrings.generatingAccount
|
2020-09-11 17:30:46 -04:00
|
|
|
normalText: JamiStrings.connectFromAnotherDevice
|
2020-09-04 14:57:36 -04:00
|
|
|
|
|
|
|
enabled: pinFromDevice.text.length !== 0 && !spinnerTriggered
|
2020-08-04 20:54:02 -04:00
|
|
|
|
2021-08-02 14:52:08 -04:00
|
|
|
KeyNavigation.tab: backButton
|
|
|
|
KeyNavigation.up: pinFromDevice
|
|
|
|
KeyNavigation.down: KeyNavigation.tab
|
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
onClicked: {
|
2020-09-04 14:57:36 -04:00
|
|
|
spinnerTriggered = true
|
2021-07-16 10:34:50 -04:00
|
|
|
|
|
|
|
WizardViewStepModel.accountCreationInfo =
|
|
|
|
JamiQmlUtils.setUpAccountCreationInputPara(
|
|
|
|
{archivePin : pinFromDevice.text,
|
|
|
|
password : passwordFromDevice.text})
|
|
|
|
WizardViewStepModel.nextStep()
|
2020-08-04 20:54:02 -04:00
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
2020-09-17 16:09:06 -04:00
|
|
|
id: errorLabel
|
|
|
|
|
2020-09-03 09:58:01 -04:00
|
|
|
Layout.alignment: Qt.AlignCenter
|
2021-07-16 10:34:50 -04:00
|
|
|
Layout.bottomMargin: JamiTheme.wizardViewPageBackButtonMargins
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-03 09:58:01 -04:00
|
|
|
visible: errorText.length !== 0
|
|
|
|
|
|
|
|
text: errorText
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
font.pointSize: JamiTheme.textFontSize
|
2021-07-16 10:34:50 -04:00
|
|
|
color: JamiTheme.redColor
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
2020-09-04 14:57:36 -04:00
|
|
|
}
|
2020-08-04 20:54:02 -04:00
|
|
|
|
2021-07-16 10:34:50 -04:00
|
|
|
BackButton {
|
2020-09-04 14:57:36 -04:00
|
|
|
id: backButton
|
2020-08-04 20:54:02 -04:00
|
|
|
|
2021-07-29 16:55:02 -04:00
|
|
|
objectName: "importFromDevicePageBackButton"
|
|
|
|
|
2020-09-04 14:57:36 -04:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.margins: 20
|
2020-08-04 20:54:02 -04:00
|
|
|
|
2021-07-29 16:55:02 -04:00
|
|
|
visible: !connectBtn.spinnerTriggered
|
|
|
|
|
2021-08-02 14:52:08 -04:00
|
|
|
KeyNavigation.tab: passwordFromDevice
|
|
|
|
KeyNavigation.up: connectBtn
|
|
|
|
KeyNavigation.down: KeyNavigation.tab
|
|
|
|
|
2021-07-16 10:34:50 -04:00
|
|
|
preferredSize: JamiTheme.wizardViewPageBackButtonSize
|
2020-09-04 14:57:36 -04:00
|
|
|
|
2021-07-16 10:34:50 -04:00
|
|
|
onClicked: WizardViewStepModel.previousStep()
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
}
|