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:
parent
5fa965df54
commit
07512cb2c8
3 changed files with 26 additions and 7 deletions
|
@ -16,6 +16,7 @@ Item {
|
||||||
function saveCredentials() {
|
function saveCredentials() {
|
||||||
manager.cloudUserName = login.text
|
manager.cloudUserName = login.text
|
||||||
manager.cloudPassword = password.text
|
manager.cloudPassword = password.text
|
||||||
|
manager.cloudPin = pin.text
|
||||||
manager.saveCloudCredentials()
|
manager.saveCloudCredentials()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +77,7 @@ Item {
|
||||||
Qt.ImhNoAutoUppercase
|
Qt.ImhNoAutoUppercase
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
GridLayout {
|
GridLayout {
|
||||||
columns: 2
|
columns: 2
|
||||||
|
|
||||||
|
@ -90,6 +92,18 @@ Item {
|
||||||
text: qsTr("Show password")
|
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 }
|
Item { width: Kirigami.Units.gridUnit; height: width }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ Kirigami.ApplicationWindow {
|
||||||
property QtObject notification: null
|
property QtObject notification: null
|
||||||
property bool showingDiveList: false
|
property bool showingDiveList: false
|
||||||
property alias syncToCloud: manager.syncToCloud
|
property alias syncToCloud: manager.syncToCloud
|
||||||
|
property alias showPin: manager.showPin
|
||||||
|
|
||||||
onAccessingCloudChanged: {
|
onAccessingCloudChanged: {
|
||||||
// >= 0 for updating cloud, -1 for hide, < -1 for local storage
|
// >= 0 for updating cloud, -1 for hide, < -1 for local storage
|
||||||
if (accessingCloud >= 0) {
|
if (accessingCloud >= 0) {
|
||||||
|
|
|
@ -293,6 +293,9 @@ void QMLManager::saveCloudCredentials()
|
||||||
currentGitLocalOnly = prefs.git_local_only;
|
currentGitLocalOnly = prefs.git_local_only;
|
||||||
prefs.git_local_only = false;
|
prefs.git_local_only = false;
|
||||||
openLocalThenRemote(url);
|
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"));
|
setStartPageText(tr("Testing cloud credentials"));
|
||||||
appendTextToLog("Have credentials, let's see if they are valid");
|
appendTextToLog("Have credentials, let's see if they are valid");
|
||||||
CloudStorageAuthenticate *csa = new CloudStorageAuthenticate(this);
|
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
|
// let's wait here for the signal to avoid too many more nested functions
|
||||||
QTimer myTimer;
|
QTimer myTimer;
|
||||||
myTimer.setSingleShot(true);
|
myTimer.setSingleShot(true);
|
||||||
|
@ -322,18 +325,18 @@ void QMLManager::checkCredentialsAndExecute(execute_function_type execute)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
myTimer.stop();
|
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
|
// here we need to enter the PIN
|
||||||
appendTextToLog(QStringLiteral("Need to verify the email address - enter PIN in desktop app"));
|
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);
|
setStartPageText(RED_FONT + tr("Cannot connect to cloud storage - cloud account not verified") + END_FONT);
|
||||||
revertToNoCloudIfNeeded();
|
revertToNoCloudIfNeeded();
|
||||||
return;
|
setShowPin(true);
|
||||||
} 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();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (showPin())
|
||||||
|
setShowPin(false);
|
||||||
|
|
||||||
// now check the redirect URL to make sure everything is set up on the cloud server
|
// 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);
|
connect(manager(), &QNetworkAccessManager::authenticationRequired, this, &QMLManager::provideAuth, Qt::UniqueConnection);
|
||||||
QUrl url(CLOUDREDIRECTURL);
|
QUrl url(CLOUDREDIRECTURL);
|
||||||
|
|
Loading…
Add table
Reference in a new issue