Skip to content

Commit

Permalink
Improve UX for cloud email/password checking
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Jongmassey authored and bstoeger committed Jul 24, 2022
1 parent 50ff94e commit 10b4cc9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions desktop-widgets/preferences/preferences_cloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "core/errorhelper.h"
#include "core/settings/qPrefCloudStorage.h"
#include <QRegularExpression>
#include <QMessageBox>

PreferencesCloud::PreferencesCloud() : AbstractPreferencesWidget(tr("Cloud"),QIcon(":preferences-cloud-icon"), 9), ui(new Ui::PreferencesCloud())
{
Expand Down Expand Up @@ -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()) {
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion desktop-widgets/preferences/preferences_cloud.ui
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<string extracomment="Help info 1"/>
</property>
<property name="text">
<string>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.</string>
<string>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 '+'.</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit 10b4cc9

Please sign in to comment.