mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cloud storage: deal with visibility of PIN entry
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
a07376b534
commit
a04f1fd133
2 changed files with 16 additions and 3 deletions
|
@ -107,6 +107,8 @@ void PreferencesDialog::cloudPinNeeded(bool toggle)
|
||||||
{
|
{
|
||||||
ui.cloud_storage_pin->setEnabled(toggle);
|
ui.cloud_storage_pin->setEnabled(toggle);
|
||||||
ui.cloud_storage_pin->setVisible(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; }" : ""
|
#define DANGER_GF (gf > 100) ? "* { color: red; }" : ""
|
||||||
|
@ -216,6 +218,7 @@ void PreferencesDialog::setUiFromPrefs()
|
||||||
ui.cloud_storage_password->setText(prefs.cloud_storage_password);
|
ui.cloud_storage_password->setText(prefs.cloud_storage_password);
|
||||||
ui.save_password_local->setChecked(prefs.save_password_local);
|
ui.save_password_local->setChecked(prefs.save_password_local);
|
||||||
ui.cloud_storage_pin->setVisible(prefs.show_cloud_pin);
|
ui.cloud_storage_pin->setVisible(prefs.show_cloud_pin);
|
||||||
|
ui.cloud_storage_pin_label->setVisible(prefs.show_cloud_pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::restorePrefs()
|
void PreferencesDialog::restorePrefs()
|
||||||
|
@ -370,8 +373,18 @@ void PreferencesDialog::syncSettings()
|
||||||
s.beginGroup("CloudStorage");
|
s.beginGroup("CloudStorage");
|
||||||
QString email = ui.cloud_storage_email->text();
|
QString email = ui.cloud_storage_email->text();
|
||||||
QString password = ui.cloud_storage_password->text();
|
QString password = ui.cloud_storage_password->text();
|
||||||
QString pin = ui.cloud_storage_pin->text();
|
if (ui.cloud_storage_pin->isVisible()) {
|
||||||
if (email != prefs.cloud_storage_email || password != prefs.cloud_storage_password) {
|
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
|
// connect to backend server to check / create credentials
|
||||||
QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$");
|
QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$");
|
||||||
if (!reg.match(email).hasMatch() || !reg.match(password).hasMatch()) {
|
if (!reg.match(email).hasMatch() || !reg.match(password).hasMatch()) {
|
||||||
|
|
|
@ -452,7 +452,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="0" column="2">
|
||||||
<widget class="QLabel" name="label_16d">
|
<widget class="QLabel" name="cloud_storage_pin_label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Verification PIN</string>
|
<string>Verification PIN</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
Loading…
Add table
Reference in a new issue