mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 20:13:23 +00:00
Preferences UI: split network preferences
Split the Network Preferences page into two screens: 1) Network preferences 2) Cloud storage preferences Enable storing these preferences locally. Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
b16570c715
commit
c121afc96c
11 changed files with 328 additions and 188 deletions
|
@ -8,6 +8,7 @@ set(SUBSURFACE_PREFERENCES_UI
|
||||||
preferences_defaults.ui
|
preferences_defaults.ui
|
||||||
preferences_graph.ui
|
preferences_graph.ui
|
||||||
preferences_network.ui
|
preferences_network.ui
|
||||||
|
preferences_cloud.ui
|
||||||
preferences_units.ui
|
preferences_units.ui
|
||||||
preferences_georeference.ui
|
preferences_georeference.ui
|
||||||
preferences_language.ui
|
preferences_language.ui
|
||||||
|
@ -30,6 +31,8 @@ set(SUBSURFACE_PREFERENCES_LIB_SRCS
|
||||||
preferences_language.h
|
preferences_language.h
|
||||||
preferences_network.cpp
|
preferences_network.cpp
|
||||||
preferences_network.h
|
preferences_network.h
|
||||||
|
preferences_cloud.cpp
|
||||||
|
preferences_cloud.h
|
||||||
preferences_units.cpp
|
preferences_units.cpp
|
||||||
preferences_units.h
|
preferences_units.h
|
||||||
preferencesdialog.cpp
|
preferencesdialog.cpp
|
||||||
|
|
127
desktop-widgets/preferences/preferences_cloud.cpp
Normal file
127
desktop-widgets/preferences/preferences_cloud.cpp
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
|
#include "preferences_cloud.h"
|
||||||
|
#include "ui_preferences_cloud.h"
|
||||||
|
#include "subsurfacewebservices.h"
|
||||||
|
#include "core/cloudstorage.h"
|
||||||
|
#include "core/errorhelper.h"
|
||||||
|
#include "core/settings/qPrefCloudStorage.h"
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
PreferencesCloud::PreferencesCloud() : AbstractPreferencesWidget(tr("Cloud"),QIcon(":preferences-cloud-icon"), 9), ui(new Ui::PreferencesCloud())
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
ui->label_help2->setWordWrap(true);
|
||||||
|
ui->label_help3->setWordWrap(true);
|
||||||
|
ui->label_help4->setWordWrap(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
PreferencesCloud::~PreferencesCloud()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesCloud::refreshSettings()
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
updateCloudAuthenticationState();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesCloud::syncSettings()
|
||||||
|
{
|
||||||
|
auto cloud = qPrefCloudStorage::instance();
|
||||||
|
|
||||||
|
QString email = ui->cloud_storage_email->text().toLower();
|
||||||
|
QString password = ui->cloud_storage_password->text();
|
||||||
|
QString newpassword = ui->cloud_storage_new_passwd->text();
|
||||||
|
|
||||||
|
//TODO: Change this to the Cloud Storage Stuff, not preferences.
|
||||||
|
if (prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED && !newpassword.isEmpty()) {
|
||||||
|
// deal with password change
|
||||||
|
if (!email.isEmpty() && !password.isEmpty()) {
|
||||||
|
// 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 '+'.")));
|
||||||
|
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 '+'.")));
|
||||||
|
ui->cloud_storage_new_passwd->setText("");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
|
||||||
|
connect(cloudAuth, &CloudStorageAuthenticate::finishedAuthenticate, this, &PreferencesCloud::updateCloudAuthenticationState);
|
||||||
|
connect(cloudAuth, &CloudStorageAuthenticate::passwordChangeSuccessful, this, &PreferencesCloud::passwordUpdateSuccessful);
|
||||||
|
cloudAuth->backend(email, password, "", newpassword);
|
||||||
|
ui->cloud_storage_new_passwd->setText("");
|
||||||
|
}
|
||||||
|
} else if (prefs.cloud_verification_status == qPrefCloudStorage::CS_UNKNOWN ||
|
||||||
|
prefs.cloud_verification_status == qPrefCloudStorage::CS_INCORRECT_USER_PASSWD ||
|
||||||
|
email != prefs.cloud_storage_email ||
|
||||||
|
password != prefs.cloud_storage_password) {
|
||||||
|
|
||||||
|
// different credentials - reset verification status
|
||||||
|
int oldVerificationStatus = cloud->cloud_verification_status();
|
||||||
|
cloud->set_cloud_verification_status(qPrefCloudStorage::CS_UNKNOWN);
|
||||||
|
if (!email.isEmpty() && !password.isEmpty()) {
|
||||||
|
// 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 '+'.")));
|
||||||
|
cloud->set_cloud_verification_status(oldVerificationStatus);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
|
||||||
|
connect(cloudAuth, &CloudStorageAuthenticate::finishedAuthenticate, this, &PreferencesCloud::updateCloudAuthenticationState);
|
||||||
|
cloudAuth->backend(email, password);
|
||||||
|
}
|
||||||
|
} else if (prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY) {
|
||||||
|
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 '+'.")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
|
||||||
|
connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(updateCloudAuthenticationState()));
|
||||||
|
cloudAuth->backend(email, password, pin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cloud->set_cloud_storage_email(email);
|
||||||
|
cloud->set_save_password_local(ui->save_password_local->isChecked());
|
||||||
|
cloud->set_cloud_storage_password(password);
|
||||||
|
cloud->set_cloud_verification_status(prefs.cloud_verification_status);
|
||||||
|
cloud->set_cloud_base_url(prefs.cloud_base_url);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesCloud::updateCloudAuthenticationState()
|
||||||
|
{
|
||||||
|
ui->cloud_storage_pin->setEnabled(prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY);
|
||||||
|
ui->cloud_storage_pin->setVisible(prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY);
|
||||||
|
ui->cloud_storage_pin_label->setEnabled(prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY);
|
||||||
|
ui->cloud_storage_pin_label->setVisible(prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY);
|
||||||
|
ui->cloud_storage_new_passwd->setEnabled(prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED);
|
||||||
|
ui->cloud_storage_new_passwd->setVisible(prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED);
|
||||||
|
ui->cloud_storage_new_passwd_label->setEnabled(prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED);
|
||||||
|
ui->cloud_storage_new_passwd_label->setVisible(prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED);
|
||||||
|
if (prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED) {
|
||||||
|
ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (credentials verified)"));
|
||||||
|
} else if (prefs.cloud_verification_status == qPrefCloudStorage::CS_INCORRECT_USER_PASSWD) {
|
||||||
|
ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (incorrect password)"));
|
||||||
|
} else if (prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY) {
|
||||||
|
ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (PIN required)"));
|
||||||
|
} else {
|
||||||
|
ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage"));
|
||||||
|
}
|
||||||
|
emit settingsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesCloud::passwordUpdateSuccessful()
|
||||||
|
{
|
||||||
|
ui->cloud_storage_password->setText(prefs.cloud_storage_password);
|
||||||
|
}
|
28
desktop-widgets/preferences/preferences_cloud.h
Normal file
28
desktop-widgets/preferences/preferences_cloud.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
|
#ifndef PREFERENCES_CLOUD_H
|
||||||
|
#define PREFERENCES_CLOUD_H
|
||||||
|
|
||||||
|
#include "abstractpreferenceswidget.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class PreferencesCloud;
|
||||||
|
}
|
||||||
|
|
||||||
|
class PreferencesCloud : public AbstractPreferencesWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
PreferencesCloud();
|
||||||
|
~PreferencesCloud();
|
||||||
|
void refreshSettings() override;
|
||||||
|
void syncSettings() override;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void updateCloudAuthenticationState();
|
||||||
|
void passwordUpdateSuccessful();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::PreferencesCloud *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
165
desktop-widgets/preferences/preferences_cloud.ui
Normal file
165
desktop-widgets/preferences/preferences_cloud.ui
Normal file
|
@ -0,0 +1,165 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>PreferencesCloud</class>
|
||||||
|
<widget class="QWidget" name="PreferencesCloud">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>713</width>
|
||||||
|
<height>558</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="cloudStorageGroupBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>129</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Subsurface cloud storage</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_16b">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string extracomment="Email address used for the Subsurface cloud storage infrastructure"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Email address</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="label_16c">
|
||||||
|
<property name="text">
|
||||||
|
<string>Password</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QLabel" name="cloud_storage_pin_label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Verification PIN</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QLabel" name="cloud_storage_new_passwd_label">
|
||||||
|
<property name="text">
|
||||||
|
<string>New password</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLineEdit" name="cloud_storage_email">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string extracomment="Email address used for the Subsurface cloud storage infrastructure"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="cloud_storage_password">
|
||||||
|
<property name="echoMode">
|
||||||
|
<enum>QLineEdit::Password</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QLineEdit" name="cloud_storage_pin">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string extracomment="One time verification PIN for Subsurface cloud storage infrastructure"/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="3">
|
||||||
|
<widget class="QLineEdit" name="cloud_storage_new_passwd">
|
||||||
|
<property name="echoMode">
|
||||||
|
<enum>QLineEdit::Password</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QCheckBox" name="save_password_local">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save Password locally?</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_help1">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string extracomment="Help info 1"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>To create a new cloud account:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="label_help2">
|
||||||
|
<property name="toolTip">
|
||||||
|
<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>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QLabel" name="label_help3">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string extracomment="Help info 1"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>2) The server responds by sending a verification PIN to the above email address (This is the only occasion that Subsurface uses the email address provided above). The above dialog now has a new PIN text box, not visible previously.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QLabel" name="label_help4">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string extracomment="Help info 1"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>3) Enter the PIN in the corresponding text box in the above dialog (this field is only visible while the server is waiting for email address confirmation). Click Apply again. The Subsurface cloud storage account will be marked as verified and the Subsurface cloud storage service is initialised for use.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
|
||||||
|
<connections>
|
||||||
|
|
||||||
|
</connections>
|
||||||
|
|
||||||
|
</ui>
|
|
@ -2,9 +2,7 @@
|
||||||
#include "preferences_network.h"
|
#include "preferences_network.h"
|
||||||
#include "ui_preferences_network.h"
|
#include "ui_preferences_network.h"
|
||||||
#include "subsurfacewebservices.h"
|
#include "subsurfacewebservices.h"
|
||||||
#include "core/cloudstorage.h"
|
|
||||||
#include "core/errorhelper.h"
|
#include "core/errorhelper.h"
|
||||||
#include "core/settings/qPrefCloudStorage.h"
|
|
||||||
#include "core/settings/qPrefProxy.h"
|
#include "core/settings/qPrefProxy.h"
|
||||||
#include <QNetworkProxy>
|
#include <QNetworkProxy>
|
||||||
|
|
||||||
|
@ -35,15 +33,10 @@ void PreferencesNetwork::refreshSettings()
|
||||||
ui->proxyUsername->setText(prefs.proxy_user);
|
ui->proxyUsername->setText(prefs.proxy_user);
|
||||||
ui->proxyPassword->setText(prefs.proxy_pass);
|
ui->proxyPassword->setText(prefs.proxy_pass);
|
||||||
ui->proxyType->setCurrentIndex(ui->proxyType->findData(prefs.proxy_type));
|
ui->proxyType->setCurrentIndex(ui->proxyType->findData(prefs.proxy_type));
|
||||||
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);
|
|
||||||
updateCloudAuthenticationState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesNetwork::syncSettings()
|
void PreferencesNetwork::syncSettings()
|
||||||
{
|
{
|
||||||
auto cloud = qPrefCloudStorage::instance();
|
|
||||||
auto proxy = qPrefProxy::instance();
|
auto proxy = qPrefProxy::instance();
|
||||||
|
|
||||||
proxy->set_proxy_type(ui->proxyType->itemData(ui->proxyType->currentIndex()).toInt());
|
proxy->set_proxy_type(ui->proxyType->itemData(ui->proxyType->currentIndex()).toInt());
|
||||||
|
@ -52,94 +45,8 @@ void PreferencesNetwork::syncSettings()
|
||||||
proxy->set_proxy_auth(ui->proxyAuthRequired->isChecked());
|
proxy->set_proxy_auth(ui->proxyAuthRequired->isChecked());
|
||||||
proxy->set_proxy_user(ui->proxyUsername->text());
|
proxy->set_proxy_user(ui->proxyUsername->text());
|
||||||
proxy->set_proxy_pass(ui->proxyPassword->text());
|
proxy->set_proxy_pass(ui->proxyPassword->text());
|
||||||
|
|
||||||
QString email = ui->cloud_storage_email->text().toLower();
|
|
||||||
QString password = ui->cloud_storage_password->text();
|
|
||||||
QString newpassword = ui->cloud_storage_new_passwd->text();
|
|
||||||
|
|
||||||
//TODO: Change this to the Cloud Storage Stuff, not preferences.
|
|
||||||
if (prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED && !newpassword.isEmpty()) {
|
|
||||||
// deal with password change
|
|
||||||
if (!email.isEmpty() && !password.isEmpty()) {
|
|
||||||
// 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 '+'.")));
|
|
||||||
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 '+'.")));
|
|
||||||
ui->cloud_storage_new_passwd->setText("");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
|
|
||||||
connect(cloudAuth, &CloudStorageAuthenticate::finishedAuthenticate, this, &PreferencesNetwork::updateCloudAuthenticationState);
|
|
||||||
connect(cloudAuth, &CloudStorageAuthenticate::passwordChangeSuccessful, this, &PreferencesNetwork::passwordUpdateSuccessful);
|
|
||||||
cloudAuth->backend(email, password, "", newpassword);
|
|
||||||
ui->cloud_storage_new_passwd->setText("");
|
|
||||||
}
|
|
||||||
} else if (prefs.cloud_verification_status == qPrefCloudStorage::CS_UNKNOWN ||
|
|
||||||
prefs.cloud_verification_status == qPrefCloudStorage::CS_INCORRECT_USER_PASSWD ||
|
|
||||||
email != prefs.cloud_storage_email ||
|
|
||||||
password != prefs.cloud_storage_password) {
|
|
||||||
|
|
||||||
// different credentials - reset verification status
|
|
||||||
int oldVerificationStatus = cloud->cloud_verification_status();
|
|
||||||
cloud->set_cloud_verification_status(qPrefCloudStorage::CS_UNKNOWN);
|
|
||||||
if (!email.isEmpty() && !password.isEmpty()) {
|
|
||||||
// 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 '+'.")));
|
|
||||||
cloud->set_cloud_verification_status(oldVerificationStatus);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
|
|
||||||
connect(cloudAuth, &CloudStorageAuthenticate::finishedAuthenticate, this, &PreferencesNetwork::updateCloudAuthenticationState);
|
|
||||||
cloudAuth->backend(email, password);
|
|
||||||
}
|
|
||||||
} else if (prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY) {
|
|
||||||
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 '+'.")));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
|
|
||||||
connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(updateCloudAuthenticationState()));
|
|
||||||
cloudAuth->backend(email, password, pin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cloud->set_cloud_storage_email(email);
|
|
||||||
cloud->set_save_password_local(ui->save_password_local->isChecked());
|
|
||||||
cloud->set_cloud_storage_password(password);
|
|
||||||
cloud->set_cloud_verification_status(prefs.cloud_verification_status);
|
|
||||||
cloud->set_cloud_base_url(prefs.cloud_base_url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesNetwork::updateCloudAuthenticationState()
|
|
||||||
{
|
|
||||||
ui->cloud_storage_pin->setEnabled(prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY);
|
|
||||||
ui->cloud_storage_pin->setVisible(prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY);
|
|
||||||
ui->cloud_storage_pin_label->setEnabled(prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY);
|
|
||||||
ui->cloud_storage_pin_label->setVisible(prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY);
|
|
||||||
ui->cloud_storage_new_passwd->setEnabled(prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED);
|
|
||||||
ui->cloud_storage_new_passwd->setVisible(prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED);
|
|
||||||
ui->cloud_storage_new_passwd_label->setEnabled(prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED);
|
|
||||||
ui->cloud_storage_new_passwd_label->setVisible(prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED);
|
|
||||||
if (prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED) {
|
|
||||||
ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (credentials verified)"));
|
|
||||||
} else if (prefs.cloud_verification_status == qPrefCloudStorage::CS_INCORRECT_USER_PASSWD) {
|
|
||||||
ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (incorrect password)"));
|
|
||||||
} else if (prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY) {
|
|
||||||
ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (PIN required)"));
|
|
||||||
} else {
|
|
||||||
ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage"));
|
|
||||||
}
|
|
||||||
emit settingsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PreferencesNetwork::proxyType_changed(int idx)
|
void PreferencesNetwork::proxyType_changed(int idx)
|
||||||
{
|
{
|
||||||
|
@ -157,7 +64,3 @@ void PreferencesNetwork::proxyType_changed(int idx)
|
||||||
ui->proxyAuthRequired->setChecked(ui->proxyAuthRequired->isChecked());
|
ui->proxyAuthRequired->setChecked(ui->proxyAuthRequired->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesNetwork::passwordUpdateSuccessful()
|
|
||||||
{
|
|
||||||
ui->cloud_storage_password->setText(prefs.cloud_storage_password);
|
|
||||||
}
|
|
||||||
|
|
|
@ -19,8 +19,6 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void proxyType_changed(int i);
|
void proxyType_changed(int i);
|
||||||
void updateCloudAuthenticationState();
|
|
||||||
void passwordUpdateSuccessful();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::PreferencesNetwork *ui;
|
Ui::PreferencesNetwork *ui;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_10">
|
<widget class="QGroupBox" name="groupBox_10">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Proxy</string>
|
<string>If your Internet access is through a proxy server, provide details for using that proxy</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
|
@ -138,93 +138,6 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="cloudStorageGroupBox">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>129</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="title">
|
|
||||||
<string>Subsurface cloud storage</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label_16b">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string extracomment="Email address used for the Subsurface cloud storage infrastructure"/>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Email address</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QLabel" name="label_16c">
|
|
||||||
<property name="text">
|
|
||||||
<string>Password</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QLabel" name="cloud_storage_pin_label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Verification PIN</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="3">
|
|
||||||
<widget class="QLabel" name="cloud_storage_new_passwd_label">
|
|
||||||
<property name="text">
|
|
||||||
<string>New password</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLineEdit" name="cloud_storage_email">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string extracomment="Email address used for the Subsurface cloud storage infrastructure"/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QLineEdit" name="cloud_storage_password">
|
|
||||||
<property name="echoMode">
|
|
||||||
<enum>QLineEdit::Password</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="2">
|
|
||||||
<widget class="QLineEdit" name="cloud_storage_pin">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string extracomment="One time verification PIN for Subsurface cloud storage infrastructure"/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="3">
|
|
||||||
<widget class="QLineEdit" name="cloud_storage_new_passwd">
|
|
||||||
<property name="echoMode">
|
|
||||||
<enum>QLineEdit::Password</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QCheckBox" name="save_password_local">
|
|
||||||
<property name="text">
|
|
||||||
<string>Save Password locally?</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "preferences_units.h"
|
#include "preferences_units.h"
|
||||||
#include "preferences_graph.h"
|
#include "preferences_graph.h"
|
||||||
#include "preferences_network.h"
|
#include "preferences_network.h"
|
||||||
|
#include "preferences_cloud.h"
|
||||||
|
|
||||||
#include "core/qthelper.h"
|
#include "core/qthelper.h"
|
||||||
|
|
||||||
|
@ -65,6 +66,7 @@ PreferencesDialog::PreferencesDialog()
|
||||||
addPreferencePage(new PreferencesUnits());
|
addPreferencePage(new PreferencesUnits());
|
||||||
addPreferencePage(new PreferencesGraph());
|
addPreferencePage(new PreferencesGraph());
|
||||||
addPreferencePage(new PreferencesNetwork());
|
addPreferencePage(new PreferencesNetwork());
|
||||||
|
addPreferencePage(new PreferencesCloud());
|
||||||
refreshPages();
|
refreshPages();
|
||||||
|
|
||||||
connect(pagesList, &QListWidget::currentRowChanged,
|
connect(pagesList, &QListWidget::currentRowChanged,
|
||||||
|
|
BIN
icons/pref_cloud.png
Normal file
BIN
icons/pref_cloud.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 449 B |
BIN
icons/pref_tech.png
Normal file
BIN
icons/pref_tech.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 712 B |
|
@ -1,7 +1,7 @@
|
||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file alias="satellite-icon">icons/satellite.svg</file>
|
<file alias="satellite-icon">icons/satellite.svg</file>
|
||||||
<file alias="graph-icon">icons/graph.png</file>
|
<file alias="graph-icon">icons/pref_tech.png</file>
|
||||||
<file alias="hide-icon">icons/go-top.svg</file>
|
<file alias="hide-icon">icons/go-top.svg</file>
|
||||||
<file alias="star-icon">icons/star.svg</file>
|
<file alias="star-icon">icons/star.svg</file>
|
||||||
<file alias="subsurface-icon">icons/subsurface-icon.png</file>
|
<file alias="subsurface-icon">icons/subsurface-icon.png</file>
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
<file alias="units-icon">icons/units.png</file>
|
<file alias="units-icon">icons/units.png</file>
|
||||||
<file alias="advanced-icon">icons/advanced.png</file>
|
<file alias="advanced-icon">icons/advanced.png</file>
|
||||||
<file alias="preferences-system-network-icon">icons/network.png</file>
|
<file alias="preferences-system-network-icon">icons/network.png</file>
|
||||||
|
<file alias="preferences-cloud-icon">icons/pref_cloud.png</file>
|
||||||
<file alias="scale-graph-icon">icons/graph.png</file>
|
<file alias="scale-graph-icon">icons/graph.png</file>
|
||||||
<file alias="value-minimum-icon">icons/minimum.png</file>
|
<file alias="value-minimum-icon">icons/minimum.png</file>
|
||||||
<file alias="value-maximum-icon">icons/maximum.png</file>
|
<file alias="value-maximum-icon">icons/maximum.png</file>
|
||||||
|
|
Loading…
Add table
Reference in a new issue