From 10b4cc914983f7c82d18d1625ba895832938819a Mon Sep 17 00:00:00 2001 From: Jon Massey Date: Mon, 18 Jul 2022 00:46:15 +0100 Subject: [PATCH] Improve UX for cloud email/password checking State requirements for email address and password format within cloud preferences UI If email address or password entered in cloud preferences, raise a warning within a QMessageBox instead of the less-visible report_error method Signed-off-by: Jon Massey --- desktop-widgets/preferences/preferences_cloud.cpp | 10 ++++++---- desktop-widgets/preferences/preferences_cloud.ui | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/desktop-widgets/preferences/preferences_cloud.cpp b/desktop-widgets/preferences/preferences_cloud.cpp index d192c3e75..b533f38a3 100644 --- a/desktop-widgets/preferences/preferences_cloud.cpp +++ b/desktop-widgets/preferences/preferences_cloud.cpp @@ -6,6 +6,7 @@ #include "core/errorhelper.h" #include "core/settings/qPrefCloudStorage.h" #include +#include PreferencesCloud::PreferencesCloud() : AbstractPreferencesWidget(tr("Cloud"),QIcon(":preferences-cloud-icon"), 9), ui(new Ui::PreferencesCloud()) { @@ -36,6 +37,7 @@ void PreferencesCloud::syncSettings() QString email = ui->cloud_storage_email->text().toLower(); QString password = ui->cloud_storage_password->text(); QString newpassword = ui->cloud_storage_new_passwd->text(); + QString emailpasswordformatwarning = "Change ignored. Cloud storage email and new password can only consist of letters, numbers, and '.', '-', '_', and '+'."; //TODO: Change this to the Cloud Storage Stuff, not preferences. if (prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED && !newpassword.isEmpty()) { @@ -44,11 +46,11 @@ void PreferencesCloud::syncSettings() // connect to backend server to check / create credentials QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$"); if (!reg.match(email).hasMatch() || (!password.isEmpty() && !reg.match(password).hasMatch())) { - report_error(qPrintable(tr("Change ignored. Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'."))); + QMessageBox::warning(this, tr("Warning"), emailpasswordformatwarning); return; } if (!reg.match(email).hasMatch() || (!newpassword.isEmpty() && !reg.match(newpassword).hasMatch())) { - report_error(qPrintable(tr("Change ignored. Cloud storage email and new password can only consist of letters, numbers, and '.', '-', '_', and '+'."))); + QMessageBox::warning(this, tr("Warning"), emailpasswordformatwarning); ui->cloud_storage_new_passwd->setText(""); return; } @@ -70,7 +72,7 @@ void PreferencesCloud::syncSettings() // connect to backend server to check / create credentials QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$"); if (!reg.match(email).hasMatch() || (!password.isEmpty() && !reg.match(password).hasMatch())) { - report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'."))); + QMessageBox::warning(this, tr("Warning"), emailpasswordformatwarning); cloud->set_cloud_verification_status(oldVerificationStatus); return; } @@ -84,7 +86,7 @@ void PreferencesCloud::syncSettings() // 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 '+'."))); + QMessageBox::warning(this, tr("Warning"), emailpasswordformatwarning); return; } CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this); diff --git a/desktop-widgets/preferences/preferences_cloud.ui b/desktop-widgets/preferences/preferences_cloud.ui index 5aea92bac..b6573c3a6 100644 --- a/desktop-widgets/preferences/preferences_cloud.ui +++ b/desktop-widgets/preferences/preferences_cloud.ui @@ -117,7 +117,7 @@ - 1) Enter an email address and a novel password that Subsurface will use to initialise the dive log in the cloud. Click Apply to send the above email address and password to the (remote) cloud server. + 1) Enter an email address and a novel password that Subsurface will use to initialise the dive log in the cloud. Click Apply to send the above email address and password to the (remote) cloud server. Cloud storage email and password can only consist of letters, numbers, and '.','-','_', and '+'.