mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-02-17 16:20:48 +01:00
More permanent settings
This commit is contained in:
parent
c997694e10
commit
4c61e208ed
@ -7,7 +7,6 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#define APP_NAME "GPXSee"
|
#define APP_NAME "GPXSee"
|
||||||
#define APP_VENDOR "Martin Tuma"
|
|
||||||
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
|
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
|
||||||
#define APP_VERSION "2.12"
|
#define APP_VERSION "2.12"
|
||||||
|
|
||||||
|
53
src/gui.cpp
53
src/gui.cpp
@ -142,9 +142,6 @@ void GUI::createMapActions()
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect(sm, SIGNAL(mapped(int)), this, SLOT(mapChanged(int)));
|
connect(sm, SIGNAL(mapped(int)), this, SLOT(mapChanged(int)));
|
||||||
|
|
||||||
_mapActions.at(0)->setChecked(true);
|
|
||||||
_currentMap = _maps.at(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::createPOIFilesActions()
|
void GUI::createPOIFilesActions()
|
||||||
@ -258,7 +255,6 @@ void GUI::createActions()
|
|||||||
_clearMapCacheAction->setEnabled(false);
|
_clearMapCacheAction->setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
createMapActions();
|
createMapActions();
|
||||||
_showMapAction->setChecked(true);
|
|
||||||
|
|
||||||
_nextMapAction = new QAction(tr("Next map"), this);
|
_nextMapAction = new QAction(tr("Next map"), this);
|
||||||
_nextMapAction->setShortcut(NEXT_MAP_SHORTCUT);
|
_nextMapAction->setShortcut(NEXT_MAP_SHORTCUT);
|
||||||
@ -401,9 +397,6 @@ void GUI::createTrackView()
|
|||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
_track->setFrameShape(QFrame::NoFrame);
|
_track->setFrameShape(QFrame::NoFrame);
|
||||||
#endif // Q_OS_WIN32
|
#endif // Q_OS_WIN32
|
||||||
|
|
||||||
if (_showMapAction->isChecked())
|
|
||||||
_track->setMap(_currentMap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::createTrackGraphs()
|
void GUI::createTrackGraphs()
|
||||||
@ -1069,7 +1062,7 @@ void GUI::closeEvent(QCloseEvent *event)
|
|||||||
|
|
||||||
void GUI::writeSettings()
|
void GUI::writeSettings()
|
||||||
{
|
{
|
||||||
QSettings settings(APP_VENDOR, APP_NAME);
|
QSettings settings(APP_NAME, APP_NAME);
|
||||||
|
|
||||||
settings.beginGroup("Window");
|
settings.beginGroup("Window");
|
||||||
settings.setValue("size", size());
|
settings.setValue("size", size());
|
||||||
@ -1082,11 +1075,20 @@ void GUI::writeSettings()
|
|||||||
settings.setValue("toolbar", _showToolbarsAction->isChecked());
|
settings.setValue("toolbar", _showToolbarsAction->isChecked());
|
||||||
settings.setValue("graphs", _showGraphsAction->isChecked());
|
settings.setValue("graphs", _showGraphsAction->isChecked());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
|
settings.beginGroup("Map");
|
||||||
|
settings.setValue("map", _currentMap->name());
|
||||||
|
settings.setValue("show", _showMapAction->isChecked());
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
settings.beginGroup("POI");
|
||||||
|
settings.setValue("show", _showPOIAction->isChecked());
|
||||||
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::readSettings()
|
void GUI::readSettings()
|
||||||
{
|
{
|
||||||
QSettings settings(APP_VENDOR, APP_NAME);
|
QSettings settings(APP_NAME, APP_NAME);
|
||||||
|
|
||||||
settings.beginGroup("Window");
|
settings.beginGroup("Window");
|
||||||
resize(settings.value("size", QSize(600, 800)).toSize());
|
resize(settings.value("size", QSize(600, 800)).toSize());
|
||||||
@ -1094,20 +1096,47 @@ void GUI::readSettings()
|
|||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup("Settings");
|
settings.beginGroup("Settings");
|
||||||
if (settings.value("units", Metric) == Imperial) {
|
if (settings.value("units", Metric).toInt() == Imperial) {
|
||||||
setImperialUnits();
|
setImperialUnits();
|
||||||
_imperialUnitsAction->setChecked(true);
|
_imperialUnitsAction->setChecked(true);
|
||||||
} else
|
} else
|
||||||
_metricUnitsAction->setChecked(true);
|
_metricUnitsAction->setChecked(true);
|
||||||
if (settings.value("toolbar", true) == false) {
|
if (settings.value("toolbar", true).toBool() == false) {
|
||||||
showToolbars(false);
|
showToolbars(false);
|
||||||
_showToolbarsAction->setChecked(false);
|
_showToolbarsAction->setChecked(false);
|
||||||
} else
|
} else
|
||||||
_showToolbarsAction->setChecked(true);
|
_showToolbarsAction->setChecked(true);
|
||||||
if (settings.value("graphs", true) == false) {
|
if (settings.value("graphs", true).toBool() == false) {
|
||||||
showGraphs(false);
|
showGraphs(false);
|
||||||
_showGraphsAction->setChecked(false);
|
_showGraphsAction->setChecked(false);
|
||||||
} else
|
} else
|
||||||
_showGraphsAction->setChecked(true);
|
_showGraphsAction->setChecked(true);
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
|
settings.beginGroup("Map");
|
||||||
|
if (settings.value("show", true).toBool() == true)
|
||||||
|
_showMapAction->setChecked(true);
|
||||||
|
if (_maps.count()) {
|
||||||
|
int index = mapIndex(settings.value("map").toString());
|
||||||
|
_mapActions.at(index)->setChecked(true);
|
||||||
|
_currentMap = _maps.at(index);
|
||||||
|
if (_showMapAction->isChecked())
|
||||||
|
_track->setMap(_currentMap);
|
||||||
|
} else
|
||||||
|
_currentMap = 0;
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
settings.beginGroup("POI");
|
||||||
|
if (settings.value("show", false).toBool() == true)
|
||||||
|
_showPOIAction->setChecked(true);
|
||||||
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
int GUI::mapIndex(const QString &name)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _maps.count(); i++)
|
||||||
|
if (_maps.at(i)->name() == name)
|
||||||
|
return i;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ private:
|
|||||||
void keyPressEvent(QKeyEvent * event);
|
void keyPressEvent(QKeyEvent * event);
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
|
int mapIndex(const QString &name);
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user