From 1ff21628116a31e27c984683b5164b566d1d09aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 3 Dec 2017 14:18:41 +0100 Subject: [PATCH] Added the "always show map" option --- src/GUI/gui.cpp | 15 ++++++++++++--- src/GUI/optionsdialog.cpp | 24 ++++++++++++++++++++++++ src/GUI/optionsdialog.h | 5 +++++ src/GUI/settings.h | 2 ++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/GUI/gui.cpp b/src/GUI/gui.cpp index 92436347..949a4ea3 100644 --- a/src/GUI/gui.cpp +++ b/src/GUI/gui.cpp @@ -83,11 +83,11 @@ GUI::GUI() _sliderPos = 0; + readSettings(); + updateGraphTabs(); updateMapView(); updateStatusBarInfo(); - - readSettings(); } GUI::~GUI() @@ -876,6 +876,8 @@ void GUI::openOptions() reloadFile(); _options = options; + + updateMapView(); } void GUI::printFile() @@ -1308,7 +1310,10 @@ void GUI::updateGraphTabs() void GUI::updateMapView() { - _mapView->setHidden(!(_trackCount + _routeCount + _waypointCount)); + if (_options.alwaysShowMap) + _mapView->setHidden(false); + else + _mapView->setHidden(!(_trackCount + _routeCount + _waypointCount)); } void GUI::setTimeType(TimeType type) @@ -1631,6 +1636,8 @@ void GUI::writeSettings() _options.separateGraphPage); if (_options.sliderColor != SLIDER_COLOR_DEFAULT) settings.setValue(SLIDER_COLOR_SETTING, _options.sliderColor); + if (_options.alwaysShowMap != ALWAYS_SHOW_MAP_DEFAULT) + settings.setValue(ALWAYS_SHOW_MAP_SETTING, _options.alwaysShowMap); settings.endGroup(); } @@ -1846,6 +1853,8 @@ void GUI::readSettings() SEPARATE_GRAPH_PAGE_DEFAULT).toBool(); _options.sliderColor = settings.value(SLIDER_COLOR_SETTING, SLIDER_COLOR_DEFAULT).value(); + _options.alwaysShowMap = settings.value(ALWAYS_SHOW_MAP_SETTING, + ALWAYS_SHOW_MAP_DEFAULT).toBool(); _mapView->setPalette(_options.palette); _mapView->setMapOpacity(_options.mapOpacity); diff --git a/src/GUI/optionsdialog.cpp b/src/GUI/optionsdialog.cpp index 25c9b1bf..ec3641d7 100644 --- a/src/GUI/optionsdialog.cpp +++ b/src/GUI/optionsdialog.cpp @@ -35,6 +35,26 @@ static QFrame *line() } #endif +QWidget *OptionsDialog::createGeneralPage() +{ + _alwaysShowMap = new QCheckBox(tr("Display map when no files are loaded")); + _alwaysShowMap->setChecked(_options->alwaysShowMap); + + QFormLayout *showMapLayout = new QFormLayout(); + showMapLayout->addWidget(_alwaysShowMap); + + QWidget *generalTab = new QWidget(); + QVBoxLayout *generalTabLayout = new QVBoxLayout(); + generalTabLayout->addLayout(showMapLayout); + generalTabLayout->addStretch(); + generalTab->setLayout(generalTabLayout); + + QTabWidget *generalPage = new QTabWidget(); + generalPage->addTab(generalTab, tr("General")); + + return generalPage; +} + QWidget *OptionsDialog::createAppearancePage() { // Paths @@ -426,6 +446,7 @@ OptionsDialog::OptionsDialog(Options *options, QWidget *parent) : QDialog(parent), _options(options) { QStackedWidget *pages = new QStackedWidget(); + pages->addWidget(createGeneralPage()); pages->addWidget(createAppearancePage()); pages->addWidget(createDataPage()); pages->addWidget(createPOIPage()); @@ -434,6 +455,7 @@ OptionsDialog::OptionsDialog(Options *options, QWidget *parent) QListWidget *menu = new QListWidget(); menu->setIconSize(QSize(MENU_ICON_SIZE, MENU_ICON_SIZE)); + new QListWidgetItem(QIcon(QPixmap(APP_ICON)), tr("General"), menu); new QListWidgetItem(QIcon(QPixmap(APPEARANCE_ICON)), tr("Appearance"), menu); new QListWidgetItem(QIcon(QPixmap(DATA_ICON)), tr("Data"), menu); @@ -473,6 +495,8 @@ OptionsDialog::OptionsDialog(Options *options, QWidget *parent) void OptionsDialog::accept() { + _options->alwaysShowMap = _alwaysShowMap->isChecked(); + _options->palette.setColor(_baseColor->color()); _options->palette.setShift(_colorOffset->value()); _options->mapOpacity = _mapOpacity->value(); diff --git a/src/GUI/optionsdialog.h b/src/GUI/optionsdialog.h index f9db56ab..07f451a7 100644 --- a/src/GUI/optionsdialog.h +++ b/src/GUI/optionsdialog.h @@ -16,6 +16,8 @@ class QRadioButton; class PercentSlider; struct Options { + // General + bool alwaysShowMap; // Appearance Palette palette; int trackWidth; @@ -70,6 +72,7 @@ public slots: void accept(); private: + QWidget *createGeneralPage(); QWidget *createAppearancePage(); QWidget *createDataPage(); QWidget *createPOIPage(); @@ -78,6 +81,8 @@ private: Options *_options; + // General + QCheckBox *_alwaysShowMap; // Appearance ColorBox *_baseColor; QDoubleSpinBox *_colorOffset; diff --git a/src/GUI/settings.h b/src/GUI/settings.h index 93ad1ece..b0f427f6 100644 --- a/src/GUI/settings.h +++ b/src/GUI/settings.h @@ -146,5 +146,7 @@ #define SEPARATE_GRAPH_PAGE_DEFAULT false #define SLIDER_COLOR_SETTING "sliderColor" #define SLIDER_COLOR_DEFAULT QColor(Qt::red) +#define ALWAYS_SHOW_MAP_SETTING "alwaysShowMap" +#define ALWAYS_SHOW_MAP_DEFAULT true #endif // SETTINGS_H