2017-04-27 18:30:36 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-12-03 22:06:52 +00:00
|
|
|
import QtQuick 2.3
|
2017-03-31 14:15:14 +00:00
|
|
|
import QtQuick.Controls 2.0
|
2015-12-03 22:06:52 +00:00
|
|
|
import QtQuick.Window 2.2
|
|
|
|
import QtQuick.Dialogs 1.2
|
|
|
|
import QtQuick.Layouts 1.1
|
2017-03-31 14:15:14 +00:00
|
|
|
import org.kde.kirigami 2.0 as Kirigami
|
2015-12-03 22:06:52 +00:00
|
|
|
import org.subsurfacedivelog.mobile 1.0
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: loginWindow
|
2017-07-20 17:39:55 +00:00
|
|
|
height: outerLayout.height
|
2015-12-03 22:06:52 +00:00
|
|
|
|
|
|
|
property string username: login.text;
|
|
|
|
property string password: password.text;
|
|
|
|
|
2017-07-20 07:55:58 +00:00
|
|
|
property real gridWidth: loginWindow.width - Kirigami.Units.gridUnit
|
|
|
|
property real col1Width: gridWidth * 0.80
|
|
|
|
property real col2Width: gridWidth * 0.20
|
|
|
|
|
2016-02-14 05:09:33 +00:00
|
|
|
function saveCredentials() {
|
|
|
|
manager.cloudUserName = login.text
|
|
|
|
manager.cloudPassword = password.text
|
2016-06-13 23:42:36 +00:00
|
|
|
manager.cloudPin = pin.text
|
2016-02-14 05:09:33 +00:00
|
|
|
manager.saveCloudCredentials()
|
|
|
|
}
|
|
|
|
|
2015-12-03 22:06:52 +00:00
|
|
|
ColumnLayout {
|
2016-02-11 15:01:24 +00:00
|
|
|
id: outerLayout
|
2016-04-07 19:12:01 +00:00
|
|
|
width: loginWindow.width - loginWindow.leftPadding - loginWindow.rightPadding - 2 * Kirigami.Units.gridUnit
|
2016-03-27 04:27:48 +00:00
|
|
|
|
2016-04-21 21:00:37 +00:00
|
|
|
function goToNext() {
|
|
|
|
for (var i = 0; i < children.length; ++i)
|
|
|
|
if (children[i].focus) {
|
|
|
|
children[i].nextItemInFocusChain().forceActiveFocus()
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Keys.onReturnPressed: goToNext()
|
|
|
|
Keys.onTabPressed: goToNext()
|
|
|
|
|
2016-03-27 04:27:48 +00:00
|
|
|
onVisibleChanged: {
|
2016-04-04 00:00:49 +00:00
|
|
|
if (visible && manager.accessingCloud < 0) {
|
2016-03-27 04:35:35 +00:00
|
|
|
manager.appendTextToLog("Credential scrn: show kbd was: " + (Qt.inputMethod.isVisible ? "visible" : "invisible"))
|
2016-03-27 04:27:48 +00:00
|
|
|
Qt.inputMethod.show()
|
|
|
|
login.forceActiveFocus()
|
|
|
|
} else {
|
2016-03-27 04:35:35 +00:00
|
|
|
manager.appendTextToLog("Credential scrn: hide kbd was: " + (Qt.inputMethod.isVisible ? "visible" : "invisible"))
|
2016-03-27 04:27:48 +00:00
|
|
|
Qt.inputMethod.hide()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Heading {
|
2016-05-03 19:24:00 +00:00
|
|
|
text: qsTr("Cloud credentials")
|
2016-02-10 12:53:55 +00:00
|
|
|
level: headingLevel
|
2016-03-08 20:26:54 +00:00
|
|
|
Layout.bottomMargin: Kirigami.Units.largeSpacing / 2
|
2015-12-03 22:06:52 +00:00
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Label {
|
2016-05-03 19:24:00 +00:00
|
|
|
text: qsTr("Email")
|
2015-12-03 22:06:52 +00:00
|
|
|
}
|
|
|
|
|
2017-03-31 14:15:14 +00:00
|
|
|
TextField {
|
2015-12-03 22:06:52 +00:00
|
|
|
id: login
|
|
|
|
text: manager.cloudUserName
|
|
|
|
Layout.fillWidth: true
|
2015-12-27 20:19:51 +00:00
|
|
|
inputMethodHints: Qt.ImhEmailCharactersOnly |
|
|
|
|
Qt.ImhNoAutoUppercase
|
2017-07-22 20:15:28 +00:00
|
|
|
onEditingFinished: {
|
|
|
|
saveCredentials()
|
|
|
|
}
|
2015-12-03 22:06:52 +00:00
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Label {
|
2016-05-03 19:24:00 +00:00
|
|
|
text: qsTr("Password")
|
2015-12-03 22:06:52 +00:00
|
|
|
}
|
|
|
|
|
2017-03-31 14:15:14 +00:00
|
|
|
TextField {
|
2015-12-03 22:06:52 +00:00
|
|
|
id: password
|
|
|
|
text: manager.cloudPassword
|
|
|
|
echoMode: TextInput.Password
|
2015-12-30 10:46:28 +00:00
|
|
|
inputMethodHints: Qt.ImhSensitiveData |
|
2015-12-27 20:19:51 +00:00
|
|
|
Qt.ImhHiddenText |
|
|
|
|
Qt.ImhNoAutoUppercase
|
2015-12-03 22:06:52 +00:00
|
|
|
Layout.fillWidth: true
|
2017-07-22 20:15:28 +00:00
|
|
|
onEditingFinished: {
|
|
|
|
saveCredentials()
|
|
|
|
}
|
2015-12-03 22:06:52 +00:00
|
|
|
}
|
2016-06-13 23:42:36 +00:00
|
|
|
|
2015-12-04 01:57:25 +00:00
|
|
|
GridLayout {
|
|
|
|
columns: 2
|
2015-12-03 22:06:52 +00:00
|
|
|
|
2017-07-20 07:55:58 +00:00
|
|
|
Kirigami.Label {
|
|
|
|
text: qsTr("Show password")
|
|
|
|
Layout.preferredWidth: col1Width
|
|
|
|
}
|
2017-07-20 17:39:55 +00:00
|
|
|
Switch {
|
2015-12-04 01:57:25 +00:00
|
|
|
checked: false
|
|
|
|
id: showPassword
|
2017-07-20 18:23:50 +00:00
|
|
|
Layout.preferredWidth: col2Width
|
2015-12-04 01:57:25 +00:00
|
|
|
onCheckedChanged: {
|
2017-07-22 20:14:38 +00:00
|
|
|
if (checked)
|
|
|
|
password.text = "" // don't show a hidden password
|
2015-12-04 01:57:25 +00:00
|
|
|
password.echoMode = checked ? TextInput.Normal : TextInput.Password
|
|
|
|
}
|
2017-07-20 08:43:17 +00:00
|
|
|
indicator: Rectangle {
|
|
|
|
implicitWidth: Kirigami.Units.largeSpacing * 3
|
|
|
|
implicitHeight: Kirigami.Units.largeSpacing
|
|
|
|
x: showPassword.leftPadding
|
|
|
|
y: parent.height / 2 - height / 2
|
|
|
|
radius: Kirigami.Units.largeSpacing * 0.5
|
|
|
|
color: showPassword.checked ?
|
|
|
|
subsurfaceTheme.lightPrimaryColor : subsurfaceTheme.backgroundColor
|
|
|
|
border.color: subsurfaceTheme.darkerPrimaryColor
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
x: showPassword.checked ? parent.width - width : 0
|
|
|
|
y: parent.height / 2 - height / 2
|
|
|
|
width: Kirigami.Units.largeSpacing * 1.5
|
|
|
|
height: Kirigami.Units.largeSpacing * 1.5
|
|
|
|
radius: height / 2
|
|
|
|
color: showPassword.down || showPassword.checked ?
|
|
|
|
subsurfaceTheme.primaryColor : subsurfaceTheme.lightPrimaryColor
|
|
|
|
border.color: subsurfaceTheme.darkerPrimaryColor
|
|
|
|
}
|
|
|
|
}
|
2015-12-04 01:57:25 +00:00
|
|
|
}
|
2015-12-03 22:06:52 +00:00
|
|
|
}
|
2016-06-13 23:42:36 +00:00
|
|
|
|
|
|
|
Kirigami.Label {
|
|
|
|
text: qsTr("PIN")
|
|
|
|
visible: rootItem.showPin
|
|
|
|
}
|
2017-03-31 14:15:14 +00:00
|
|
|
TextField {
|
2016-06-13 23:42:36 +00:00
|
|
|
id: pin
|
|
|
|
text: ""
|
|
|
|
Layout.fillWidth: true
|
|
|
|
visible: rootItem.showPin
|
|
|
|
}
|
2015-12-03 22:06:52 +00:00
|
|
|
}
|
|
|
|
}
|