desktop-widgets: use qPrefCloudStorage instead of QSettings

Use qPrefCloudStorage for divelogde_user/password to secure same
handling as other settings, as well as same handling as used in
shared uploadDiveLogsDE class

Signed-off-by: Jan Iversen <jan@casacondor.com>
This commit is contained in:
jan Iversen 2019-12-09 11:47:59 +01:00 committed by Dirk Hohndel
parent fba3e5115a
commit 2f680c1f76

View file

@ -16,11 +16,11 @@
#include "core/cloudstorage.h" #include "core/cloudstorage.h"
#include "core/subsurface-string.h" #include "core/subsurface-string.h"
#include "core/uploadDiveLogsDE.h" #include "core/uploadDiveLogsDE.h"
#include "core/settings/qPrefCloudStorage.h"
#include <QDir> #include <QDir>
#include <QHttpMultiPart> #include <QHttpMultiPart>
#include <QMessageBox> #include <QMessageBox>
#include <QSettings>
#include <QXmlStreamReader> #include <QXmlStreamReader>
#include <qdesktopservices.h> #include <qdesktopservices.h>
#include <QShortcut> #include <QShortcut>
@ -291,9 +291,8 @@ DivelogsDeWebServices::DivelogsDeWebServices(QWidget *parent, Qt::WindowFlags f)
uploadMode(false) uploadMode(false)
{ {
// should DivelogDE user and pass be stored in the prefs struct or something? // should DivelogDE user and pass be stored in the prefs struct or something?
QSettings s; ui.userID->setText(qPrefCloudStorage::divelogde_user());
ui.userID->setText(s.value("divelogde_user").toString()); ui.password->setText(qPrefCloudStorage::divelogde_pass());
ui.password->setText(s.value("divelogde_pass").toString());
ui.saveUidLocal->hide(); ui.saveUidLocal->hide();
hideUpload(); hideUpload();
QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this); QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this);
@ -304,10 +303,8 @@ DivelogsDeWebServices::DivelogsDeWebServices(QWidget *parent, Qt::WindowFlags f)
void DivelogsDeWebServices::startUpload() void DivelogsDeWebServices::startUpload()
{ {
QSettings s; qPrefCloudStorage::set_divelogde_user(ui.userID->text());
s.setValue("divelogde_user", ui.userID->text()); qPrefCloudStorage::set_divelogde_pass(ui.password->text());
s.setValue("divelogde_pass", ui.password->text());
s.sync();
ui.status->setText(tr("Uploading dive list...")); ui.status->setText(tr("Uploading dive list..."));
ui.progressBar->setRange(0, 0); // this makes the progressbar do an 'infinite spin' ui.progressBar->setRange(0, 0); // this makes the progressbar do an 'infinite spin'
@ -530,10 +527,8 @@ void DivelogsDeWebServices::buttonClicked(QAbstractButton *button)
Command::importDives(&table, &trips, &sites, IMPORT_MERGE_ALL_TRIPS, QStringLiteral("divelogs.de")); Command::importDives(&table, &trips, &sites, IMPORT_MERGE_ALL_TRIPS, QStringLiteral("divelogs.de"));
/* store last entered user/pass in config */ /* store last entered user/pass in config */
QSettings s; qPrefCloudStorage::set_divelogde_user(ui.userID->text());
s.setValue("divelogde_user", ui.userID->text()); qPrefCloudStorage::set_divelogde_pass(ui.password->text());
s.setValue("divelogde_pass", ui.password->text());
s.sync();
hide(); hide();
close(); close();
resetState(); resetState();