1
0
Fork 0
mirror of https://github.com/subsurface/subsurface.git synced 2025-02-19 22:16:15 +00:00

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>
This commit is contained in:
Dirk Hohndel 2016-06-13 16:42:36 -07:00
parent 5fa965df54
commit 07512cb2c8
3 changed files with 26 additions and 7 deletions

View file

@ -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 }
}
}

View file

@ -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) {

View file

@ -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);