Worked on LoginPage

This commit is contained in:
Scharel Clemens 2020-01-19 13:13:29 +01:00
parent 4563e95ef7
commit ffe96e2200
7 changed files with 135 additions and 128 deletions

View file

@ -29,6 +29,7 @@ SOURCES += src/harbour-nextcloudnotes.cpp \
DISTFILES += qml/harbour-nextcloudnotes.qml \
LoginWebview.qml \
qml/cover/CoverPage.qml \
qml/pages/LoginPage.qml \
rpm/harbour-nextcloudnotes.changes.run.in \
rpm/harbour-nextcloudnotes.changes \
rpm/harbour-nextcloudnotes.spec \
@ -37,7 +38,6 @@ DISTFILES += qml/harbour-nextcloudnotes.qml \
harbour-nextcloudnotes.desktop \
qml/pages/NotePage.qml \
qml/pages/NotesPage.qml \
qml/pages/LoginDialog.qml \
qml/pages/EditPage.qml \
qml/pages/SettingsPage.qml \
qml/pages/AboutPage.qml \

View file

@ -2,41 +2,29 @@ import QtQuick 2.2
import Sailfish.Silica 1.0
import Nemo.Configuration 1.0
Dialog {
id: loginDialog
Page {
id: loginPage
property string accountId
property bool addingNew: false
ConfigurationGroup {
id: account
path: "/apps/harbour-nextcloudnotes/accounts/" + accountId
Component.onCompleted: {
//nameField.text = value("name", "", String)
serverField.text = value("server", "", String)
nameField.text = value("name", "", String)
serverField.text = "https://" + value("server", "", String)
usernameField.text = value("username", "", String)
passwordField.text = value("password", "", String)
unsecureConnectionTextSwitch.checked = value("unsecureConnection", false, Boolean)
unencryptedConnectionTextSwitch.checked = value("unencryptedConnection", false, Boolean)
nameField.text === "" ? nameField.focus = true : (serverField.text === "https://" ? serverField.focus = true : (usernameField.text === "" ? usernameField.focus = true : (passwordField.text === "" ? passwordField.focus = true : passwordField.focus = false)))
serverField.text === "https://" ? serverField.focus = true : (usernameField.text === "" ? usernameField.focus = true : (passwordField.text === "" ? passwordField.focus = true : passwordField.focus = false))
}
}
canAccept: (nameField.text.length > 0 && serverField.acceptableInput && usernameField.text.length > 0 && passwordField.text.length > 0)
onAccepted: {
account.setValue("name", nameField.text)
account.setValue("server", serverField.text)
account.setValue("username", usernameField.text)
account.setValue("password", passwordField.text)
account.setValue("unsecureConnection", unsecureConnectionTextSwitch.checked)
account.setValue("unencryptedConnection", unencryptedConnectionTextSwitch.checked)
account.sync()
onStatusChanged: {
if (status === PageStatus.Deactivating)
notesApi.abortFlowV2Login()
}
onRejected: {
if (addingNew) appSettings.removeAccount(accountId)
notesApi.host = account.value("server", "", String)
}
onDone: notesApi.abortFlowV2Login()
Connections {
target: notesApi
@ -52,6 +40,9 @@ Dialog {
pushed = true
//console.log("Login successfull")
}
}
onStatusProductNameChanged: {
}
onServerChanged: {
console.log("Login server: " + notesApi.server)
@ -76,9 +67,8 @@ Dialog {
width: parent.width
spacing: Theme.paddingLarge
DialogHeader {
//title: qsTr("Nextcloud Login")
acceptText: addingNew ? qsTr("Login") : qsTr("Save")
PageHeader {
title: qsTr("Nextcloud Login")
}
Image {
@ -89,9 +79,18 @@ Dialog {
}
TextField {
id: nameField
width: parent.width
enabled: false
placeholderText: qsTr("Nextcloud instance")
label: placeholderText
}
TextField {
id: serverField
width: parent.width
placeholderText: qsTr("Nextcloud server")
validator: RegExpValidator { regExp: /^https?:\/\/([-a-zA-Z0-9@:%._\+~#=].*)/ }
validator: RegExpValidator { regExp: unencryptedConnectionTextSwitch.checked ? /^https?:\/\/([-a-zA-Z0-9@:%._\+~#=].*)/: /^https:\/\/([-a-zA-Z0-9@:%._\+~#=].*)/ }
inputMethodHints: Qt.ImhUrlCharactersOnly
label: placeholderText
onClicked: if (text === "") text = "https://"
@ -99,6 +98,9 @@ Dialog {
if (acceptableInput)
notesApi.host = text
}
EnterKey.enabled: text.length > 0
EnterKey.iconSource: legacyLoginColumn.visible ? "image://theme/icon-m-enter-next" : "icon-m-enter-accept"
EnterKey.onClicked: legacyLoginColumn.visible ? passwordField.focus = true : (notesApi.loginBusy ? notesApi.abortFlowV2Login() : notesApi.initiateFlowV2Login())
}
Column {
@ -108,6 +110,7 @@ Dialog {
visible: notesApi.statusVersion.split('.')[0] >= 16
Label {
text: "Flow Login v2"
x: Theme.horizontalPageMargin
}
}
@ -117,9 +120,55 @@ Dialog {
visible: !flowv2LoginColumn.visible
Label {
text: "Legacy Login"
x: Theme.horizontalPageMargin
}
TextField {
id: usernameField
width: parent.width
//text: account.value("name", "", String)
placeholderText: qsTr("Username")
label: placeholderText
inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
errorHighlight: text.length === 0// && focus === true
EnterKey.enabled: text.length > 0
EnterKey.iconSource: "image://theme/icon-m-enter-next"
EnterKey.onClicked: passwordField.focus = true
}
PasswordField {
id: passwordField
width: parent.width
//text: account.value("password", "", String)
placeholderText: qsTr("Password")
label: placeholderText
errorHighlight: text.length === 0// && focus === true
EnterKey.enabled: text.length > 0
EnterKey.iconSource: "image://theme/icon-m-enter-accept"
EnterKey.onClicked: loginDialog.accept()
}
}
Button {
id: loginButton
anchors.horizontalCenter: parent.horizontalCenter
property bool pushed: false
text: notesApi.loginBusy ? qsTr("Abort") : qsTr("Login")
onClicked: notesApi.loginBusy ? notesApi.abortFlowV2Login() : notesApi.initiateFlowV2Login()
}
ProgressBar {
id: loginProgressBar
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
highlighted: notesApi.loginBusy
indeterminate: notesApi.loginUrl.toString() !== ""
label: indeterminate ? qsTr("Follow the login procedure") : ""
//anchors.verticalCenter: loginButton.verticalCenter
//anchors.left: loginButton.right
//anchors.leftMargin: Theme.paddingMedium
//running: notesApi.loginBusy
}
/*
TextField {
id: nameField
width: parent.width
@ -151,50 +200,7 @@ Dialog {
EnterKey.onClicked: usernameField.focus = true
onTextChanged: notesApi.host = text
}
TextField {
id: usernameField
width: parent.width
//text: account.value("name", "", String)
placeholderText: qsTr("Username")
label: placeholderText
inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
errorHighlight: text.length === 0// && focus === true
EnterKey.enabled: text.length > 0
EnterKey.iconSource: "image://theme/icon-m-enter-next"
EnterKey.onClicked: passwordField.focus = true
}
PasswordField {
id: passwordField
width: parent.width
//text: account.value("password", "", String)
placeholderText: qsTr("Password")
label: placeholderText
errorHighlight: text.length === 0// && focus === true
EnterKey.enabled: text.length > 0
EnterKey.iconSource: "image://theme/icon-m-enter-accept"
EnterKey.onClicked: loginDialog.accept()
}
Button {
id: loginButton
anchors.horizontalCenter: parent.horizontalCenter
property bool pushed: false
text: notesApi.loginBusy ? qsTr("Abort") : qsTr("Login")
onClicked: notesApi.loginBusy ? notesApi.abortFlowV2Login() : notesApi.initiateFlowV2Login()
}
ProgressBar {
id: loginProgressBar
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width
highlighted: notesApi.loginBusy
indeterminate: notesApi.loginUrl.toString() !== ""
label: indeterminate ? qsTr("Follow the login procedure") : ""
//anchors.verticalCenter: loginButton.verticalCenter
//anchors.left: loginButton.right
//anchors.leftMargin: Theme.paddingMedium
//running: notesApi.loginBusy
}
*/
SectionHeader {
text: qsTr("Security")

View file

@ -70,7 +70,7 @@ Page {
MenuItem {
text: qsTr("Edit")
onClicked: {
var login = pageStack.replace(Qt.resolvedUrl("LoginDialog.qml"), { accountId: modelData })
var login = pageStack.replace(Qt.resolvedUrl("LoginPage.qml"), { accountId: modelData })
}
}
MenuItem {
@ -90,7 +90,7 @@ Page {
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
var newAccountID = appSettings.addAccount()
var login = pageStack.replace(Qt.resolvedUrl("LoginDialog.qml"), { accountId: newAccountID, addingNew: true })
var login = pageStack.replace(Qt.resolvedUrl("LoginPage.qml"), { accountId: newAccountID, addingNew: true })
}
}

View file

@ -12,6 +12,13 @@
# * date Author's Name <author's email> version-release
# - Summary of changes
* Sun Jan 19 2020 Scharel Clemens <harbour-nextcloudnotes@scharel.rocks> 0.5-0
- Added offline mode
- Added Nextcloud Flow v2 Login
* Sun Jan 19 2020 Scharel Clemens <harbour-nextcloudnotes@scharel.rocks> 0.4-0
- Implemented API in C++
* Fri Dec 28 2018 Scharel Clemens <harbour-nextcloudnotes@scharel.name> 0.3-0
- Began implementing the data model in C++

View file

@ -107,16 +107,11 @@
<source></source>
<translation></translation>
</message>
</context>
<context>
<name>LoginPage</name>
<message>
<source>Login</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Account name</source>
<source>Nextcloud Login</source>
<translation type="unfinished"></translation>
</message>
<message>
@ -124,11 +119,15 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Username</source>
<source>Abort</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Password</source>
<source>Login</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Follow the login procedure</source>
<translation type="unfinished"></translation>
</message>
<message>
@ -152,11 +151,11 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Abort</source>
<translation type="unfinished"></translation>
<source></source>
<translation></translation>
</message>
<message>
<source>Follow the login procedure</source>
<source>Nextcloud instance</source>
<translation type="unfinished"></translation>
</message>
</context>

View file

@ -107,16 +107,11 @@
<source></source>
<translation></translation>
</message>
</context>
<context>
<name>LoginPage</name>
<message>
<source>Login</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Save</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Account name</source>
<source>Nextcloud Login</source>
<translation type="unfinished"></translation>
</message>
<message>
@ -124,11 +119,15 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Username</source>
<source>Abort</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Password</source>
<source>Login</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Follow the login procedure</source>
<translation type="unfinished"></translation>
</message>
<message>
@ -152,11 +151,11 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Abort</source>
<translation type="unfinished"></translation>
<source></source>
<translation></translation>
</message>
<message>
<source>Follow the login procedure</source>
<source>Nextcloud instance</source>
<translation type="unfinished"></translation>
</message>
</context>

View file

@ -129,73 +129,69 @@
<source></source>
<translation></translation>
</message>
</context>
<context>
<name>LoginPage</name>
<message>
<location filename="../qml/pages/LoginDialog.qml" line="80"/>
<location filename="../qml/pages/LoginDialog.qml" line="186"/>
<source>Login</source>
<location filename="../qml/pages/LoginPage.qml" line="71"/>
<source>Nextcloud Login</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/LoginDialog.qml" line="80"/>
<source>Save</source>
<location filename="../qml/pages/LoginPage.qml" line="85"/>
<source>Nextcloud instance</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/LoginDialog.qml" line="132"/>
<source>Account name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/LoginDialog.qml" line="101"/>
<location filename="../qml/pages/LoginDialog.qml" line="147"/>
<location filename="../qml/pages/LoginPage.qml" line="91"/>
<source>Nextcloud server</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/LoginDialog.qml" line="162"/>
<source>Username</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/LoginDialog.qml" line="175"/>
<source>Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/LoginDialog.qml" line="186"/>
<location filename="../qml/pages/LoginPage.qml" line="125"/>
<source>Abort</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/LoginDialog.qml" line="195"/>
<location filename="../qml/pages/LoginPage.qml" line="125"/>
<source>Login</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/LoginPage.qml" line="134"/>
<source>Follow the login procedure</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/LoginDialog.qml" line="203"/>
<location filename="../qml/pages/LoginPage.qml" line="201"/>
<source>Security</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/LoginDialog.qml" line="210"/>
<location filename="../qml/pages/LoginPage.qml" line="208"/>
<source>&lt;strong&gt;CAUTION: Your password will be saved without any encryption on the device!&lt;/strong&gt;&lt;br&gt;Please consider creating a dedicated app password! Open your Nextcloud in a browser and go to &lt;i&gt;Settings&lt;/i&gt; &lt;i&gt;Security&lt;/i&gt;.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/LoginDialog.qml" line="214"/>
<location filename="../qml/pages/LoginPage.qml" line="212"/>
<source>Do not check certificates</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/LoginDialog.qml" line="215"/>
<location filename="../qml/pages/LoginPage.qml" line="213"/>
<source>Enable this option to allow selfsigned certificates</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/LoginDialog.qml" line="221"/>
<location filename="../qml/pages/LoginPage.qml" line="219"/>
<source>Allow unencrypted connections</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../qml/pages/LoginPage.qml" line="206"/>
<source></source>
<translation></translation>
</message>
</context>
<context>
<name>MITLicense</name>