diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2016-06-13 16:42:36 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-06-13 16:42:36 -0700 |
commit | 07512cb2c8ed6e6878ddb29e44219cb5d71eaf59 (patch) | |
tree | a762a1262ed1baf5ba9db8fc3a319f2269adc165 /mobile-widgets | |
parent | 5fa965df54c1ab7f881271e0dad2b6dfa6f253ed (diff) | |
download | subsurface-07512cb2c8ed6e6878ddb29e44219cb5d71eaf59.tar.gz |
QML UI: allow entering the cloud PIN on the mobile UI
Now the user doesn't need to do this on the desktop app anymore.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets')
-rw-r--r-- | mobile-widgets/qml/CloudCredentials.qml | 14 | ||||
-rw-r--r-- | mobile-widgets/qml/main.qml | 2 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 17 |
3 files changed, 26 insertions, 7 deletions
diff --git a/mobile-widgets/qml/CloudCredentials.qml b/mobile-widgets/qml/CloudCredentials.qml index 1222dbb2b..7f1e0d986 100644 --- a/mobile-widgets/qml/CloudCredentials.qml +++ b/mobile-widgets/qml/CloudCredentials.qml @@ -16,6 +16,7 @@ Item { function saveCredentials() { manager.cloudUserName = login.text manager.cloudPassword = password.text + manager.cloudPin = pin.text manager.saveCloudCredentials() } @@ -76,6 +77,7 @@ Item { Qt.ImhNoAutoUppercase Layout.fillWidth: true } + GridLayout { columns: 2 @@ -90,6 +92,18 @@ Item { text: qsTr("Show password") } } + + Kirigami.Label { + text: qsTr("PIN") + visible: rootItem.showPin + } + StyledTextField { + id: pin + text: "" + Layout.fillWidth: true + visible: rootItem.showPin + } + Item { width: Kirigami.Units.gridUnit; height: width } } } diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml index a855cdaf6..99c8dc27b 100644 --- a/mobile-widgets/qml/main.qml +++ b/mobile-widgets/qml/main.qml @@ -23,6 +23,8 @@ Kirigami.ApplicationWindow { property QtObject notification: null property bool showingDiveList: false property alias syncToCloud: manager.syncToCloud + property alias showPin: manager.showPin + onAccessingCloudChanged: { // >= 0 for updating cloud, -1 for hide, < -1 for local storage if (accessingCloud >= 0) { diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 3e19969b5..d9ab7f2ee 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -293,6 +293,9 @@ void QMLManager::saveCloudCredentials() currentGitLocalOnly = prefs.git_local_only; prefs.git_local_only = false; openLocalThenRemote(url); + } else if (prefs.cloud_verification_status = CS_NEED_TO_VERIFY && !cloudPin().isEmpty()) { + // the user entered a PIN? + tryRetrieveDataFromBackend(); } } @@ -306,7 +309,7 @@ void QMLManager::checkCredentialsAndExecute(execute_function_type execute) setStartPageText(tr("Testing cloud credentials")); appendTextToLog("Have credentials, let's see if they are valid"); CloudStorageAuthenticate *csa = new CloudStorageAuthenticate(this); - csa->backend(prefs.cloud_storage_email, prefs.cloud_storage_password); + csa->backend(prefs.cloud_storage_email, prefs.cloud_storage_password, cloudPin()); // let's wait here for the signal to avoid too many more nested functions QTimer myTimer; myTimer.setSingleShot(true); @@ -322,18 +325,18 @@ void QMLManager::checkCredentialsAndExecute(execute_function_type execute) return; } myTimer.stop(); - if (prefs.cloud_verification_status == CS_NEED_TO_VERIFY) { + setCloudPin(""); + if (prefs.cloud_verification_status != CS_VERIFIED) { // here we need to enter the PIN appendTextToLog(QStringLiteral("Need to verify the email address - enter PIN in desktop app")); setStartPageText(RED_FONT + tr("Cannot connect to cloud storage - cloud account not verified") + END_FONT); revertToNoCloudIfNeeded(); - return; - } else if (prefs.cloud_verification_status != CS_VERIFIED) { - appendTextToLog(QString("Cloud account verification failed - status %1").arg(prefs.cloud_verification_status)); - setStartPageText(RED_FONT + tr("Cannot connect to cloud storage - check developer log") + END_FONT); - revertToNoCloudIfNeeded(); + setShowPin(true); return; } + if (showPin()) + setShowPin(false); + // now check the redirect URL to make sure everything is set up on the cloud server connect(manager(), &QNetworkAccessManager::authenticationRequired, this, &QMLManager::provideAuth, Qt::UniqueConnection); QUrl url(CLOUDREDIRECTURL); |