summaryrefslogtreecommitdiffstats
path: root/qt-ui/preferences.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-09 11:21:03 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-09 17:03:53 -0700
commita04f1fd13317034c471ad7eb8dbf55375566f947 (patch)
tree8f187306b89608b329a3e295e2d071fe72571504 /qt-ui/preferences.cpp
parenta07376b5345fdb398510ac29835493b7ca75ce77 (diff)
downloadsubsurface-a04f1fd13317034c471ad7eb8dbf55375566f947.tar.gz
Cloud storage: deal with visibility of PIN entry
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/preferences.cpp')
-rw-r--r--qt-ui/preferences.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index 89402c87a..e3872ee4d 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -107,6 +107,8 @@ void PreferencesDialog::cloudPinNeeded(bool toggle)
{
ui.cloud_storage_pin->setEnabled(toggle);
ui.cloud_storage_pin->setVisible(toggle);
+ ui.cloud_storage_pin_label->setEnabled(toggle);
+ ui.cloud_storage_pin_label->setVisible(toggle);
}
#define DANGER_GF (gf > 100) ? "* { color: red; }" : ""
@@ -216,6 +218,7 @@ void PreferencesDialog::setUiFromPrefs()
ui.cloud_storage_password->setText(prefs.cloud_storage_password);
ui.save_password_local->setChecked(prefs.save_password_local);
ui.cloud_storage_pin->setVisible(prefs.show_cloud_pin);
+ ui.cloud_storage_pin_label->setVisible(prefs.show_cloud_pin);
}
void PreferencesDialog::restorePrefs()
@@ -370,8 +373,18 @@ void PreferencesDialog::syncSettings()
s.beginGroup("CloudStorage");
QString email = ui.cloud_storage_email->text();
QString password = ui.cloud_storage_password->text();
- QString pin = ui.cloud_storage_pin->text();
- if (email != prefs.cloud_storage_email || password != prefs.cloud_storage_password) {
+ if (ui.cloud_storage_pin->isVisible()) {
+ QString pin = ui.cloud_storage_pin->text();
+ if (!pin.isEmpty()) {
+ // connect to backend server to check / create credentials
+ QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$");
+ if (!reg.match(email).hasMatch() || !reg.match(password).hasMatch()) {
+ report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
+ }
+ CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
+ QNetworkReply *reply = cloudAuth->authenticate(email, password, pin);
+ }
+ } else if (email != prefs.cloud_storage_email || password != prefs.cloud_storage_password) {
// connect to backend server to check / create credentials
QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$");
if (!reg.match(email).hasMatch() || !reg.match(password).hasMatch()) {