1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-31 00:55:13 +01:00

Fixed options/settings handling isses.

This commit is contained in:
Martin Tůma 2016-12-06 21:02:44 +01:00
parent 4cf027df58
commit 34e48199b2
4 changed files with 56 additions and 23 deletions

View File

@ -70,6 +70,7 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
setWindowIcon(QIcon(QPixmap(APP_ICON)));
setWindowTitle(APP_NAME);
setUnifiedTitleAndToolBarOnMac(true);
setAcceptDrops(true);
_trackCount = 0;
_routeCount = 0;
@ -85,8 +86,6 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
updateStatusBarInfo();
readSettings();
setAcceptDrops(true);
}
GUI::~GUI()
@ -1271,7 +1270,9 @@ void GUI::writeSettings()
settings.endGroup();
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked()
if ((_imperialUnitsAction->isChecked() ? Imperial : Metric) !=
UNITS_DEFAULT)
settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked()
? Imperial : Metric);
if (_showToolbarsAction->isChecked() != SHOW_TOOLBARS_DEFAULT)
settings.setValue(SHOW_TOOLBARS_SETTING,
@ -1302,15 +1303,17 @@ void GUI::writeSettings()
if (_overlapPOIAction->isChecked() != OVERLAP_POI_DEFAULT)
settings.setValue(OVERLAP_POI_SETTING, _overlapPOIAction->isChecked());
settings.remove(DISABLED_POI_FILE_SETTINGS_PREFIX);
settings.beginWriteArray(DISABLED_POI_FILE_SETTINGS_PREFIX);
for (int i = 0, j = 0; i < _poiFilesActions.count(); i++) {
int j = 0;
for (int i = 0; i < _poiFilesActions.count(); i++) {
if (!_poiFilesActions.at(i)->isChecked()) {
if (j == 0)
settings.beginWriteArray(DISABLED_POI_FILE_SETTINGS_PREFIX);
settings.setArrayIndex(j++);
settings.setValue(DISABLED_POI_FILE_SETTING, _poi->files().at(i));
}
}
settings.endArray();
if (j != 0)
settings.endArray();
settings.endGroup();
settings.beginGroup(DATA_SETTINGS_GROUP);
@ -1513,16 +1516,35 @@ void GUI::readSettings()
(int)TRACK_STYLE_DEFAULT).toInt();
_options.routeStyle = (Qt::PenStyle) settings.value(ROUTE_STYLE_SETTING,
(int)ROUTE_STYLE_DEFAULT).toInt();
_options.graphWidth = settings.value(GRAPH_WIDTH_SETTING,
GRAPH_WIDTH_DEFAULT).toInt();
_options.pathAntiAliasing = settings.value(PATH_AA_SETTING, PATH_AA_DEFAULT)
.toBool();
_options.graphWidth = settings.value(GRAPH_WIDTH_SETTING,
GRAPH_WIDTH_DEFAULT).toInt();
_options.graphAntiAliasing = settings.value(GRAPH_AA_SETTING,
GRAPH_AA_DEFAULT).toBool();
_options.poiRadius = settings.value(POI_RADIUS_SETTING, POI_RADIUS_DEFAULT)
.toInt();
_options.useOpenGL = settings.value(USE_OPENGL_SETTING, USE_OPENGL_DEFAULT)
.toBool();
_pathView->setPalette(_options.palette);
_pathView->setTrackWidth(_options.trackWidth);
_pathView->setRouteWidth(_options.routeWidth);
_pathView->setTrackStyle(_options.trackStyle);
_pathView->setRouteStyle(_options.routeStyle);
_pathView->setRenderHint(QPainter::Antialiasing, _options.pathAntiAliasing);
if (_options.useOpenGL)
_pathView->useOpenGL(true);
for (int i = 0; i < _tabs.count(); i++) {
_tabs.at(i)->setPalette(_options.palette);
_tabs.at(i)->setGraphWidth(_options.graphWidth);
_tabs.at(i)->setRenderHint(QPainter::Antialiasing,
_options.graphAntiAliasing);
}
_poi->setRadius(_options.poiRadius);
settings.endGroup();
}

