summaryrefslogtreecommitdiffstats
path: root/qt-ui/preferences.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-07 09:54:28 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-09 17:03:36 -0700
commita07376b5345fdb398510ac29835493b7ca75ce77 (patch)
tree57a23b3f6e2bd455a6b615bfe7ac1e197caca037 /qt-ui/preferences.cpp
parent318bf5cccc9a8ac2c8ee18939e3c6c4a4e7a0fb3 (diff)
downloadsubsurface-a07376b5345fdb398510ac29835493b7ca75ce77.tar.gz
Cloud storage: initial support for confirming the email PIN
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/preferences.cpp')
-rw-r--r--qt-ui/preferences.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index 8342dff78..89402c87a 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -59,7 +59,6 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDial
connect(ui.btnDisconnectFacebook, &QPushButton::clicked, fb, &FacebookManager::logout);
connect(fb, &FacebookManager::justLoggedOut, this, &PreferencesDialog::facebookDisconnect);
#endif
-
connect(ui.proxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(proxyType_changed(int)));
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *)));
connect(ui.gflow, SIGNAL(valueChanged(int)), this, SLOT(gflowChanged(int)));
@@ -104,6 +103,12 @@ void PreferencesDialog::facebookDisconnect()
#endif
}
+void PreferencesDialog::cloudPinNeeded(bool toggle)
+{
+ ui.cloud_storage_pin->setEnabled(toggle);
+ ui.cloud_storage_pin->setVisible(toggle);
+}
+
#define DANGER_GF (gf > 100) ? "* { color: red; }" : ""
void PreferencesDialog::gflowChanged(int gf)
{
@@ -210,6 +215,7 @@ void PreferencesDialog::setUiFromPrefs()
ui.cloud_storage_email->setText(prefs.cloud_storage_email);
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);
}
void PreferencesDialog::restorePrefs()
@@ -364,6 +370,7 @@ 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) {
// connect to backend server to check / create credentials
QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$");
@@ -371,6 +378,7 @@ void PreferencesDialog::syncSettings()
report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
}
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
+ connect(cloudAuth, SIGNAL(finishedAuthenticate(bool)), this, SLOT(cloudPinNeeded(bool)));
QNetworkReply *reply = cloudAuth->authenticate(email, password);
}
SAVE_OR_REMOVE("email", default_prefs.cloud_storage_email, email);
@@ -379,6 +387,7 @@ void PreferencesDialog::syncSettings()
SAVE_OR_REMOVE("password", default_prefs.cloud_storage_password, password);
else
s.remove("password");
+ SAVE_OR_REMOVE("show_cloud_pin", default_prefs.show_cloud_pin, prefs.show_cloud_pin);
s.endGroup();
loadSettings();
emit settingsChanged();
@@ -495,6 +504,7 @@ void PreferencesDialog::loadSettings()
GET_TXT("password", cloud_storage_password);
GET_TXT("email", cloud_storage_email);
GET_BOOL("save_password_local", save_password_local);
+ GET_BOOL("show_cloud_pin", show_cloud_pin);
s.endGroup();
}