mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-18 19:52:09 +01:00
Added permanent settings
This commit is contained in:
parent
2e4aeb57a8
commit
a8d671556e
@ -7,6 +7,7 @@
|
||||
#include <QString>
|
||||
|
||||
#define APP_NAME "GPXSee"
|
||||
#define APP_VENDOR "Martin Tuma"
|
||||
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
|
||||
#define APP_VERSION "2.12"
|
||||
|
||||
|
59
src/gui.cpp
59
src/gui.cpp
@ -1,4 +1,4 @@
|
||||
#include <QApplication>
|
||||
#include <QApplication>
|
||||
#include <QVBoxLayout>
|
||||
#include <QMenuBar>
|
||||
#include <QStatusBar>
|
||||
@ -14,6 +14,7 @@
|
||||
#include <QActionGroup>
|
||||
#include <QAction>
|
||||
#include <QLabel>
|
||||
#include <QSettings>
|
||||
#include "config.h"
|
||||
#include "icons.h"
|
||||
#include "keys.h"
|
||||
@ -96,7 +97,7 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||
updateGraphTabs();
|
||||
updateTrackView();
|
||||
|
||||
resize(600, 800);
|
||||
readSettings();
|
||||
}
|
||||
|
||||
void GUI::loadMaps()
|
||||
@ -272,14 +273,12 @@ void GUI::createActions()
|
||||
// Settings actions
|
||||
_showGraphsAction = new QAction(tr("Show graphs"), this);
|
||||
_showGraphsAction->setCheckable(true);
|
||||
_showGraphsAction->setChecked(true);
|
||||
_showGraphsAction->setShortcut(SHOW_GRAPHS_SHORTCUT);
|
||||
connect(_showGraphsAction, SIGNAL(triggered(bool)), this,
|
||||
SLOT(showGraphs(bool)));
|
||||
addAction(_showGraphsAction);
|
||||
_showToolbarsAction = new QAction(tr("Show toolbars"), this);
|
||||
_showToolbarsAction->setCheckable(true);
|
||||
_showToolbarsAction->setChecked(true);
|
||||
connect(_showToolbarsAction, SIGNAL(triggered(bool)), this,
|
||||
SLOT(showToolbars(bool)));
|
||||
QActionGroup *ag = new QActionGroup(this);
|
||||
@ -287,7 +286,6 @@ void GUI::createActions()
|
||||
_metricUnitsAction = new QAction(tr("Metric"), this);
|
||||
_metricUnitsAction->setCheckable(true);
|
||||
_metricUnitsAction->setActionGroup(ag);
|
||||
_metricUnitsAction->setChecked(true);
|
||||
connect(_metricUnitsAction, SIGNAL(triggered()), this,
|
||||
SLOT(setMetricUnits()));
|
||||
_imperialUnitsAction = new QAction(tr("Imperial"), this);
|
||||
@ -1062,3 +1060,54 @@ void GUI::keyPressEvent(QKeyEvent *event)
|
||||
openFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
writeSettings();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void GUI::writeSettings()
|
||||
{
|
||||
QSettings settings(APP_VENDOR, APP_NAME);
|
||||
|
||||
settings.beginGroup("Window");
|
||||
settings.setValue("size", size());
|
||||
settings.setValue("pos", pos());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("Settings");
|
||||
settings.setValue("units", _imperialUnitsAction->isChecked()
|
||||
? Imperial : Metric);
|
||||
settings.setValue("toolbar", _showToolbarsAction->isChecked());
|
||||
settings.setValue("graphs", _showGraphsAction->isChecked());
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void GUI::readSettings()
|
||||
{
|
||||
QSettings settings(APP_VENDOR, APP_NAME);
|
||||
|
||||
settings.beginGroup("Window");
|
||||
resize(settings.value("size", QSize(600, 800)).toSize());
|
||||
move(settings.value("pos", QPoint(10, 10)).toPoint());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("Settings");
|
||||
if (settings.value("units", Metric) == Imperial) {
|
||||
setImperialUnits();
|
||||
_imperialUnitsAction->setChecked(true);
|
||||
} else
|
||||
_metricUnitsAction->setChecked(true);
|
||||
if (settings.value("toolbar", true) == false) {
|
||||
showToolbars(false);
|
||||
_showToolbarsAction->setChecked(false);
|
||||
} else
|
||||
_showToolbarsAction->setChecked(true);
|
||||
if (settings.value("graphs", true) == false) {
|
||||
showGraphs(false);
|
||||
_showGraphsAction->setChecked(false);
|
||||
} else
|
||||
_showGraphsAction->setChecked(true);
|
||||
settings.endGroup();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user