mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-31 09:05:14 +01:00
Fixed options/settings handling isses.
This commit is contained in:
parent
4cf027df58
commit
34e48199b2
36
src/gui.cpp
36
src/gui.cpp
@ -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,6 +1270,8 @@ void GUI::writeSettings()
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
|
||||
if ((_imperialUnitsAction->isChecked() ? Imperial : Metric) !=
|
||||
UNITS_DEFAULT)
|
||||
settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked()
|
||||
? Imperial : Metric);
|
||||
if (_showToolbarsAction->isChecked() != SHOW_TOOLBARS_DEFAULT)
|
||||
@ -1302,14 +1303,16 @@ 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));
|
||||
}
|
||||
}
|
||||
if (j != 0)
|
||||
settings.endArray();
|
||||
settings.endGroup();
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user