Cloud storage: deal with visibility of PIN entry

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-06-09 11:21:03 -07:00
parent a07376b534
commit a04f1fd133
2 changed files with 16 additions and 3 deletions

View file

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

View file

@ -452,7 +452,7 @@
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_16d">
<widget class="QLabel" name="cloud_storage_pin_label">
<property name="text">
<string>Verification PIN</string>
</property>