desktop-widget: remove QSettings

Update desktop-widget to use qPrefDisplay (amended variable)

Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
jan Iversen 2018-08-18 20:00:55 +02:00 committed by Dirk Hohndel
parent 3436734bb9
commit c85f5c560c
2 changed files with 7 additions and 18 deletions

View file

@ -12,6 +12,7 @@
#include "desktop-widgets/subsurfacewebservices.h" #include "desktop-widgets/subsurfacewebservices.h"
#include "core/worldmap-save.h" #include "core/worldmap-save.h"
#include "core/save-html.h" #include "core/save-html.h"
#include "core/settings/qPrefDisplay.h"
#include "desktop-widgets/mainwindow.h" #include "desktop-widgets/mainwindow.h"
#include "profile-widget/profilewidget2.h" #include "profile-widget/profilewidget2.h"
#include "core/dive.h" // Allows access to helper functions in TeX export. #include "core/dive.h" // Allows access to helper functions in TeX export.
@ -121,15 +122,10 @@ void DiveLogExportDialog::on_buttonBox_accepted()
{ {
QString filename; QString filename;
QString stylesheet; QString stylesheet;
QSettings settings;
QString lastDir = QDir::homePath(); QString lastDir = QDir::homePath();
settings.beginGroup("FileDialog"); if (QDir(qPrefDisplay::lastDir()).exists())
if (settings.contains("LastDir")) { lastDir = qPrefDisplay::lastDir();
if (QDir(settings.value("LastDir").toString()).exists())
lastDir = settings.value("LastDir").toString();
}
settings.endGroup();
switch (ui->tabWidget->currentIndex()) { switch (ui->tabWidget->currentIndex()) {
case 0: case 0:
@ -184,9 +180,7 @@ void DiveLogExportDialog::on_buttonBox_accepted()
if (!filename.isNull() && !filename.isEmpty()) { if (!filename.isNull() && !filename.isEmpty()) {
// remember the last export path // remember the last export path
QFileInfo fileInfo(filename); QFileInfo fileInfo(filename);
settings.beginGroup("FileDialog"); qPrefDisplay::set_lastDir(fileInfo.dir().path());
settings.setValue("LastDir", fileInfo.dir().path());
settings.endGroup();
// the non XSLT exports are called directly above, the XSLT based ons are called here // the non XSLT exports are called directly above, the XSLT based ons are called here
if (!stylesheet.isEmpty()) { if (!stylesheet.isEmpty()) {
future = QtConcurrent::run(export_dives_xslt, filename.toUtf8(), ui->exportSelected->isChecked(), ui->CSVUnits_2->currentIndex(), stylesheet.toUtf8()); future = QtConcurrent::run(export_dives_xslt, filename.toUtf8(), ui->exportSelected->isChecked(), ui->CSVUnits_2->currentIndex(), stylesheet.toUtf8());

View file

@ -549,13 +549,10 @@ void MainWindow::on_actionNew_triggered()
static QString lastUsedDir() static QString lastUsedDir()
{ {
QSettings settings;
QString lastDir = QDir::homePath(); QString lastDir = QDir::homePath();
settings.beginGroup("FileDialog"); if (QDir(qPrefDisplay::lastDir()).exists())
if (settings.contains("LastDir")) lastDir = qPrefDisplay::lastDir();
if (QDir(settings.value("LastDir").toString()).exists())
lastDir = settings.value("LastDir").toString();
return lastDir; return lastDir;
} }
@ -773,9 +770,7 @@ void MainWindow::on_actionClose_triggered()
void MainWindow::updateLastUsedDir(const QString &dir) void MainWindow::updateLastUsedDir(const QString &dir)
{ {
QSettings s; qPrefDisplay::set_lastDir(dir);
s.beginGroup("FileDialog");
s.setValue("LastDir", dir);
} }
void MainWindow::on_actionPrint_triggered() void MainWindow::on_actionPrint_triggered()