View File

@ -36,3 +36,11 @@ void Palette::reset()
{
_state = _h;
}
QDebug operator<<(QDebug dbg, const Palette &palette)
{
dbg.nospace() << "Palette(" << palette.color() << ", " << palette.shift()
<< ")";
return dbg.maybeSpace();
}

View File

@ -2,13 +2,14 @@
#define PALETTE_H
#include <QColor>
#include <QDebug>
class Palette
{
public:
Palette(const QColor &color = Qt::blue, qreal shift = 0.62);
QColor color() const {return QColor::fromHsvF(_h, _s, _v, _a);}
QColor color() const {return QColor::fromHsvF(_h, _s, _v, _a).toRgb();}
qreal shift() const {return _shift;}
void setColor(const QColor &color);
void setShift(qreal shift);
@ -27,4 +28,6 @@ private:
qreal _state;
};
QDebug operator<<(QDebug dbg, const Palette &palette);
#endif // PALLETE_H

View File

@ -1,6 +1,9 @@
#ifndef SETTINGS_H
#define SETTINGS_H
#define IMPERIAL_UNITS() \
(QLocale::system().measurementSystem() == QLocale::ImperialSystem)
#define WINDOW_SETTINGS_GROUP "Window"
#define WINDOW_SIZE_SETTING "size"
#define WINDOW_SIZE_DEFAULT QSize(600, 800)
@ -9,9 +12,7 @@
#define SETTINGS_SETTINGS_GROUP "Settings"
#define UNITS_SETTING "units"
#define UNITS_DEFAULT \
(QLocale::system().measurementSystem() == QLocale::ImperialSystem) \
? Imperial : Metric
#define UNITS_DEFAULT (IMPERIAL_UNITS() ? Imperial : Metric)
#define SHOW_TOOLBARS_SETTING "toolbar"
#define SHOW_TOOLBARS_DEFAULT true
@ -54,20 +55,19 @@
#define PAPER_ORIENTATION_SETTING "orientation"
#define PAPER_ORIENTATION_DEFAULT QPrinter::Portrait
#define PAPER_SIZE_SETTING "size"
#define PAPER_SIZE_DEFAULT \
(QLocale::system().measurementSystem() == QLocale::ImperialSystem) \
? QPrinter::Letter : QPrinter::A4
#define PAPER_SIZE_DEFAULT (IMPERIAL_UNITS() ? QPrinter::Letter \
: QPrinter::A4)
#define MARGIN_LEFT_SETTING "marginLeft"
#define MARGIN_LEFT_DEFAULT 5
#define MARGIN_LEFT_DEFAULT 5 /* mm */
#define MARGIN_TOP_SETTING "marginTop"
#define MARGIN_TOP_DEFAULT 5
#define MARGIN_TOP_DEFAULT 5 /* mm */
#define MARGIN_RIGHT_SETTING "marginRight"
#define MARGIN_RIGHT_DEFAULT 5
#define MARGIN_RIGHT_DEFAULT 5 /* mm */
#define MARGIN_BOTTOM_SETTING "marginBottom"
#define MARGIN_BOTTOM_DEFAULT 5
#define MARGIN_BOTTOM_DEFAULT 5 /* mm */
#define EXPORT_FILENAME_SETTING "fileName"
#define EXPORT_FILENAME_DEFAULT \
QString("%1/export.pdf").arg(QDir::currentPath())
#define EXPORT_FILENAME_DEFAULT QString("%1/export.pdf"). \
arg(QDir::currentPath())
#define OPTIONS_SETTINGS_GROUP "Options"
#define PALETTE_COLOR_SETTING "paletteColor"
@ -89,7 +89,7 @@
#define GRAPH_AA_SETTING "graphAntiAliasing"
#define GRAPH_AA_DEFAULT false
#define POI_RADIUS_SETTING "poiRadius"
#define POI_RADIUS_DEFAULT 1000
#define POI_RADIUS_DEFAULT 1000 /* m */
#define USE_OPENGL_SETTING "useOpenGL"
#define USE_OPENGL_DEFAULT false