Improvements in LoginPage
This commit is contained in:
parent
ffe96e2200
commit
61238c8d08
5 changed files with 111 additions and 122 deletions
|
@ -11,7 +11,7 @@ Page {
|
|||
id: account
|
||||
path: "/apps/harbour-nextcloudnotes/accounts/" + accountId
|
||||
Component.onCompleted: {
|
||||
nameField.text = value("name", "", String)
|
||||
//nameField.text = value("name", "", String)
|
||||
serverField.text = "https://" + value("server", "", String)
|
||||
usernameField.text = value("username", "", String)
|
||||
passwordField.text = value("password", "", String)
|
||||
|
@ -28,34 +28,22 @@ Page {
|
|||
|
||||
Connections {
|
||||
target: notesApi
|
||||
onStatusVersionChanged: {
|
||||
for (var i = 0; i < notesApi.version.length; ++i) {
|
||||
console.log(notesApi.version[i])
|
||||
onStatusInstalledChanged: {
|
||||
if (notesApi.statusInstalled) {
|
||||
console.log("Nextcloud instance found")
|
||||
}
|
||||
}
|
||||
onLoginUrlChanged: {
|
||||
if (notesApi.loginUrl)
|
||||
Qt.openUrlExternally(notesApi.loginUrl)
|
||||
else {
|
||||
pushed = true
|
||||
//console.log("Login successfull")
|
||||
console.log("Login successfull")
|
||||
}
|
||||
}
|
||||
onStatusProductNameChanged: {
|
||||
|
||||
}
|
||||
onServerChanged: {
|
||||
console.log("Login server: " + notesApi.server)
|
||||
serverField.text = notesApi.server
|
||||
}
|
||||
onUsernameChanged: {
|
||||
console.log("Login username: " + notesApi.username)
|
||||
usernameField.text = notesApi.username
|
||||
}
|
||||
onPasswordChanged: {
|
||||
console.log("Login password: " + notesApi.password)
|
||||
passwordField.text = notesApi.password
|
||||
}
|
||||
}
|
||||
|
||||
SilicaFlickable {
|
||||
|
@ -68,39 +56,46 @@ Page {
|
|||
spacing: Theme.paddingLarge
|
||||
|
||||
PageHeader {
|
||||
title: qsTr("Nextcloud Login")
|
||||
title: notesApi.statusProductName ? notesApi.statusProductName : qsTr("Nextcloud Login")
|
||||
}
|
||||
|
||||
Image {
|
||||
id: nextcloudLogoImage
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
height: Theme.itemSizeHuge
|
||||
fillMode: Image.PreserveAspectFit
|
||||
source: "../img/nextcloud-logo-transparent.png"
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: nameField
|
||||
ProgressBar {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: parent.width
|
||||
enabled: false
|
||||
placeholderText: qsTr("Nextcloud instance")
|
||||
label: placeholderText
|
||||
indeterminate: notesApi.statusBusy
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: serverField
|
||||
Row {
|
||||
width: parent.width
|
||||
placeholderText: qsTr("Nextcloud server")
|
||||
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://"
|
||||
onTextChanged: {
|
||||
if (acceptableInput)
|
||||
notesApi.host = text
|
||||
TextField {
|
||||
id: serverField
|
||||
width: parent.width - statusIcon.width - Theme.horizontalPageMargin
|
||||
placeholderText: qsTr("Nextcloud server")
|
||||
label: placeholderText
|
||||
validator: RegExpValidator { regExp: unencryptedConnectionTextSwitch.checked ? /^https?:\/\/([-a-zA-Z0-9@:%._\+~#=].*)/: /^https:\/\/([-a-zA-Z0-9@:%._\+~#=].*)/ }
|
||||
inputMethodHints: Qt.ImhUrlCharactersOnly
|
||||
onClicked: if (text === "") text = "https://"
|
||||
onTextChanged: {
|
||||
if (acceptableInput)
|
||||
notesApi.server = 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())
|
||||
}
|
||||
Icon {
|
||||
id: statusIcon
|
||||
highlighted: serverField.highlighted
|
||||
source: notesApi.statusInstalled ? "image://theme/icon-s-accept" : "image://theme/icon-s-decline"
|
||||
}
|
||||
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 {
|
||||
|
@ -117,7 +112,7 @@ Page {
|
|||
Column {
|
||||
id: legacyLoginColumn
|
||||
width: parent.width
|
||||
visible: !flowv2LoginColumn.visible
|
||||
visible: notesApi.statusVersion.split('.')[0] < 16
|
||||
Label {
|
||||
text: "Legacy Login"
|
||||
x: Theme.horizontalPageMargin
|
||||
|
@ -155,18 +150,6 @@ Page {
|
|||
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 {
|
||||
|
|
|
@ -312,14 +312,14 @@ void NotesApi::replyFinished(QNetworkReply *reply) {
|
|||
qDebug() << "Login reply";
|
||||
if (json.isObject())
|
||||
updateLoginFlow(json.object());
|
||||
m_loginReplies.removeAll(reply);
|
||||
//m_loginReplies.removeAll(reply);
|
||||
emit loginBusyChanged(loginBusy());
|
||||
}
|
||||
else if (m_pollReplies.contains(reply)) {
|
||||
qDebug() << "Poll reply, finished";
|
||||
if (json.isObject())
|
||||
updateLoginCredentials(json.object());
|
||||
m_pollReplies.removeAll(reply);
|
||||
//m_pollReplies.removeAll(reply);
|
||||
abortFlowV2Login();
|
||||
emit loginBusyChanged(loginBusy());
|
||||
}
|
||||
|
@ -327,7 +327,7 @@ void NotesApi::replyFinished(QNetworkReply *reply) {
|
|||
qDebug() << "Status reply";
|
||||
if (json.isObject())
|
||||
updateStatus(json.object());
|
||||
m_statusReplies.removeAll(reply);
|
||||
//m_statusReplies.removeAll(reply);
|
||||
emit statusBusyChanged(statusBusy());
|
||||
}
|
||||
else if (m_notesReplies.contains(reply)) {
|
||||
|
@ -338,7 +338,7 @@ void NotesApi::replyFinished(QNetworkReply *reply) {
|
|||
emit lastSyncChanged(m_lastSync);
|
||||
}
|
||||
}
|
||||
m_notesReplies.removeAll(reply);
|
||||
//m_notesReplies.removeAll(reply);
|
||||
emit notesBusyChanged(notesBusy());
|
||||
}
|
||||
else {
|
||||
|
@ -354,10 +354,18 @@ void NotesApi::replyFinished(QNetworkReply *reply) {
|
|||
qDebug() << "Poll reply";
|
||||
//qDebug() << "Polling not finished yet" << m_pollUrl;
|
||||
}
|
||||
else if (m_statusReplies.contains(reply)) {
|
||||
updateStatus(QJsonObject());
|
||||
qDebug() << "Could not retreive status";
|
||||
}
|
||||
else {
|
||||
emit error(CommunicationError);
|
||||
}
|
||||
}
|
||||
m_loginReplies.removeAll(reply);
|
||||
m_pollReplies.removeAll(reply);
|
||||
m_statusReplies.removeAll(reply);
|
||||
m_notesReplies.removeAll(reply);
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
|
@ -388,39 +396,37 @@ QUrl NotesApi::apiEndpointUrl(const QString endpoint) const {
|
|||
}
|
||||
|
||||
void NotesApi::updateStatus(const QJsonObject &status) {
|
||||
if (!status.isEmpty()) {
|
||||
if (m_status_installed != status.value("installed").toBool()) {
|
||||
m_status_installed = status.value("installed").toBool();
|
||||
emit statusInstalledChanged(m_status_installed);
|
||||
}
|
||||
if (m_status_maintenance != status.value("maintenance").toBool()) {
|
||||
m_status_maintenance = status.value("maintenance").toBool();
|
||||
emit statusMaintenanceChanged(m_status_maintenance);
|
||||
}
|
||||
if (m_status_needsDbUpgrade != status.value("needsDbUpgrade").toBool()) {
|
||||
m_status_needsDbUpgrade = status.value("needsDbUpgrade").toBool();
|
||||
emit statusNeedsDbUpgradeChanged(m_status_needsDbUpgrade);
|
||||
}
|
||||
if (m_status_version != status.value("version").toString()) {
|
||||
m_status_version = status.value("version").toString();
|
||||
emit statusVersionChanged(m_status_version);
|
||||
}
|
||||
if (m_status_versionstring != status.value("versionstring").toString()) {
|
||||
m_status_versionstring = status.value("versionstring").toString();
|
||||
emit statusVersionStringChanged(m_status_versionstring);
|
||||
}
|
||||
if (m_status_edition != status.value("edition").toString()) {
|
||||
m_status_edition = status.value("edition").toString();
|
||||
emit statusEditionChanged(m_status_edition);
|
||||
}
|
||||
if (m_status_productname != status.value("productname").toString()) {
|
||||
m_status_productname = status.value("productname").toString();
|
||||
emit statusProductNameChanged(m_status_productname);
|
||||
}
|
||||
if (m_status_extendedSupport != status.value("extendedSupport").toBool()) {
|
||||
m_status_extendedSupport = status.value("extendedSupport").toBool();
|
||||
emit statusExtendedSupportChanged(m_status_extendedSupport);
|
||||
}
|
||||
if (m_status_installed != status.value("installed").toBool()) {
|
||||
m_status_installed = status.value("installed").toBool();
|
||||
emit statusInstalledChanged(m_status_installed);
|
||||
}
|
||||
if (m_status_maintenance != status.value("maintenance").toBool()) {
|
||||
m_status_maintenance = status.value("maintenance").toBool();
|
||||
emit statusMaintenanceChanged(m_status_maintenance);
|
||||
}
|
||||
if (m_status_needsDbUpgrade != status.value("needsDbUpgrade").toBool()) {
|
||||
m_status_needsDbUpgrade = status.value("needsDbUpgrade").toBool();
|
||||
emit statusNeedsDbUpgradeChanged(m_status_needsDbUpgrade);
|
||||
}
|
||||
if (m_status_version != status.value("version").toString()) {
|
||||
m_status_version = status.value("version").toString();
|
||||
emit statusVersionChanged(m_status_version);
|
||||
}
|
||||
if (m_status_versionstring != status.value("versionstring").toString()) {
|
||||
m_status_versionstring = status.value("versionstring").toString();
|
||||
emit statusVersionStringChanged(m_status_versionstring);
|
||||
}
|
||||
if (m_status_edition != status.value("edition").toString()) {
|
||||
m_status_edition = status.value("edition").toString();
|
||||
emit statusEditionChanged(m_status_edition);
|
||||
}
|
||||
if (m_status_productname != status.value("productname").toString()) {
|
||||
m_status_productname = status.value("productname").toString();
|
||||
emit statusProductNameChanged(m_status_productname);
|
||||
}
|
||||
if (m_status_extendedSupport != status.value("extendedSupport").toBool()) {
|
||||
m_status_extendedSupport = status.value("extendedSupport").toBool();
|
||||
emit statusExtendedSupportChanged(m_status_extendedSupport);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -126,10 +126,6 @@
|
|||
<source>Login</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Follow the login procedure</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Security</source>
|
||||
<translation type="unfinished"></translation>
|
||||
|
@ -155,7 +151,11 @@
|
|||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Nextcloud instance</source>
|
||||
<source>Username</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Password</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
|
|
|
@ -126,10 +126,6 @@
|
|||
<source>Login</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Follow the login procedure</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Security</source>
|
||||
<translation type="unfinished"></translation>
|
||||
|
@ -155,7 +151,11 @@
|
|||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Nextcloud instance</source>
|
||||
<source>Username</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Password</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
|
|
|
@ -133,57 +133,57 @@
|
|||
<context>
|
||||
<name>LoginPage</name>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="71"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="59"/>
|
||||
<source>Nextcloud Login</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="85"/>
|
||||
<source>Nextcloud instance</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="91"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="81"/>
|
||||
<source>Nextcloud server</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="125"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="124"/>
|
||||
<source>Username</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="137"/>
|
||||
<source>Password</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="150"/>
|
||||
<source>Abort</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="125"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="150"/>
|
||||
<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/LoginPage.qml" line="201"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="189"/>
|
||||
<source>Security</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="208"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="196"/>
|
||||
<source><strong>CAUTION: Your password will be saved without any encryption on the device!</strong><br>Please consider creating a dedicated app password! Open your Nextcloud in a browser and go to <i>Settings</i> → <i>Security</i>.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="212"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="200"/>
|
||||
<source>Do not check certificates</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="213"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="201"/>
|
||||
<source>Enable this option to allow selfsigned certificates</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="219"/>
|
||||
<location filename="../qml/pages/LoginPage.qml" line="207"/>
|
||||
<source>Allow unencrypted connections</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -270,37 +270,37 @@
|
|||
<context>
|
||||
<name>NotesApi</name>
|
||||
<message>
|
||||
<location filename="../src/notesapi.cpp" line="477"/>
|
||||
<location filename="../src/notesapi.cpp" line="483"/>
|
||||
<source>No network connection available</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/notesapi.cpp" line="480"/>
|
||||
<location filename="../src/notesapi.cpp" line="486"/>
|
||||
<source>Failed to communicate with the Nextcloud server</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/notesapi.cpp" line="483"/>
|
||||
<location filename="../src/notesapi.cpp" line="489"/>
|
||||
<source>An error happened while reading from the local storage</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/notesapi.cpp" line="486"/>
|
||||
<location filename="../src/notesapi.cpp" line="492"/>
|
||||
<source>An error happened while writing to the local storage</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/notesapi.cpp" line="489"/>
|
||||
<location filename="../src/notesapi.cpp" line="495"/>
|
||||
<source>An error occured while establishing an encrypted connection</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/notesapi.cpp" line="492"/>
|
||||
<location filename="../src/notesapi.cpp" line="498"/>
|
||||
<source>Could not authenticate to the Nextcloud instance</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/notesapi.cpp" line="495"/>
|
||||
<location filename="../src/notesapi.cpp" line="501"/>
|
||||
<source>Unknown error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
Loading…
Reference in a new issue