mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-31 09:05:14 +01:00
Added permanent settings
This commit is contained in:
parent
2e4aeb57a8
commit
a8d671556e
@ -7,6 +7,7 @@
|
|||||||
#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"
|
||||||
|
|
||||||
|
59
src/gui.cpp
59
src/gui.cpp
@ -1,4 +1,4 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
@ -14,6 +14,7 @@
|
|||||||
#include <QActionGroup>
|
#include <QActionGroup>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QSettings>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "icons.h"
|
#include "icons.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
@ -96,7 +97,7 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
|||||||
updateGraphTabs();
|
updateGraphTabs();
|
||||||
updateTrackView();
|
updateTrackView();
|
||||||
|
|
||||||
resize(600, 800);
|
readSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::loadMaps()
|
void GUI::loadMaps()
|
||||||
@ -272,14 +273,12 @@ void GUI::createActions()
|
|||||||
// Settings actions
|
// Settings actions
|
||||||
_showGraphsAction = new QAction(tr("Show graphs"), this);
|
_showGraphsAction = new QAction(tr("Show graphs"), this);
|
||||||
_showGraphsAction->setCheckable(true);
|
_showGraphsAction->setCheckable(true);
|
||||||
_showGraphsAction->setChecked(true);
|
|
||||||
_showGraphsAction->setShortcut(SHOW_GRAPHS_SHORTCUT);
|
_showGraphsAction->setShortcut(SHOW_GRAPHS_SHORTCUT);
|
||||||
connect(_showGraphsAction, SIGNAL(triggered(bool)), this,
|
connect(_showGraphsAction, SIGNAL(triggered(bool)), this,
|
||||||
SLOT(showGraphs(bool)));
|
SLOT(showGraphs(bool)));
|
||||||
addAction(_showGraphsAction);
|
addAction(_showGraphsAction);
|
||||||
_showToolbarsAction = new QAction(tr("Show toolbars"), this);
|
_showToolbarsAction = new QAction(tr("Show toolbars"), this);
|
||||||
_showToolbarsAction->setCheckable(true);
|
_showToolbarsAction->setCheckable(true);
|
||||||
_showToolbarsAction->setChecked(true);
|
|
||||||
connect(_showToolbarsAction, SIGNAL(triggered(bool)), this,
|
connect(_showToolbarsAction, SIGNAL(triggered(bool)), this,
|
||||||
SLOT(showToolbars(bool)));
|
SLOT(showToolbars(bool)));
|
||||||
QActionGroup *ag = new QActionGroup(this);
|
QActionGroup *ag = new QActionGroup(this);
|
||||||
@ -287,7 +286,6 @@ void GUI::createActions()
|
|||||||
_metricUnitsAction = new QAction(tr("Metric"), this);
|
_metricUnitsAction = new QAction(tr("Metric"), this);
|
||||||
_metricUnitsAction->setCheckable(true);
|
_metricUnitsAction->setCheckable(true);
|
||||||
_metricUnitsAction->setActionGroup(ag);
|
_metricUnitsAction->setActionGroup(ag);
|
||||||
_metricUnitsAction->setChecked(true);
|
|
||||||
connect(_metricUnitsAction, SIGNAL(triggered()), this,
|
connect(_metricUnitsAction, SIGNAL(triggered()), this,
|
||||||
SLOT(setMetricUnits()));
|
SLOT(setMetricUnits()));
|
||||||
_imperialUnitsAction = new QAction(tr("Imperial"), this);
|
_imperialUnitsAction = new QAction(tr("Imperial"), this);
|
||||||
@ -1062,3 +1060,54 @@ void GUI::keyPressEvent(QKeyEvent *event)
|
|||||||
openFile(file);
|
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();
|
||||||
|
}
|
||||||
|
@ -89,6 +89,10 @@ private:
|
|||||||
void updateTrackView();
|
void updateTrackView();
|
||||||
|
|
||||||
void keyPressEvent(QKeyEvent * event);
|
void keyPressEvent(QKeyEvent * event);
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
|
void readSettings();
|
||||||
|
void writeSettings();
|
||||||
|
|
||||||
QMenu *_fileMenu;
|
QMenu *_fileMenu;
|
||||||
QMenu *_helpMenu;
|
QMenu *_helpMenu;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user