1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Added the "always show map" option

This commit is contained in:
Martin Tůma 2017-12-03 14:18:41 +01:00
parent 0f10c7596b
commit 1ff2162811
4 changed files with 43 additions and 3 deletions

View File

@ -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,6 +1310,9 @@ void GUI::updateGraphTabs()
void GUI::updateMapView()
{
if (_options.alwaysShowMap)
_mapView->setHidden(false);
else
_mapView->setHidden(!(_trackCount + _routeCount + _waypointCount));
}
@ -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<QColor>();
_options.alwaysShowMap = settings.value(ALWAYS_SHOW_MAP_SETTING,
ALWAYS_SHOW_MAP_DEFAULT).toBool();
_mapView->setPalette(_options.palette);
_mapView->setMapOpacity(_options.mapOpacity);

View File

@ -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();

View File

@ -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;

View File

@ -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