1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 23:03:22 +02:00
GPXSee/src/GUI/optionsdialog.cpp

747 lines
24 KiB
C++
Raw Normal View History

2016-12-06 01:48:26 +01:00
#include <QVBoxLayout>
#include <QFormLayout>
#include <QDialogButtonBox>
#include <QListWidget>
#include <QListWidgetItem>
#include <QStackedWidget>
#include <QTabWidget>
#include <QSpinBox>
#include <QGroupBox>
#include <QCheckBox>
#include <QComboBox>
#include <QRadioButton>
2017-05-23 12:50:46 +02:00
#include <QLabel>
2016-12-06 01:48:26 +01:00
#include <QSysInfo>
#include "map/pcs.h"
2016-12-06 01:48:26 +01:00
#include "icons.h"
#include "colorbox.h"
#include "stylecombobox.h"
#include "oddspinbox.h"
#include "percentslider.h"
#include "limitedcombobox.h"
2016-12-06 01:48:26 +01:00
#include "optionsdialog.h"
2016-12-06 01:48:26 +01:00
#define MENU_MARGIN 20
2016-12-07 21:38:36 +01:00
#define MENU_ICON_SIZE 32
2016-12-06 01:48:26 +01:00
#ifdef Q_OS_MAC
static QFrame *line()
{
QFrame *l = new QFrame();
l->setFrameShape(QFrame::HLine);
l->setFrameShadow(QFrame::Sunken);
return l;
}
2019-05-30 19:36:24 +02:00
#endif // Q_OS_MAC
2019-11-13 08:27:54 +01:00
void OptionsDialog::automaticPauseDetectionSet(bool set)
{
_pauseInterval->setEnabled(!set);
_pauseSpeed->setEnabled(!set);
}
QWidget *OptionsDialog::createMapPage()
2017-12-03 14:18:41 +01:00
{
_projection = new LimitedComboBox(200);
QList<KV<int, QString> > projections(GCS::list() + PCS::list());
qSort(projections);
for (int i = 0; i < projections.size(); i++) {
QString text = QString::number(projections.at(i).key()) + " - "
+ projections.at(i).value();
_projection->addItem(text, QVariant(projections.at(i).key()));
}
_projection->setCurrentIndex(_projection->findData(_options->projection));
2017-12-03 14:18:41 +01:00
#ifdef ENABLE_HIDPI
_hidpi = new QRadioButton(tr("High-resolution"));
_lodpi = new QRadioButton(tr("Standard"));
if (_options->hidpiMap)
_hidpi->setChecked(true);
else
_lodpi->setChecked(true);
QLabel *lhi = new QLabel(tr("Non-HiDPI maps are loaded as HiDPI maps. "
"The map is sharp but map objects are small/hard to read."));
QLabel *llo = new QLabel(tr("Non-HiDPI maps are loaded such as they are. "
"Map objects have the expected size but the map is blurry."));
QFont f = lhi->font();
f.setPointSize(f.pointSize() - 1);
lhi->setWordWrap(true);
llo->setWordWrap(true);
lhi->setFont(f);
llo->setFont(f);
#endif // ENABLE_HIDPI
QFormLayout *vectorLayout = new QFormLayout();
vectorLayout->addRow(tr("Projection:"), _projection);
2017-12-03 14:18:41 +01:00
QWidget *vectorMapsTab = new QWidget();
QVBoxLayout *vectorMapsTabLayout = new QVBoxLayout();
vectorMapsTabLayout->addLayout(vectorLayout);
vectorMapsTabLayout->addStretch();
vectorMapsTab->setLayout(vectorMapsTabLayout);
2017-12-03 14:18:41 +01:00
#ifdef ENABLE_HIDPI
QVBoxLayout *hidpiTabLayout = new QVBoxLayout();
hidpiTabLayout->addWidget(_lodpi);
hidpiTabLayout->addWidget(llo);
hidpiTabLayout->addSpacing(10);
hidpiTabLayout->addWidget(_hidpi);
hidpiTabLayout->addWidget(lhi);
hidpiTabLayout->addStretch();
QWidget *hidpiTab = new QWidget();
hidpiTab->setLayout(hidpiTabLayout);
#endif // ENABLE_HIDPI
QTabWidget *mapPage = new QTabWidget();
mapPage->addTab(vectorMapsTab, tr("Vector maps"));
#ifdef ENABLE_HIDPI
mapPage->addTab(hidpiTab, tr("HiDPI display mode"));
#endif // ENABLE_HIDPI
return mapPage;
2017-12-03 14:18:41 +01:00
}
2016-12-06 01:48:26 +01:00
QWidget *OptionsDialog::createAppearancePage()
{
2019-01-31 01:46:53 +01:00
// Tracks
2016-12-06 01:48:26 +01:00
_trackWidth = new QSpinBox();
_trackWidth->setValue(_options->trackWidth);
_trackWidth->setMinimum(1);
_trackStyle = new StyleComboBox();
_trackStyle->setValue(_options->trackStyle);
QFormLayout *trackLayout = new QFormLayout();
2017-09-15 00:07:09 +02:00
#ifdef Q_OS_MAC
2016-12-07 21:38:36 +01:00
trackLayout->addRow(tr("Track width:"), _trackWidth);
trackLayout->addRow(tr("Track style:"), _trackStyle);
2017-09-15 00:07:09 +02:00
#else // Q_OS_MAC
trackLayout->addRow(tr("Width:"), _trackWidth);
trackLayout->addRow(tr("Style:"), _trackStyle);
2016-12-07 21:38:36 +01:00
QGroupBox *trackBox = new QGroupBox(tr("Tracks"));
2016-12-06 01:48:26 +01:00
trackBox->setLayout(trackLayout);
2017-09-15 00:07:09 +02:00
#endif // Q_OS_MAC
2016-12-06 01:48:26 +01:00
2019-01-31 01:46:53 +01:00
// Routes
2016-12-06 01:48:26 +01:00
_routeWidth = new QSpinBox();
_routeWidth->setValue(_options->routeWidth);
_routeWidth->setMinimum(1);
_routeStyle = new StyleComboBox();
_routeStyle->setValue(_options->routeStyle);
QFormLayout *routeLayout = new QFormLayout();
2017-09-15 00:07:09 +02:00
#ifdef Q_OS_MAC
2016-12-07 21:38:36 +01:00
routeLayout->addRow(tr("Route width:"), _routeWidth);
routeLayout->addRow(tr("Route style:"), _routeStyle);
2017-09-15 00:07:09 +02:00
#else // Q_OS_MAC
routeLayout->addRow(tr("Width:"), _routeWidth);
routeLayout->addRow(tr("Style:"), _routeStyle);
2016-12-07 21:38:36 +01:00
QGroupBox *routeBox = new QGroupBox(tr("Routes"));
2016-12-06 01:48:26 +01:00
routeBox->setLayout(routeLayout);
2016-12-07 21:38:36 +01:00
#endif // Q_OS_MAC
2016-12-06 01:48:26 +01:00
// Areas
_areaWidth = new QSpinBox();
_areaWidth->setValue(_options->areaWidth);
_areaStyle = new StyleComboBox();
_areaStyle->setValue(_options->areaStyle);
_areaOpacity = new PercentSlider();
_areaOpacity->setValue(_options->areaOpacity);
QFormLayout *areaLayout = new QFormLayout();
#ifdef Q_OS_MAC
areaLayout->addRow(tr("Area border width:"), _areaWidth);
areaLayout->addRow(tr("Area border style:"), _areaStyle);
2019-02-13 00:59:26 +01:00
areaLayout->addRow(tr("Area fill opacity:"), _areaOpacity);
#else // Q_OS_MAC
areaLayout->addRow(tr("Width:"), _areaWidth);
areaLayout->addRow(tr("Style:"), _areaStyle);
areaLayout->addRow(tr("Fill opacity:"), _areaOpacity);
QGroupBox *areaBox = new QGroupBox(tr("Areas"));
areaBox->setLayout(areaLayout);
#endif // Q_OS_MAC
// Palette & antialiasing
2019-01-31 01:46:53 +01:00
_baseColor = new ColorBox();
_baseColor->setColor(_options->palette.color());
_colorOffset = new QDoubleSpinBox();
_colorOffset->setMinimum(0);
_colorOffset->setMaximum(1.0);
_colorOffset->setSingleStep(0.01);
_colorOffset->setValue(_options->palette.shift());
QFormLayout *paletteLayout = new QFormLayout();
paletteLayout->addRow(tr("Base color:"), _baseColor);
paletteLayout->addRow(tr("Palette shift:"), _colorOffset);
2016-12-06 01:48:26 +01:00
_pathAA = new QCheckBox(tr("Use anti-aliasing"));
_pathAA->setChecked(_options->pathAntiAliasing);
2016-12-07 21:38:36 +01:00
QFormLayout *pathAALayout = new QFormLayout();
pathAALayout->addWidget(_pathAA);
2016-12-06 01:48:26 +01:00
QWidget *pathTab = new QWidget();
QVBoxLayout *pathTabLayout = new QVBoxLayout();
2016-12-07 21:38:36 +01:00
#ifdef Q_OS_MAC
pathTabLayout->addLayout(trackLayout);
pathTabLayout->addWidget(line());
2016-12-07 21:38:36 +01:00
pathTabLayout->addLayout(routeLayout);
pathTabLayout->addWidget(line());
pathTabLayout->addLayout(areaLayout);
pathTabLayout->addWidget(line());
2017-05-23 12:50:46 +02:00
#else // Q_OS_MAC
2016-12-06 01:48:26 +01:00
pathTabLayout->addWidget(trackBox);
pathTabLayout->addWidget(routeBox);
pathTabLayout->addWidget(areaBox);
2017-05-23 12:50:46 +02:00
#endif // Q_OS_MAC
2019-01-31 01:46:53 +01:00
pathTabLayout->addLayout(paletteLayout);
2016-12-07 21:38:36 +01:00
pathTabLayout->addLayout(pathAALayout);
2017-05-22 17:04:37 +02:00
pathTabLayout->addStretch();
2016-12-06 01:48:26 +01:00
pathTab->setLayout(pathTabLayout);
// Waypoints
_waypointSize = new QSpinBox();
2017-09-15 00:07:09 +02:00
_waypointSize->setMinimum(1);
_waypointSize->setValue(_options->waypointSize);
_waypointColor = new ColorBox();
_waypointColor->setColor(_options->waypointColor);
QFormLayout *waypointLayout = new QFormLayout();
2017-09-15 00:07:09 +02:00
#ifdef Q_OS_MAC
waypointLayout->addRow(tr("Waypoint color:"), _waypointColor);
waypointLayout->addRow(tr("Waypoint size:"), _waypointSize);
2017-09-15 00:07:09 +02:00
#else // Q_OS_MAC
waypointLayout->addRow(tr("Color:"), _waypointColor);
waypointLayout->addRow(tr("Size:"), _waypointSize);
QGroupBox *waypointBox = new QGroupBox(tr("Waypoints"));
waypointBox->setLayout(waypointLayout);
#endif // Q_OS_MAC
_poiSize = new QSpinBox();
2017-09-15 00:07:09 +02:00
_poiSize->setMinimum(1);
_poiSize->setValue(_options->poiSize);
_poiColor = new ColorBox();
_poiColor->setColor(_options->poiColor);
QFormLayout *poiLayout = new QFormLayout();
2017-09-15 00:07:09 +02:00
#ifdef Q_OS_MAC
poiLayout->addRow(tr("POI color:"), _poiColor);
poiLayout->addRow(tr("POI size:"), _poiSize);
2017-09-15 00:07:09 +02:00
#else // Q_OS_MAC
poiLayout->addRow(tr("Color:"), _poiColor);
poiLayout->addRow(tr("Size:"), _poiSize);
QGroupBox *poiBox = new QGroupBox(tr("POIs"));
poiBox->setLayout(poiLayout);
#endif // Q_OS_MAC
QWidget *pointTab = new QWidget();
QVBoxLayout *pointTabLayout = new QVBoxLayout();
#ifdef Q_OS_MAC
pointTabLayout->addLayout(waypointLayout);
2017-09-10 12:53:51 +02:00
pointTabLayout->addWidget(line());
pointTabLayout->addLayout(poiLayout);
#else // Q_OS_MAC
pointTabLayout->addWidget(waypointBox);
pointTabLayout->addWidget(poiBox);
#endif // Q_OS_MAC
pointTabLayout->addStretch();
pointTab->setLayout(pointTabLayout);
// Graphs
2017-12-03 00:36:52 +01:00
_sliderColor = new ColorBox();
_sliderColor->setColor(_options->sliderColor);
2016-12-06 01:48:26 +01:00
_graphWidth = new QSpinBox();
_graphWidth->setValue(_options->graphWidth);
_graphWidth->setMinimum(1);
2017-12-03 00:36:52 +01:00
2016-12-06 01:48:26 +01:00
QFormLayout *graphLayout = new QFormLayout();
graphLayout->addRow(tr("Line width:"), _graphWidth);
2017-12-03 00:36:52 +01:00
graphLayout->addRow(tr("Slider color:"), _sliderColor);
2016-12-06 01:48:26 +01:00
_graphAA = new QCheckBox(tr("Use anti-aliasing"));
_graphAA->setChecked(_options->graphAntiAliasing);
2016-12-07 21:38:36 +01:00
QFormLayout *graphAALayout = new QFormLayout();
graphAALayout->addWidget(_graphAA);
2016-12-06 01:48:26 +01:00
QWidget *graphTab = new QWidget();
QVBoxLayout *graphTabLayout = new QVBoxLayout();
graphTabLayout->addLayout(graphLayout);
2016-12-07 21:38:36 +01:00
graphTabLayout->addLayout(graphAALayout);
2016-12-06 01:48:26 +01:00
graphTabLayout->addStretch();
graphTab->setLayout(graphTabLayout);
// Map
_mapOpacity = new PercentSlider();
_mapOpacity->setValue(_options->mapOpacity);
2017-09-15 00:07:09 +02:00
_backgroundColor = new ColorBox();
_backgroundColor->setColor(_options->backgroundColor);
_backgroundColor->enableAlphaChannel(false);
QFormLayout *mapLayout = new QFormLayout();
2017-09-15 00:07:09 +02:00
mapLayout->addRow(tr("Background color:"), _backgroundColor);
mapLayout->addRow(tr("Map opacity:"), _mapOpacity);
QWidget *mapTab = new QWidget();
QVBoxLayout *mapTabLayout = new QVBoxLayout();
mapTabLayout->addLayout(mapLayout);
mapTabLayout->addStretch();
mapTab->setLayout(mapTabLayout);
2016-12-06 01:48:26 +01:00
QTabWidget *appearancePage = new QTabWidget();
appearancePage->addTab(pathTab, tr("Paths"));
appearancePage->addTab(pointTab, tr("Points"));
2016-12-06 01:48:26 +01:00
appearancePage->addTab(graphTab, tr("Graphs"));
appearancePage->addTab(mapTab, tr("Map"));
2016-12-06 01:48:26 +01:00
return appearancePage;
}
2017-05-22 14:54:22 +02:00
QWidget *OptionsDialog::createDataPage()
{
QString filterToolTip = tr("Moving average window size");
_elevationFilter = new OddSpinBox();
2017-05-22 14:54:22 +02:00
_elevationFilter->setValue(_options->elevationFilter);
_elevationFilter->setToolTip(filterToolTip);
_speedFilter = new OddSpinBox();
2017-05-22 14:54:22 +02:00
_speedFilter->setValue(_options->speedFilter);
_speedFilter->setToolTip(filterToolTip);
_heartRateFilter = new OddSpinBox();
2017-05-22 14:54:22 +02:00
_heartRateFilter->setValue(_options->heartRateFilter);
_heartRateFilter->setToolTip(filterToolTip);
_cadenceFilter = new OddSpinBox();
2017-05-22 14:54:22 +02:00
_cadenceFilter->setValue(_options->cadenceFilter);
_cadenceFilter->setToolTip(filterToolTip);
_powerFilter = new OddSpinBox();
2017-05-22 14:54:22 +02:00
_powerFilter->setValue(_options->powerFilter);
_powerFilter->setToolTip(filterToolTip);
2017-05-22 17:04:37 +02:00
QFormLayout *smoothLayout = new QFormLayout();
smoothLayout->addRow(tr("Elevation:"), _elevationFilter);
smoothLayout->addRow(tr("Speed:"), _speedFilter);
smoothLayout->addRow(tr("Heart rate:"), _heartRateFilter);
smoothLayout->addRow(tr("Cadence:"), _cadenceFilter);
smoothLayout->addRow(tr("Power:"), _powerFilter);
2017-05-23 12:50:46 +02:00
#ifndef Q_OS_MAC
2017-05-22 17:04:37 +02:00
QGroupBox *smoothBox = new QGroupBox(tr("Smoothing"));
smoothBox->setLayout(smoothLayout);
2017-05-23 12:50:46 +02:00
#endif // Q_OS_MAC
2017-05-22 14:54:22 +02:00
2017-05-22 17:04:37 +02:00
_outlierEliminate = new QCheckBox(tr("Eliminate GPS outliers"));
2017-05-22 14:54:22 +02:00
_outlierEliminate->setChecked(_options->outlierEliminate);
QFormLayout *outlierLayout = new QFormLayout();
outlierLayout->addWidget(_outlierEliminate);
QWidget *filterTab = new QWidget();
QVBoxLayout *filterTabLayout = new QVBoxLayout();
2017-05-23 12:50:46 +02:00
#ifdef Q_OS_MAC
filterTabLayout->addWidget(new QLabel(tr("Smoothing:")));
2017-05-23 12:50:46 +02:00
filterTabLayout->addLayout(smoothLayout);
filterTabLayout->addWidget(line());
2017-05-23 12:50:46 +02:00
#else // Q_OS_MAC
2017-05-22 17:04:37 +02:00
filterTabLayout->addWidget(smoothBox);
2017-05-23 12:50:46 +02:00
#endif // Q_OS_MAC
filterTabLayout->addLayout(outlierLayout);
2017-05-22 14:54:22 +02:00
filterTabLayout->addStretch();
filterTab->setLayout(filterTabLayout);
2017-05-22 17:04:37 +02:00
2019-11-13 08:27:54 +01:00
_automaticPause = new QRadioButton(tr("Automatic"));
2019-11-13 09:13:05 +01:00
_manualPause = new QRadioButton(tr("Custom"));
2019-11-13 08:27:54 +01:00
if (_options->automaticPause)
_automaticPause->setChecked(true);
else
_manualPause->setChecked(true);
2017-05-22 14:54:22 +02:00
_pauseSpeed = new QDoubleSpinBox();
_pauseSpeed->setDecimals(1);
_pauseSpeed->setSingleStep(0.1);
_pauseSpeed->setMinimum(0.1);
2019-11-13 08:27:54 +01:00
_pauseSpeed->setEnabled(_manualPause->isChecked());
2017-05-22 14:54:22 +02:00
if (_options->units == Imperial) {
_pauseSpeed->setValue(_options->pauseSpeed * MS2MIH);
_pauseSpeed->setSuffix(UNIT_SPACE + tr("mi/h"));
2018-02-11 23:51:57 +01:00
} else if (_options->units == Nautical) {
_pauseSpeed->setValue(_options->pauseSpeed * MS2KN);
_pauseSpeed->setSuffix(UNIT_SPACE + tr("kn"));
2017-05-22 14:54:22 +02:00
} else {
_pauseSpeed->setValue(_options->pauseSpeed * MS2KMH);
_pauseSpeed->setSuffix(UNIT_SPACE + tr("km/h"));
}
_pauseInterval = new QSpinBox();
_pauseInterval->setMinimum(1);
_pauseInterval->setSuffix(UNIT_SPACE + tr("s"));
_pauseInterval->setValue(_options->pauseInterval);
2019-11-13 08:27:54 +01:00
_pauseInterval->setEnabled(_manualPause->isChecked());
connect(_automaticPause, SIGNAL(toggled(bool)), this,
SLOT(automaticPauseDetectionSet(bool)));
QHBoxLayout *pauseTypeLayout = new QHBoxLayout();
2019-11-13 20:03:19 +01:00
#ifdef Q_OS_MAC
pauseTypeLayout->addStretch();
#endif
2019-11-13 08:27:54 +01:00
pauseTypeLayout->addWidget(_automaticPause);
pauseTypeLayout->addWidget(_manualPause);
pauseTypeLayout->addStretch();
QFormLayout *pauseValuesLayout = new QFormLayout();
pauseValuesLayout->addRow(tr("Minimal speed:"), _pauseSpeed);
pauseValuesLayout->addRow(tr("Minimal duration:"), _pauseInterval);
2017-05-22 14:54:22 +02:00
2019-11-13 08:27:54 +01:00
QVBoxLayout *pauseLayout = new QVBoxLayout();
pauseLayout->addLayout(pauseTypeLayout);
pauseLayout->addLayout(pauseValuesLayout);
2017-05-22 14:54:22 +02:00
QWidget *pauseTab = new QWidget();
pauseTab->setLayout(pauseLayout);
_computedSpeed = new QRadioButton(tr("Computed from distance/time"));
_reportedSpeed = new QRadioButton(tr("Recorded by device"));
2018-06-21 20:54:24 +02:00
if (_options->useReportedSpeed)
_reportedSpeed->setChecked(true);
2018-06-21 20:54:24 +02:00
else
_computedSpeed->setChecked(true);
_dataGPSElevation = new QRadioButton(tr("GPS data"));
_dataDEMElevation = new QRadioButton(tr("DEM data"));
if (_options->dataUseDEM)
_dataDEMElevation->setChecked(true);
else
_dataGPSElevation->setChecked(true);
QWidget *sourceTab = new QWidget();
QVBoxLayout *sourceTabLayout = new QVBoxLayout();
#ifdef Q_OS_MAC
QVBoxLayout *speedOptions = new QVBoxLayout();
speedOptions->addWidget(_computedSpeed);
speedOptions->addWidget(_reportedSpeed);
QVBoxLayout *elevationOptions = new QVBoxLayout();
2019-01-22 23:21:01 +01:00
elevationOptions->addWidget(_dataGPSElevation);
elevationOptions->addWidget(_dataDEMElevation);
QFormLayout *formLayout = new QFormLayout();
formLayout->addRow(tr("Speed:"), speedOptions);
formLayout->addRow(tr("Elevation:"), elevationOptions);
sourceTabLayout->addLayout(formLayout);
#else // Q_OS_MAC
QFormLayout *speedLayout = new QFormLayout();
QFormLayout *elevationLayout = new QFormLayout();
speedLayout->addWidget(_computedSpeed);
speedLayout->addWidget(_reportedSpeed);
QGroupBox *speedBox = new QGroupBox(tr("Speed"));
speedBox->setLayout(speedLayout);
elevationLayout->addWidget(_dataGPSElevation);
elevationLayout->addWidget(_dataDEMElevation);
QGroupBox *elevationBox = new QGroupBox(tr("Elevation"));
elevationBox->setLayout(elevationLayout);
2018-06-21 20:54:24 +02:00
sourceTabLayout->addWidget(speedBox);
sourceTabLayout->addWidget(elevationBox);
#endif // Q_OS_MAC
sourceTabLayout->addStretch();
sourceTab->setLayout(sourceTabLayout);
2018-06-21 20:54:24 +02:00
2017-05-22 14:54:22 +02:00
QTabWidget *filterPage = new QTabWidget();
filterPage->addTab(filterTab, tr("Filtering"));
filterPage->addTab(sourceTab, tr("Sources"));
2017-05-22 14:54:22 +02:00
filterPage->addTab(pauseTab, tr("Pause detection"));
return filterPage;
}
2016-12-06 01:48:26 +01:00
QWidget *OptionsDialog::createPOIPage()
{
_poiGPSElevation = new QRadioButton(tr("GPS data"));
_poiDEMElevation = new QRadioButton(tr("DEM data"));
if (_options->poiUseDEM)
_poiDEMElevation->setChecked(true);
else
_poiGPSElevation->setChecked(true);
2016-12-06 01:48:26 +01:00
_poiRadius = new QDoubleSpinBox();
_poiRadius->setSingleStep(1);
_poiRadius->setDecimals(1);
2016-12-07 21:38:36 +01:00
if (_options->units == Imperial) {
_poiRadius->setValue(_options->poiRadius / MIINM);
_poiRadius->setSuffix(UNIT_SPACE + tr("mi"));
2018-02-11 23:51:57 +01:00
} else if (_options->units == Nautical) {
_poiRadius->setValue(_options->poiRadius / NMIINM);
_poiRadius->setSuffix(UNIT_SPACE + tr("nmi"));
2016-12-07 21:38:36 +01:00
} else {
_poiRadius->setValue(_options->poiRadius / KMINM);
_poiRadius->setSuffix(UNIT_SPACE + tr("km"));
}
2016-12-06 01:48:26 +01:00
QVBoxLayout *elevationLayout = new QVBoxLayout();
elevationLayout->addWidget(_poiGPSElevation);
elevationLayout->addWidget(_poiDEMElevation);
2016-12-06 01:48:26 +01:00
QFormLayout *poiLayout = new QFormLayout();
poiLayout->addRow(tr("Radius:"), _poiRadius);
poiLayout->addRow(tr("Elevation:"), elevationLayout);
2016-12-06 01:48:26 +01:00
QWidget *poiTab = new QWidget();
poiTab->setLayout(poiLayout);
QTabWidget *poiPage = new QTabWidget();
poiPage->addTab(poiTab, tr("POI"));
return poiPage;
}
QWidget *OptionsDialog::createExportPage()
{
_wysiwyg = new QRadioButton(tr("WYSIWYG"));
2017-08-30 13:56:23 +02:00
_hires = new QRadioButton(tr("High-Resolution"));
if (_options->hiresPrint)
_hires->setChecked(true);
else
_wysiwyg->setChecked(true);
QLabel *lw = new QLabel(tr("The printed area is approximately the display"
" area. The map zoom level does not change."));
QLabel *lh = new QLabel(tr("The zoom level will be changed so that"
2017-08-30 13:56:23 +02:00
" the whole content (tracks/waypoints) fits to the printed area and"
" the map resolution is as close as possible to the print resolution."));
QFont f = lw->font();
f.setPointSize(f.pointSize() - 1);
lw->setWordWrap(true);
lh->setWordWrap(true);
lw->setFont(f);
lh->setFont(f);
QVBoxLayout *modeTabLayout = new QVBoxLayout();
modeTabLayout->addWidget(_wysiwyg);
modeTabLayout->addWidget(lw);
modeTabLayout->addSpacing(10);
modeTabLayout->addWidget(_hires);
modeTabLayout->addWidget(lh);
modeTabLayout->addStretch();
QWidget *modeTab = new QWidget();
modeTab->setLayout(modeTabLayout);
_name = new QCheckBox(tr("Name"));
_name->setChecked(_options->printName);
_date = new QCheckBox(tr("Date"));
_date->setChecked(_options->printDate);
_distance = new QCheckBox(tr("Distance"));
_distance->setChecked(_options->printDistance);
_time = new QCheckBox(tr("Time"));
_time->setChecked(_options->printTime);
_movingTime = new QCheckBox(tr("Moving time"));
_movingTime->setChecked(_options->printMovingTime);
_itemCount = new QCheckBox(tr("Item count (>1)"));
_itemCount->setChecked(_options->printItemCount);
QFormLayout *headerTabLayout = new QFormLayout();
headerTabLayout->addWidget(_name);
headerTabLayout->addWidget(_date);
headerTabLayout->addWidget(_distance);
headerTabLayout->addWidget(_time);
headerTabLayout->addWidget(_movingTime);
headerTabLayout->addItem(new QSpacerItem(10, 10));
headerTabLayout->addWidget(_itemCount);
QWidget *headerTab = new QWidget();
headerTab->setLayout(headerTabLayout);
_separateGraphPage = new QCheckBox(tr("Separate graph page"));
_separateGraphPage->setChecked(_options->separateGraphPage);
QFormLayout *graphTabLayout = new QFormLayout();
graphTabLayout->addWidget(_separateGraphPage);
QWidget *graphTab = new QWidget();
graphTab->setLayout(graphTabLayout);
QTabWidget *exportPage = new QTabWidget();
exportPage->addTab(modeTab, tr("Print mode"));
exportPage->addTab(headerTab, tr("Header"));
exportPage->addTab(graphTab, tr("Graphs"));
return exportPage;
}
2016-12-06 01:48:26 +01:00
QWidget *OptionsDialog::createSystemPage()
{
_useOpenGL = new QCheckBox(tr("Use OpenGL"));
_useOpenGL->setChecked(_options->useOpenGL);
2018-07-23 23:53:58 +02:00
#ifdef ENABLE_HTTP2
_enableHTTP2 = new QCheckBox(tr("Enable HTTP/2"));
_enableHTTP2->setChecked(_options->enableHTTP2);
#endif // ENABLE_HTTP2
2016-12-06 01:48:26 +01:00
_pixmapCache = new QSpinBox();
_pixmapCache->setMinimum(16);
_pixmapCache->setMaximum(1024);
_pixmapCache->setSuffix(UNIT_SPACE + tr("MB"));
_pixmapCache->setValue(_options->pixmapCache);
_connectionTimeout = new QSpinBox();
_connectionTimeout->setMinimum(30);
_connectionTimeout->setMaximum(120);
_connectionTimeout->setSuffix(UNIT_SPACE + tr("s"));
_connectionTimeout->setValue(_options->connectionTimeout);
QFormLayout *formLayout = new QFormLayout();
formLayout->addRow(tr("Image cache size:"), _pixmapCache);
formLayout->addRow(tr("Connection timeout:"), _connectionTimeout);
QFormLayout *checkboxLayout = new QFormLayout();
2018-07-23 23:53:58 +02:00
#ifdef ENABLE_HTTP2
checkboxLayout->addWidget(_enableHTTP2);
#endif // ENABLE_HTTP2
checkboxLayout->addWidget(_useOpenGL);
2016-12-06 01:48:26 +01:00
QWidget *systemTab = new QWidget();
QVBoxLayout *systemTabLayout = new QVBoxLayout();
systemTabLayout->addLayout(formLayout);
systemTabLayout->addLayout(checkboxLayout);
systemTabLayout->addStretch();
systemTab->setLayout(systemTabLayout);
2016-12-06 01:48:26 +01:00
QTabWidget *systemPage = new QTabWidget();
systemPage->addTab(systemTab, tr("System"));
return systemPage;
}
OptionsDialog::OptionsDialog(Options *options, QWidget *parent)
: QDialog(parent), _options(options)
{
QStackedWidget *pages = new QStackedWidget();
pages->addWidget(createAppearancePage());
pages->addWidget(createMapPage());
2017-05-22 14:54:22 +02:00
pages->addWidget(createDataPage());
2016-12-06 01:48:26 +01:00
pages->addWidget(createPOIPage());
pages->addWidget(createExportPage());
2016-12-06 01:48:26 +01:00
pages->addWidget(createSystemPage());
QListWidget *menu = new QListWidget();
2016-12-07 21:38:36 +01:00
menu->setIconSize(QSize(MENU_ICON_SIZE, MENU_ICON_SIZE));
2018-08-18 21:06:36 +02:00
new QListWidgetItem(QIcon(APPEARANCE_ICON), tr("Appearance"),
2016-12-06 01:48:26 +01:00
menu);
new QListWidgetItem(QIcon(MAPS_ICON), tr("Maps"), menu);
2018-08-18 21:06:36 +02:00
new QListWidgetItem(QIcon(DATA_ICON), tr("Data"), menu);
new QListWidgetItem(QIcon(POI_ICON), tr("POI"), menu);
new QListWidgetItem(QIcon(PRINT_EXPORT_ICON), tr("Print & Export"),
menu);
2018-08-18 21:06:36 +02:00
new QListWidgetItem(QIcon(SYSTEM_ICON), tr("System"), menu);
2016-12-06 01:48:26 +01:00
QHBoxLayout *contentLayout = new QHBoxLayout();
contentLayout->addWidget(menu);
contentLayout->addWidget(pages);
menu->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
menu->setMaximumWidth(menu->sizeHintForColumn(0) + 2 * menu->frameWidth()
+ MENU_MARGIN);
pages->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
pages->setMinimumWidth(2 * menu->size().width());
connect(menu, SIGNAL(currentRowChanged(int)), pages,
SLOT(setCurrentIndex(int)));
menu->item(0)->setSelected(true);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
QVBoxLayout *layout = new QVBoxLayout;
layout->addLayout(contentLayout);
layout->addWidget(buttonBox);
setLayout(layout);
setWindowTitle(tr("Options"));
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
}
void OptionsDialog::accept()
{
_options->palette.setColor(_baseColor->color());
_options->palette.setShift(_colorOffset->value());
_options->mapOpacity = _mapOpacity->value();
2017-09-15 00:07:09 +02:00
_options->backgroundColor = _backgroundColor->color();
2016-12-06 01:48:26 +01:00
_options->trackWidth = _trackWidth->value();
_options->trackStyle = (Qt::PenStyle) _trackStyle->itemData(
_trackStyle->currentIndex()).toInt();
_options->routeWidth = _routeWidth->value();
_options->routeStyle = (Qt::PenStyle) _routeStyle->itemData(
_routeStyle->currentIndex()).toInt();
_options->pathAntiAliasing = _pathAA->isChecked();
2019-01-31 01:46:53 +01:00
_options->areaWidth = _areaWidth->value();
_options->areaStyle = (Qt::PenStyle) _areaStyle->itemData(
_areaStyle->currentIndex()).toInt();
_options->areaOpacity = _areaOpacity->value();
_options->waypointSize = _waypointSize->value();
_options->waypointColor = _waypointColor->color();
_options->poiSize = _poiSize->value();
_options->poiColor = _poiColor->color();
2016-12-06 01:48:26 +01:00
_options->graphWidth = _graphWidth->value();
2017-12-03 00:36:52 +01:00
_options->sliderColor = _sliderColor->color();
2016-12-06 01:48:26 +01:00
_options->graphAntiAliasing = _graphAA->isChecked();
2019-05-15 07:47:57 +02:00
_options->projection = _projection->itemData(_projection->currentIndex())
.toInt();
#ifdef ENABLE_HIDPI
_options->hidpiMap = _hidpi->isChecked();
#endif // ENABLE_HIDPI
2017-05-22 14:54:22 +02:00
_options->elevationFilter = _elevationFilter->value();
_options->speedFilter = _speedFilter->value();
_options->heartRateFilter = _heartRateFilter->value();
_options->cadenceFilter = _cadenceFilter->value();
_options->powerFilter = _powerFilter->value();
_options->outlierEliminate = _outlierEliminate->isChecked();
2019-11-13 08:27:54 +01:00
_options->automaticPause = _automaticPause->isChecked();
2017-09-15 00:07:09 +02:00
qreal pauseSpeed = (_options->units == Imperial)
2018-02-11 23:51:57 +01:00
? _pauseSpeed->value() / MS2MIH : (_options->units == Nautical)
? _pauseSpeed->value() / MS2KN : _pauseSpeed->value() / MS2KMH;
2017-09-15 00:07:09 +02:00
if (qAbs(pauseSpeed - _options->pauseSpeed) > 0.01)
_options->pauseSpeed = pauseSpeed;
2017-05-22 14:54:22 +02:00
_options->pauseInterval = _pauseInterval->value();
_options->useReportedSpeed = _reportedSpeed->isChecked();
_options->dataUseDEM = _dataDEMElevation->isChecked();
2017-05-22 14:54:22 +02:00
2017-09-15 00:07:09 +02:00
qreal poiRadius = (_options->units == Imperial)
2018-02-11 23:51:57 +01:00
? _poiRadius->value() * MIINM : (_options->units == Nautical)
? _poiRadius->value() * NMIINM : _poiRadius->value() * KMINM;
2017-09-15 00:07:09 +02:00
if (qAbs(poiRadius - _options->poiRadius) > 0.01)
_options->poiRadius = poiRadius;
_options->poiUseDEM = _poiDEMElevation->isChecked();
2016-12-06 01:48:26 +01:00
_options->useOpenGL = _useOpenGL->isChecked();
2018-07-23 23:53:58 +02:00
#ifdef ENABLE_HTTP2
_options->enableHTTP2 = _enableHTTP2->isChecked();
#endif // ENABLE_HTTP2
_options->pixmapCache = _pixmapCache->value();
_options->connectionTimeout = _connectionTimeout->value();
2016-12-06 01:48:26 +01:00
_options->hiresPrint = _hires->isChecked();
_options->printName = _name->isChecked();
_options->printDate = _date->isChecked();
_options->printDistance = _distance->isChecked();
_options->printTime = _time->isChecked();
_options->printMovingTime = _movingTime->isChecked();
_options->printItemCount = _itemCount->isChecked();
_options->separateGraphPage = _separateGraphPage->isChecked();
2016-12-06 01:48:26 +01:00
QDialog::accept();
}