mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-27 21:24:47 +01:00
Made the HiDPI display mode (of non-HiDPI maps) configurable
This commit is contained in:
parent
d58322b412
commit
89f384feed
@ -40,5 +40,7 @@
|
||||
<file>icons/document-print_32@2x.png</file>
|
||||
<file>icons/view-filter.png</file>
|
||||
<file>icons/view-filter@2x.png</file>
|
||||
<file>icons/applications-internet_32.png</file>
|
||||
<file>icons/applications-internet_32@2x.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
BIN
icons/applications-internet_32.png
Normal file
BIN
icons/applications-internet_32.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
BIN
icons/applications-internet_32@2x.png
Normal file
BIN
icons/applications-internet_32@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.1 KiB |
@ -931,6 +931,11 @@ void GUI::openOptions()
|
||||
if (options.enableHTTP2 != _options.enableHTTP2)
|
||||
Downloader::enableHTTP2(options.enableHTTP2);
|
||||
#endif // ENABLE_HTTP2
|
||||
#ifdef ENABLE_HIDPI
|
||||
if (options.hidpiMap != _options.hidpiMap)
|
||||
_mapView->setDevicePixelRatio(options.hidpiMap ? devicePixelRatioF()
|
||||
: 1.0);
|
||||
#endif // ENABLE_HIDPI
|
||||
|
||||
if (reload)
|
||||
reloadFile();
|
||||
@ -1798,6 +1803,10 @@ void GUI::writeSettings()
|
||||
settings.setValue(SLIDER_COLOR_SETTING, _options.sliderColor);
|
||||
if (_options.alwaysShowMap != ALWAYS_SHOW_MAP_DEFAULT)
|
||||
settings.setValue(ALWAYS_SHOW_MAP_SETTING, _options.alwaysShowMap);
|
||||
#ifdef ENABLE_HIDPI
|
||||
if (_options.hidpiMap != HIDPI_MAP_DEFAULT)
|
||||
settings.setValue(HIDPI_MAP_SETTING, _options.hidpiMap);
|
||||
#endif // ENABLE_HIDPI
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
@ -2033,6 +2042,10 @@ void GUI::readSettings()
|
||||
SLIDER_COLOR_DEFAULT).value<QColor>();
|
||||
_options.alwaysShowMap = settings.value(ALWAYS_SHOW_MAP_SETTING,
|
||||
ALWAYS_SHOW_MAP_DEFAULT).toBool();
|
||||
#ifdef ENABLE_HIDPI
|
||||
_options.hidpiMap = settings.value(HIDPI_MAP_SETTING, HIDPI_MAP_SETTING)
|
||||
.toBool();
|
||||
#endif // ENABLE_HIDPI
|
||||
|
||||
_mapView->setPalette(_options.palette);
|
||||
_mapView->setMapOpacity(_options.mapOpacity);
|
||||
@ -2049,6 +2062,9 @@ void GUI::readSettings()
|
||||
_mapView->setMarkerColor(_options.sliderColor);
|
||||
if (_options.useOpenGL)
|
||||
_mapView->useOpenGL(true);
|
||||
#ifdef ENABLE_HIDPI
|
||||
_mapView->setDevicePixelRatio(_options.hidpiMap ? devicePixelRatioF() : 1.0);
|
||||
#endif // ENABLE_HIDPI
|
||||
|
||||
for (int i = 0; i < _tabs.count(); i++) {
|
||||
_tabs.at(i)->setPalette(_options.palette);
|
||||
@ -2134,7 +2150,7 @@ void GUI::show()
|
||||
void GUI::screenChanged(QScreen *screen)
|
||||
{
|
||||
#ifdef ENABLE_HIDPI
|
||||
_mapView->updateDevicePixelRatio();
|
||||
_mapView->setDevicePixelRatio(_options.hidpiMap ? devicePixelRatioF() : 1.0);
|
||||
|
||||
disconnect(SIGNAL(logicalDotsPerInchChanged(qreal)), this,
|
||||
SLOT(logicalDotsPerInchChanged(qreal)));
|
||||
@ -2150,6 +2166,6 @@ void GUI::logicalDotsPerInchChanged(qreal dpi)
|
||||
Q_UNUSED(dpi)
|
||||
|
||||
#ifdef ENABLE_HIDPI
|
||||
_mapView->updateDevicePixelRatio();
|
||||
_mapView->setDevicePixelRatio(_options.hidpiMap ? devicePixelRatioF() : 1.0);
|
||||
#endif // ENBLE_HIDPI
|
||||
}
|
||||
|
@ -25,5 +25,6 @@
|
||||
#define SYSTEM_ICON ":/icons/preferences-system.png"
|
||||
#define PRINT_EXPORT_ICON ":/icons/document-print_32.png"
|
||||
#define DATA_ICON ":/icons/view-filter.png"
|
||||
#define MAPS_ICON ":/icons/applications-internet_32.png"
|
||||
|
||||
#endif /* ICONS_H */
|
||||
|
@ -42,10 +42,6 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
||||
|
||||
_map = map;
|
||||
_map->load();
|
||||
#ifdef ENABLE_HIDPI
|
||||
_ratio = devicePixelRatioF();
|
||||
_map->setDevicePixelRatio(_ratio);
|
||||
#endif // ENABLE_HIDPI
|
||||
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
|
||||
|
||||
_poi = poi;
|
||||
@ -75,6 +71,9 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
||||
_poiSize = 8;
|
||||
_poiColor = Qt::black;
|
||||
|
||||
#ifdef ENABLE_HIDPI
|
||||
_ratio = 1.0;
|
||||
#endif // ENABLE_HIDPI
|
||||
_opengl = false;
|
||||
_plot = false;
|
||||
_digitalZoom = 0;
|
||||
@ -845,23 +844,19 @@ void MapView::reloadMap()
|
||||
_scene->invalidate();
|
||||
}
|
||||
|
||||
void MapView::updateDevicePixelRatio()
|
||||
void MapView::setDevicePixelRatio(qreal ratio)
|
||||
{
|
||||
#ifdef ENABLE_HIDPI
|
||||
if (_ratio == devicePixelRatioF())
|
||||
if (_ratio == ratio)
|
||||
return;
|
||||
|
||||
_ratio = devicePixelRatioF();
|
||||
_ratio = ratio;
|
||||
|
||||
QRectF vr(mapToScene(viewport()->rect()).boundingRect()
|
||||
.intersected(_map->bounds()));
|
||||
RectC cr(_map->xy2ll(vr.topLeft()), _map->xy2ll(vr.bottomRight()));
|
||||
|
||||
_map->setDevicePixelRatio(_ratio);
|
||||
|
||||
digitalZoom(0);
|
||||
|
||||
_map->zoomFit(viewport()->rect().size(), cr);
|
||||
_scene->setSceneRect(_map->bounds());
|
||||
|
||||
for (int i = 0; i < _tracks.size(); i++)
|
||||
@ -881,5 +876,7 @@ void MapView::updateDevicePixelRatio()
|
||||
centerOn(nc);
|
||||
|
||||
reloadMap();
|
||||
#else // ENABLE_HIDPI
|
||||
Q_UNUSED(ratio);
|
||||
#endif // ENABLE_HIDPI
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public slots:
|
||||
void showRouteWaypoints(bool show);
|
||||
void clearMapCache();
|
||||
void setCoordinatesFormat(CoordinatesFormat format);
|
||||
void updateDevicePixelRatio();
|
||||
void setDevicePixelRatio(qreal ratio);
|
||||
|
||||
private slots:
|
||||
void updatePOI();
|
||||
|
@ -34,26 +34,61 @@ static QFrame *line()
|
||||
}
|
||||
#endif
|
||||
|
||||
QWidget *OptionsDialog::createGeneralPage()
|
||||
QWidget *OptionsDialog::createMapPage()
|
||||
{
|
||||
_alwaysShowMap = new QCheckBox(tr("Always show the map"));
|
||||
_alwaysShowMap->setChecked(_options->alwaysShowMap);
|
||||
_alwaysShowMap->setToolTip("<p>" +
|
||||
tr("Show the map even when no files are loaded.") + "</p>");
|
||||
|
||||
#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 *showMapLayout = new QFormLayout();
|
||||
showMapLayout->addWidget(_alwaysShowMap);
|
||||
|
||||
QWidget *generalTab = new QWidget();
|
||||
QVBoxLayout *generalTabLayout = new QVBoxLayout();
|
||||
generalTabLayout->addLayout(showMapLayout);
|
||||
generalTabLayout->addStretch();
|
||||
generalTab->setLayout(generalTabLayout);
|
||||
QWidget *mapTab = new QWidget();
|
||||
QVBoxLayout *mapTabLayout = new QVBoxLayout();
|
||||
mapTabLayout->addLayout(showMapLayout);
|
||||
mapTabLayout->addStretch();
|
||||
mapTab->setLayout(mapTabLayout);
|
||||
|
||||
QTabWidget *generalPage = new QTabWidget();
|
||||
generalPage->addTab(generalTab, tr("General"));
|
||||
#ifdef ENABLE_HIDPI
|
||||
QVBoxLayout *hidpiTabLayout = new QVBoxLayout();
|
||||
hidpiTabLayout->addWidget(_lodpi);
|
||||
hidpiTabLayout->addWidget(llo);
|
||||
hidpiTabLayout->addSpacing(10);
|
||||
hidpiTabLayout->addWidget(_hidpi);
|
||||
hidpiTabLayout->addWidget(lhi);
|
||||
hidpiTabLayout->addStretch();
|
||||
|
||||
return generalPage;
|
||||
QWidget *hidpiTab = new QWidget();
|
||||
hidpiTab->setLayout(hidpiTabLayout);
|
||||
#endif // ENABLE_HIDPI
|
||||
|
||||
QTabWidget *mapPage = new QTabWidget();
|
||||
mapPage->addTab(mapTab, tr("General"));
|
||||
#ifdef ENABLE_HIDPI
|
||||
mapPage->addTab(hidpiTab, tr("HiDPI display mode"));
|
||||
#endif // ENABLE_HIDPI
|
||||
|
||||
return mapPage;
|
||||
}
|
||||
|
||||
QWidget *OptionsDialog::createAppearancePage()
|
||||
@ -483,8 +518,8 @@ OptionsDialog::OptionsDialog(Options *options, QWidget *parent)
|
||||
: QDialog(parent), _options(options)
|
||||
{
|
||||
QStackedWidget *pages = new QStackedWidget();
|
||||
pages->addWidget(createGeneralPage());
|
||||
pages->addWidget(createAppearancePage());
|
||||
pages->addWidget(createMapPage());
|
||||
pages->addWidget(createDataPage());
|
||||
pages->addWidget(createPOIPage());
|
||||
pages->addWidget(createExportPage());
|
||||
@ -492,9 +527,9 @@ OptionsDialog::OptionsDialog(Options *options, QWidget *parent)
|
||||
|
||||
QListWidget *menu = new QListWidget();
|
||||
menu->setIconSize(QSize(MENU_ICON_SIZE, MENU_ICON_SIZE));
|
||||
new QListWidgetItem(QIcon(APP_ICON), tr("General"), menu);
|
||||
new QListWidgetItem(QIcon(APPEARANCE_ICON), tr("Appearance"),
|
||||
menu);
|
||||
new QListWidgetItem(QIcon(MAPS_ICON), tr("Maps"), menu);
|
||||
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"),
|
||||
@ -532,8 +567,6 @@ 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();
|
||||
@ -553,6 +586,11 @@ void OptionsDialog::accept()
|
||||
_options->sliderColor = _sliderColor->color();
|
||||
_options->graphAntiAliasing = _graphAA->isChecked();
|
||||
|
||||
_options->alwaysShowMap = _alwaysShowMap->isChecked();
|
||||
#ifdef ENABLE_HIDPI
|
||||
_options->hidpiMap = _hidpi->isChecked();
|
||||
#endif // ENABLE_HIDPI
|
||||
|
||||
_options->elevationFilter = _elevationFilter->value();
|
||||
_options->speedFilter = _speedFilter->value();
|
||||
_options->heartRateFilter = _heartRateFilter->value();
|
||||
|
@ -18,8 +18,6 @@ class QRadioButton;
|
||||
class PercentSlider;
|
||||
|
||||
struct Options {
|
||||
// General
|
||||
bool alwaysShowMap;
|
||||
// Appearance
|
||||
Palette palette;
|
||||
int trackWidth;
|
||||
@ -36,6 +34,11 @@ struct Options {
|
||||
bool graphAntiAliasing;
|
||||
int mapOpacity;
|
||||
QColor backgroundColor;
|
||||
// Map
|
||||
bool alwaysShowMap;
|
||||
#ifdef ENABLE_HIDPI
|
||||
bool hidpiMap;
|
||||
#endif // ENABLE_HIDPI
|
||||
// Data
|
||||
int elevationFilter;
|
||||
int speedFilter;
|
||||
@ -79,7 +82,7 @@ public slots:
|
||||
void accept();
|
||||
|
||||
private:
|
||||
QWidget *createGeneralPage();
|
||||
QWidget *createMapPage();
|
||||
QWidget *createAppearancePage();
|
||||
QWidget *createDataPage();
|
||||
QWidget *createPOIPage();
|
||||
@ -88,8 +91,6 @@ private:
|
||||
|
||||
Options *_options;
|
||||
|
||||
// General
|
||||
QCheckBox *_alwaysShowMap;
|
||||
// Appearance
|
||||
ColorBox *_baseColor;
|
||||
QDoubleSpinBox *_colorOffset;
|
||||
@ -107,6 +108,12 @@ private:
|
||||
QSpinBox *_graphWidth;
|
||||
ColorBox *_sliderColor;
|
||||
QCheckBox *_graphAA;
|
||||
// Map
|
||||
QCheckBox *_alwaysShowMap;
|
||||
#ifdef ENABLE_HIDPI
|
||||
QRadioButton *_hidpi;
|
||||
QRadioButton *_lodpi;
|
||||
#endif // ENABLE_HIDPI
|
||||
// Data
|
||||
OddSpinBox *_elevationFilter;
|
||||
OddSpinBox *_speedFilter;
|
||||
|
@ -156,5 +156,7 @@
|
||||
#define SLIDER_COLOR_DEFAULT QColor(Qt::red)
|
||||
#define ALWAYS_SHOW_MAP_SETTING "alwaysShowMap"
|
||||
#define ALWAYS_SHOW_MAP_DEFAULT true
|
||||
#define HIDPI_MAP_SETTING "HiDPIMap"
|
||||
#define HIDPI_MAP_DEFAULT true
|
||||
|
||||
#endif // SETTINGS_H
|
||||
|
Loading…
Reference in New Issue
Block a user