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
|
|
|
|
|
|
|
|
import "../../constant"
|
|
|
|
import "../../commoncomponents"
|
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
Rectangle {
|
|
|
|
id: root
|
|
|
|
|
2020-08-03 13:27:42 -04:00
|
|
|
property alias text_pinFromDeviceAlias: pinFromDevice.text
|
|
|
|
property alias text_passwordFromDeviceAlias: passwordFromDevice.text
|
2020-08-04 20:54:02 -04:00
|
|
|
property string errorText: ""
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-04 14:57:36 -04:00
|
|
|
signal leavePage
|
|
|
|
signal importAccount
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
color: JamiTheme.backgroundColor
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-04 14:57:36 -04:00
|
|
|
onVisibleChanged: {
|
|
|
|
if (visible)
|
|
|
|
pinFromDevice.focus = true
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
ColumnLayout {
|
2020-09-03 09:58:01 -04:00
|
|
|
spacing: layoutSpacing
|
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
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-04 20:54:02 -04:00
|
|
|
text: qsTr("Enter your main Jami account password")
|
|
|
|
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
|
|
|
|
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
|
|
|
|
placeholderText: qsTr("Password")
|
2020-09-03 09:58:01 -04:00
|
|
|
font.pointSize: 9
|
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
|
|
|
|
|
|
|
onTextChanged: errorText = ""
|
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
|
|
|
property int preferredHeight: layoutSpacing
|
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
|
|
|
|
|
|
|
|
text: qsTr("Enter the PIN from another configured Jami account. " +
|
2020-09-04 14:57:36 -04:00
|
|
|
"Use the \"Link Another Device\" feature to obtain a PIN")
|
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
|
|
|
|
2020-09-03 09:58:01 -04:00
|
|
|
Layout.preferredHeight: fieldLayoutHeight
|
|
|
|
Layout.preferredWidth: connectBtn.width
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
|
2020-08-03 13:27:42 -04:00
|
|
|
selectByMouse: true
|
|
|
|
placeholderText: qsTr("PIN")
|
2020-09-03 09:58:01 -04:00
|
|
|
font.pointSize: 9
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
Layout.preferredWidth: preferredWidth
|
|
|
|
Layout.preferredHeight: preferredHeight
|
|
|
|
|
2020-09-04 14:57:36 -04:00
|
|
|
spinnerTriggeredtext: qsTr("Generating account…")
|
|
|
|
normalText: qsTr("CONNECT FROM ANOTHER DEVICE")
|
|
|
|
|
|
|
|
enabled: pinFromDevice.text.length !== 0 && !spinnerTriggered
|
2020-08-04 20:54:02 -04:00
|
|
|
|
|
|
|
onClicked: {
|
2020-09-04 14:57:36 -04:00
|
|
|
spinnerTriggered = true
|
2020-08-04 20:54:02 -04:00
|
|
|
importAccount()
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
2020-09-03 09:58:01 -04:00
|
|
|
Layout.alignment: Qt.AlignCenter
|
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
|
|
|
|
color: "red"
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
2020-09-04 14:57:36 -04:00
|
|
|
}
|
2020-08-04 20:54:02 -04:00
|
|
|
|
2020-09-04 14:57:36 -04:00
|
|
|
HoverableButton {
|
|
|
|
id: backButton
|
2020-08-04 20:54:02 -04:00
|
|
|
|
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
|
|
|
|
2020-09-04 14:57:36 -04:00
|
|
|
width: 35
|
|
|
|
height: 35
|
2020-08-04 20:54:02 -04:00
|
|
|
|
2020-09-04 14:57:36 -04:00
|
|
|
radius: 30
|
|
|
|
|
|
|
|
backgroundColor: root.color
|
|
|
|
onExitColor: root.color
|
|
|
|
|
|
|
|
source: "qrc:/images/icons/ic_arrow_back_24px.svg"
|
|
|
|
toolTipText: qsTr("Back to welcome page")
|
|
|
|
|
|
|
|
onClicked: leavePage()
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
}
|