1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Settings improvements and code cleanup

This commit is contained in:
Martin Tůma 2017-09-15 00:07:09 +02:00
parent a7506cfd82
commit b9489afbfe
14 changed files with 131 additions and 124 deletions

View File

@ -310,7 +310,7 @@ void Atlas::draw(QPainter *painter, const QRectF &rect)
} }
// Multiple maps // Multiple maps
painter->fillRect(rect, Qt::white); painter->fillRect(rect, _backgroundColor);
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) { for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
QRectF ir = rect.intersected(_bounds.at(i).second); QRectF ir = rect.intersected(_bounds.at(i).second);
if (!ir.isNull()) if (!ir.isNull())

View File

@ -70,7 +70,7 @@ qreal EmptyMap::zoomOut()
void EmptyMap::draw(QPainter *painter, const QRectF &rect) void EmptyMap::draw(QPainter *painter, const QRectF &rect)
{ {
painter->fillRect(rect, Qt::white); painter->fillRect(rect, _backgroundColor);
} }
QPointF EmptyMap::ll2xy(const Coordinates &c) QPointF EmptyMap::ll2xy(const Coordinates &c)

View File

@ -461,3 +461,8 @@ void GraphView::useOpenGL(bool use)
else else
setViewport(new QWidget); setViewport(new QWidget);
} }
void GraphView::useAntiAliasing(bool use)
{
setRenderHint(QPainter::Antialiasing, use);
}

View File

@ -56,6 +56,7 @@ public:
void plot(QPainter *painter, const QRectF &target, qreal scale); void plot(QPainter *painter, const QRectF &target, qreal scale);
void useOpenGL(bool use); void useOpenGL(bool use);
void useAntiAliasing(bool use);
signals: signals:
void sliderPositionChanged(qreal); void sliderPositionChanged(qreal);

View File

@ -857,6 +857,19 @@ void GUI::closePOIFiles()
void GUI::openOptions() void GUI::openOptions()
{ {
#define SET_VIEW_OPTION(option, action) \
if (options.option != _options.option) \
_pathView->action(options.option)
#define SET_TAB_OPTION(option, action) \
if (options.option != _options.option) \
for (int i = 0; i < _tabs.count(); i++) \
_tabs.at(i)->action(options.option)
#define SET_TRACK_OPTION(option, action) \
if (options.option != _options.option) { \
Track::action(options.option); \
reload = true; \
}
Options options(_options); Options options(_options);
bool reload = false; bool reload = false;
@ -864,83 +877,36 @@ void GUI::openOptions()
if (dialog.exec() != QDialog::Accepted) if (dialog.exec() != QDialog::Accepted)
return; return;
if (options.palette != _options.palette) { SET_VIEW_OPTION(palette, setPalette);
_pathView->setPalette(options.palette); SET_VIEW_OPTION(mapOpacity, setMapOpacity);
for (int i = 0; i < _tabs.count(); i++) SET_VIEW_OPTION(backgroundColor, setBackgroundColor);
_tabs.at(i)->setPalette(options.palette); SET_VIEW_OPTION(trackWidth, setTrackWidth);
} SET_VIEW_OPTION(routeWidth, setRouteWidth);
if (options.mapOpacity != _options.mapOpacity) SET_VIEW_OPTION(trackStyle, setTrackStyle);
_pathView->setMapOpacity(options.mapOpacity); SET_VIEW_OPTION(routeStyle, setRouteStyle);
if (options.blendColor != _options.blendColor) SET_VIEW_OPTION(waypointSize, setWaypointSize);
_pathView->setBlendColor(options.blendColor); SET_VIEW_OPTION(waypointColor, setWaypointColor);
if (options.trackWidth != _options.trackWidth) SET_VIEW_OPTION(poiSize, setPOISize);
_pathView->setTrackWidth(options.trackWidth); SET_VIEW_OPTION(poiColor, setPOIColor);
if (options.routeWidth != _options.routeWidth) SET_VIEW_OPTION(pathAntiAliasing, useAntiAliasing);
_pathView->setRouteWidth(options.routeWidth); SET_VIEW_OPTION(useOpenGL, useOpenGL);
if (options.trackStyle != _options.trackStyle)
_pathView->setTrackStyle(options.trackStyle);
if (options.routeStyle != _options.routeStyle)
_pathView->setRouteStyle(options.routeStyle);
if (options.waypointSize != _options.waypointSize)
_pathView->setWaypointSize(options.waypointSize);
if (options.waypointColor != _options.waypointColor)
_pathView->setWaypointColor(options.waypointColor);
if (options.poiSize != _options.poiSize)
_pathView->setPOISize(options.poiSize);
if (options.poiColor != _options.poiColor)
_pathView->setPOIColor(options.poiColor);
if (options.pathAntiAliasing != _options.pathAntiAliasing)
_pathView->setRenderHint(QPainter::Antialiasing,
options.pathAntiAliasing);
if (options.graphWidth != _options.graphWidth)
for (int i = 0; i < _tabs.count(); i++)
_tabs.at(i)->setGraphWidth(options.graphWidth);
if (options.graphAntiAliasing != _options.graphAntiAliasing)
for (int i = 0; i < _tabs.count(); i++)
_tabs.at(i)->setRenderHint(QPainter::Antialiasing,
options.graphAntiAliasing);
if (options.elevationFilter != _options.elevationFilter) { SET_TAB_OPTION(palette, setPalette);
Track::setElevationFilter(options.elevationFilter); SET_TAB_OPTION(graphWidth, setGraphWidth);
reload = true; SET_TAB_OPTION(graphAntiAliasing, useAntiAliasing);
} SET_TAB_OPTION(useOpenGL, useOpenGL);
if (options.speedFilter != _options.speedFilter) {
Track::setSpeedFilter(options.speedFilter); SET_TRACK_OPTION(elevationFilter, setElevationFilter);
reload = true; SET_TRACK_OPTION(speedFilter, setSpeedFilter);
} SET_TRACK_OPTION(heartRateFilter, setHeartRateFilter);
if (options.heartRateFilter != _options.heartRateFilter) { SET_TRACK_OPTION(cadenceFilter, setCadenceFilter);
Track::setHeartRateFilter(options.heartRateFilter); SET_TRACK_OPTION(powerFilter, setPowerFilter);
reload = true; SET_TRACK_OPTION(outlierEliminate, setOutlierElimination);
} SET_TRACK_OPTION(pauseSpeed, setPauseSpeed);
if (options.cadenceFilter != _options.cadenceFilter) { SET_TRACK_OPTION(pauseInterval, setPauseInterval);
Track::setCadenceFilter(options.cadenceFilter);
reload = true;
}
if (options.powerFilter != _options.powerFilter) {
Track::setPowerFilter(options.powerFilter);
reload = true;
}
if (options.outlierEliminate != _options.outlierEliminate) {
Track::setOutlierElimination(options.outlierEliminate);
reload = true;
}
if (options.pauseSpeed != _options.pauseSpeed) {
Track::setPauseSpeed(options.pauseSpeed);
reload = true;
}
if (options.pauseInterval != _options.pauseInterval) {
Track::setPauseInterval(options.pauseInterval);
reload = true;
}
if (options.poiRadius != _options.poiRadius) if (options.poiRadius != _options.poiRadius)
_poi->setRadius(options.poiRadius); _poi->setRadius(options.poiRadius);
if (options.useOpenGL != _options.useOpenGL) {
_pathView->useOpenGL(options.useOpenGL);
for (int i = 0; i < _tabs.count(); i++)
_tabs.at(i)->useOpenGL(options.useOpenGL);
}
if (options.pixmapCache != _options.pixmapCache) if (options.pixmapCache != _options.pixmapCache)
QPixmapCache::setCacheLimit(options.pixmapCache * 1024); QPixmapCache::setCacheLimit(options.pixmapCache * 1024);
@ -1618,8 +1584,8 @@ void GUI::writeSettings()
settings.setValue(PALETTE_SHIFT_SETTING, _options.palette.shift()); settings.setValue(PALETTE_SHIFT_SETTING, _options.palette.shift());
if (_options.mapOpacity != MAP_OPACITY_DEFAULT) if (_options.mapOpacity != MAP_OPACITY_DEFAULT)
settings.setValue(MAP_OPACITY_SETTING, _options.mapOpacity); settings.setValue(MAP_OPACITY_SETTING, _options.mapOpacity);
if (_options.blendColor != BLEND_COLOR_DEFAULT) if (_options.backgroundColor != BACKGROUND_COLOR_DEFAULT)
settings.setValue(BLEND_COLOR_SETTING, _options.blendColor); settings.setValue(BACKGROUND_COLOR_SETTING, _options.backgroundColor);
if (_options.trackWidth != TRACK_WIDTH_DEFAULT) if (_options.trackWidth != TRACK_WIDTH_DEFAULT)
settings.setValue(TRACK_WIDTH_SETTING, _options.trackWidth); settings.setValue(TRACK_WIDTH_SETTING, _options.trackWidth);
if (_options.routeWidth != ROUTE_WIDTH_DEFAULT) if (_options.routeWidth != ROUTE_WIDTH_DEFAULT)
@ -1829,8 +1795,8 @@ void GUI::readSettings()
_options.palette = Palette(pc, ps); _options.palette = Palette(pc, ps);
_options.mapOpacity = settings.value(MAP_OPACITY_SETTING, _options.mapOpacity = settings.value(MAP_OPACITY_SETTING,
MAP_OPACITY_DEFAULT).toInt(); MAP_OPACITY_DEFAULT).toInt();
_options.blendColor = settings.value(BLEND_COLOR_SETTING, _options.backgroundColor = settings.value(BACKGROUND_COLOR_SETTING,
BLEND_COLOR_DEFAULT).value<QColor>(); BACKGROUND_COLOR_DEFAULT).value<QColor>();
_options.trackWidth = settings.value(TRACK_WIDTH_SETTING, _options.trackWidth = settings.value(TRACK_WIDTH_SETTING,
TRACK_WIDTH_DEFAULT).toInt(); TRACK_WIDTH_DEFAULT).toInt();
_options.routeWidth = settings.value(ROUTE_WIDTH_SETTING, _options.routeWidth = settings.value(ROUTE_WIDTH_SETTING,
@ -1894,7 +1860,7 @@ void GUI::readSettings()
_pathView->setPalette(_options.palette); _pathView->setPalette(_options.palette);
_pathView->setMapOpacity(_options.mapOpacity); _pathView->setMapOpacity(_options.mapOpacity);
_pathView->setBlendColor(_options.blendColor); _pathView->setBackgroundColor(_options.backgroundColor);
_pathView->setTrackWidth(_options.trackWidth); _pathView->setTrackWidth(_options.trackWidth);
_pathView->setRouteWidth(_options.routeWidth); _pathView->setRouteWidth(_options.routeWidth);
_pathView->setTrackStyle(_options.trackStyle); _pathView->setTrackStyle(_options.trackStyle);

View File

@ -4,6 +4,7 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QRectF> #include <QRectF>
#include <QColor>
class QPainter; class QPainter;
class Coordinates; class Coordinates;
@ -14,7 +15,7 @@ class Map : public QObject
Q_OBJECT Q_OBJECT
public: public:
Map(QObject *parent = 0) : QObject(parent) {} Map(QObject *parent = 0) : QObject(parent) {_backgroundColor = Qt::white;}
virtual const QString &name() const = 0; virtual const QString &name() const = 0;
@ -37,8 +38,13 @@ public:
virtual void load() {} virtual void load() {}
virtual void unload() {} virtual void unload() {}
void setBackgroundColor(const QColor &color) {_backgroundColor = color;}
signals: signals:
void loaded(); void loaded();
protected:
QColor _backgroundColor;
}; };
#endif // MAP_H #endif // MAP_H

View File

@ -609,7 +609,8 @@ void OfflineMap::drawTiled(QPainter *painter, const QRectF &rect)
int y = tl.y() + j * _tileSize.height(); int y = tl.y() + j * _tileSize.height();
if (!QRectF(QPointF(x, y), _tileSize).intersects(bounds())) { if (!QRectF(QPointF(x, y), _tileSize).intersects(bounds())) {
painter->fillRect(QRectF(QPoint(x, y), _tileSize), Qt::white); painter->fillRect(QRectF(QPoint(x, y), _tileSize),
_backgroundColor);
continue; continue;
} }
@ -631,7 +632,8 @@ void OfflineMap::drawTiled(QPainter *painter, const QRectF &rect)
if (pixmap.isNull()) { if (pixmap.isNull()) {
qWarning("%s: error loading tile image", qPrintable( qWarning("%s: error loading tile image", qPrintable(
_tileName.arg(QString::number(x), QString::number(y)))); _tileName.arg(QString::number(x), QString::number(y))));
painter->fillRect(QRectF(QPoint(x, y), _tileSize), Qt::white); painter->fillRect(QRectF(QPoint(x, y), _tileSize),
_backgroundColor);
} else } else
painter->drawPixmap(QPoint(x, y), pixmap); painter->drawPixmap(QPoint(x, y), pixmap);
} }
@ -652,7 +654,7 @@ void OfflineMap::drawOZF(QPainter *painter, const QRectF &rect)
if (!QRectF(QPointF(x, y), _ozf.tileSize()).intersects(bounds())) { if (!QRectF(QPointF(x, y), _ozf.tileSize()).intersects(bounds())) {
painter->fillRect(QRectF(QPoint(x, y), _ozf.tileSize()), painter->fillRect(QRectF(QPoint(x, y), _ozf.tileSize()),
Qt::white); _backgroundColor);
continue; continue;
} }
@ -668,7 +670,7 @@ void OfflineMap::drawOZF(QPainter *painter, const QRectF &rect)
if (pixmap.isNull()) { if (pixmap.isNull()) {
qWarning("%s: error loading tile image", qPrintable(key)); qWarning("%s: error loading tile image", qPrintable(key));
painter->fillRect(QRectF(QPoint(x, y), _ozf.tileSize()), painter->fillRect(QRectF(QPoint(x, y), _ozf.tileSize()),
Qt::white); _backgroundColor);
} else } else
painter->drawPixmap(QPoint(x, y), pixmap); painter->drawPixmap(QPoint(x, y), pixmap);
} }
@ -678,7 +680,7 @@ void OfflineMap::drawOZF(QPainter *painter, const QRectF &rect)
void OfflineMap::drawImage(QPainter *painter, const QRectF &rect) void OfflineMap::drawImage(QPainter *painter, const QRectF &rect)
{ {
if (!_img || _img->isNull()) if (!_img || _img->isNull())
painter->fillRect(rect, Qt::white); painter->fillRect(rect, _backgroundColor);
else { else {
QRect r(rect.toRect()); QRect r(rect.toRect());
painter->drawImage(r.left(), r.top(), *_img, r.left(), r.top(), painter->drawImage(r.left(), r.top(), *_img, r.left(), r.top(),

View File

@ -34,12 +34,6 @@ static int scale2zoom(qreal scale)
return (int)log2(360.0/(scale * (qreal)TILE_SIZE)); return (int)log2(360.0/(scale * (qreal)TILE_SIZE));
} }
static void fillTile(Tile &tile)
{
tile.pixmap() = QPixmap(TILE_SIZE, TILE_SIZE);
tile.pixmap().fill();
}
static bool loadTileFile(Tile &tile, const QString &file) static bool loadTileFile(Tile &tile, const QString &file)
{ {
if (!tile.pixmap().load(file)) { if (!tile.pixmap().load(file)) {
@ -69,6 +63,12 @@ OnlineMap::OnlineMap(const QString &name, const QString &url,
qWarning("Error creating tiles dir: %s\n", qPrintable(path)); qWarning("Error creating tiles dir: %s\n", qPrintable(path));
} }
void OnlineMap::fillTile(Tile &tile)
{
tile.pixmap() = QPixmap(TILE_SIZE, TILE_SIZE);
tile.pixmap().fill(_backgroundColor);
}
void OnlineMap::emitLoaded() void OnlineMap::emitLoaded()
{ {
emit loaded(); emit loaded();

View File

@ -41,6 +41,7 @@ private slots:
void emitLoaded(); void emitLoaded();
private: private:
void fillTile(Tile &tile);
QString tileUrl(const Tile &tile) const; QString tileUrl(const Tile &tile) const;
QString tileFile(const Tile &tile) const; QString tileFile(const Tile &tile) const;
void loadTilesAsync(QList<Tile> &list); void loadTilesAsync(QList<Tile> &list);

View File

@ -51,7 +51,7 @@ QWidget *OptionsDialog::createAppearancePage()
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
QGroupBox *colorBox = new QGroupBox(tr("Colors")); QGroupBox *colorBox = new QGroupBox(tr("Colors"));
colorBox->setLayout(paletteLayout); colorBox->setLayout(paletteLayout);
#endif #endif // Q_OS_MAC
_trackWidth = new QSpinBox(); _trackWidth = new QSpinBox();
_trackWidth->setValue(_options->trackWidth); _trackWidth->setValue(_options->trackWidth);
@ -59,12 +59,15 @@ QWidget *OptionsDialog::createAppearancePage()
_trackStyle = new StyleComboBox(); _trackStyle = new StyleComboBox();
_trackStyle->setValue(_options->trackStyle); _trackStyle->setValue(_options->trackStyle);
QFormLayout *trackLayout = new QFormLayout(); QFormLayout *trackLayout = new QFormLayout();
#ifdef Q_OS_MAC
trackLayout->addRow(tr("Track width:"), _trackWidth); trackLayout->addRow(tr("Track width:"), _trackWidth);
trackLayout->addRow(tr("Track style:"), _trackStyle); trackLayout->addRow(tr("Track style:"), _trackStyle);
#ifndef Q_OS_MAC #else // Q_OS_MAC
trackLayout->addRow(tr("Width:"), _trackWidth);
trackLayout->addRow(tr("Style:"), _trackStyle);
QGroupBox *trackBox = new QGroupBox(tr("Tracks")); QGroupBox *trackBox = new QGroupBox(tr("Tracks"));
trackBox->setLayout(trackLayout); trackBox->setLayout(trackLayout);
#endif #endif // Q_OS_MAC
_routeWidth = new QSpinBox(); _routeWidth = new QSpinBox();
_routeWidth->setValue(_options->routeWidth); _routeWidth->setValue(_options->routeWidth);
@ -72,9 +75,12 @@ QWidget *OptionsDialog::createAppearancePage()
_routeStyle = new StyleComboBox(); _routeStyle = new StyleComboBox();
_routeStyle->setValue(_options->routeStyle); _routeStyle->setValue(_options->routeStyle);
QFormLayout *routeLayout = new QFormLayout(); QFormLayout *routeLayout = new QFormLayout();
#ifdef Q_OS_MAC
routeLayout->addRow(tr("Route width:"), _routeWidth); routeLayout->addRow(tr("Route width:"), _routeWidth);
routeLayout->addRow(tr("Route style:"), _routeStyle); routeLayout->addRow(tr("Route style:"), _routeStyle);
#ifndef Q_OS_MAC #else // Q_OS_MAC
routeLayout->addRow(tr("Width:"), _routeWidth);
routeLayout->addRow(tr("Style:"), _routeStyle);
QGroupBox *routeBox = new QGroupBox(tr("Routes")); QGroupBox *routeBox = new QGroupBox(tr("Routes"));
routeBox->setLayout(routeLayout); routeBox->setLayout(routeLayout);
#endif // Q_OS_MAC #endif // Q_OS_MAC
@ -105,25 +111,33 @@ QWidget *OptionsDialog::createAppearancePage()
// Waypoints // Waypoints
_waypointSize = new QSpinBox(); _waypointSize = new QSpinBox();
_waypointSize->setMinimum(1);
_waypointSize->setValue(_options->waypointSize); _waypointSize->setValue(_options->waypointSize);
_waypointColor = new ColorBox(); _waypointColor = new ColorBox();
_waypointColor->setColor(_options->waypointColor); _waypointColor->setColor(_options->waypointColor);
QFormLayout *waypointLayout = new QFormLayout(); QFormLayout *waypointLayout = new QFormLayout();
#ifdef Q_OS_MAC
waypointLayout->addRow(tr("Waypoint color:"), _waypointColor); waypointLayout->addRow(tr("Waypoint color:"), _waypointColor);
waypointLayout->addRow(tr("Waypoint size:"), _waypointSize); waypointLayout->addRow(tr("Waypoint size:"), _waypointSize);
#ifndef Q_OS_MAC #else // Q_OS_MAC
waypointLayout->addRow(tr("Color:"), _waypointColor);
waypointLayout->addRow(tr("Size:"), _waypointSize);
QGroupBox *waypointBox = new QGroupBox(tr("Waypoints")); QGroupBox *waypointBox = new QGroupBox(tr("Waypoints"));
waypointBox->setLayout(waypointLayout); waypointBox->setLayout(waypointLayout);
#endif // Q_OS_MAC #endif // Q_OS_MAC
_poiSize = new QSpinBox(); _poiSize = new QSpinBox();
_poiSize->setMinimum(1);
_poiSize->setValue(_options->poiSize); _poiSize->setValue(_options->poiSize);
_poiColor = new ColorBox(); _poiColor = new ColorBox();
_poiColor->setColor(_options->poiColor); _poiColor->setColor(_options->poiColor);
QFormLayout *poiLayout = new QFormLayout(); QFormLayout *poiLayout = new QFormLayout();
#ifdef Q_OS_MAC
poiLayout->addRow(tr("POI color:"), _poiColor); poiLayout->addRow(tr("POI color:"), _poiColor);
poiLayout->addRow(tr("POI size:"), _poiSize); poiLayout->addRow(tr("POI size:"), _poiSize);
#ifndef Q_OS_MAC #else // Q_OS_MAC
poiLayout->addRow(tr("Color:"), _poiColor);
poiLayout->addRow(tr("Size:"), _poiSize);
QGroupBox *poiBox = new QGroupBox(tr("POIs")); QGroupBox *poiBox = new QGroupBox(tr("POIs"));
poiBox->setLayout(poiLayout); poiBox->setLayout(poiLayout);
#endif // Q_OS_MAC #endif // Q_OS_MAC
@ -165,10 +179,10 @@ QWidget *OptionsDialog::createAppearancePage()
// Map // Map
_mapOpacity = new PercentSlider(); _mapOpacity = new PercentSlider();
_mapOpacity->setValue(_options->mapOpacity); _mapOpacity->setValue(_options->mapOpacity);
_blendColor = new ColorBox(); _backgroundColor = new ColorBox();
_blendColor->setColor(_options->blendColor); _backgroundColor->setColor(_options->backgroundColor);
QFormLayout *mapLayout = new QFormLayout(); QFormLayout *mapLayout = new QFormLayout();
mapLayout->addRow(tr("Background color:"), _blendColor); mapLayout->addRow(tr("Background color:"), _backgroundColor);
mapLayout->addRow(tr("Map opacity:"), _mapOpacity); mapLayout->addRow(tr("Map opacity:"), _mapOpacity);
QWidget *mapTab = new QWidget(); QWidget *mapTab = new QWidget();
@ -457,7 +471,7 @@ void OptionsDialog::accept()
_options->palette.setColor(_baseColor->color()); _options->palette.setColor(_baseColor->color());
_options->palette.setShift(_colorOffset->value()); _options->palette.setShift(_colorOffset->value());
_options->mapOpacity = _mapOpacity->value(); _options->mapOpacity = _mapOpacity->value();
_options->blendColor = _blendColor->color(); _options->backgroundColor = _backgroundColor->color();
_options->trackWidth = _trackWidth->value(); _options->trackWidth = _trackWidth->value();
_options->trackStyle = (Qt::PenStyle) _trackStyle->itemData( _options->trackStyle = (Qt::PenStyle) _trackStyle->itemData(
_trackStyle->currentIndex()).toInt(); _trackStyle->currentIndex()).toInt();
@ -478,12 +492,16 @@ void OptionsDialog::accept()
_options->cadenceFilter = _cadenceFilter->value(); _options->cadenceFilter = _cadenceFilter->value();
_options->powerFilter = _powerFilter->value(); _options->powerFilter = _powerFilter->value();
_options->outlierEliminate = _outlierEliminate->isChecked(); _options->outlierEliminate = _outlierEliminate->isChecked();
_options->pauseSpeed = (_options->units == Imperial) qreal pauseSpeed = (_options->units == Imperial)
? _pauseSpeed->value() / MS2MIH : _pauseSpeed->value() / MS2KMH; ? _pauseSpeed->value() / MS2MIH : _pauseSpeed->value() / MS2KMH;
if (qAbs(pauseSpeed - _options->pauseSpeed) > 0.01)
_options->pauseSpeed = pauseSpeed;
_options->pauseInterval = _pauseInterval->value(); _options->pauseInterval = _pauseInterval->value();
_options->poiRadius = (_options->units == Imperial) qreal poiRadius = (_options->units == Imperial)
? _poiRadius->value() * MIINM : _poiRadius->value() * KMINM; ? _poiRadius->value() * MIINM : _poiRadius->value() * KMINM;
if (qAbs(poiRadius - _options->poiRadius) > 0.01)
_options->poiRadius = poiRadius;
_options->useOpenGL = _useOpenGL->isChecked(); _options->useOpenGL = _useOpenGL->isChecked();
_options->pixmapCache = _pixmapCache->value(); _options->pixmapCache = _pixmapCache->value();

View File

@ -30,7 +30,7 @@ struct Options {
bool pathAntiAliasing; bool pathAntiAliasing;
bool graphAntiAliasing; bool graphAntiAliasing;
int mapOpacity; int mapOpacity;
QColor blendColor; QColor backgroundColor;
// Data // Data
int elevationFilter; int elevationFilter;
int speedFilter; int speedFilter;
@ -81,7 +81,7 @@ private:
ColorBox *_baseColor; ColorBox *_baseColor;
QDoubleSpinBox *_colorOffset; QDoubleSpinBox *_colorOffset;
PercentSlider *_mapOpacity; PercentSlider *_mapOpacity;
ColorBox *_blendColor; ColorBox *_backgroundColor;
QSpinBox *_trackWidth; QSpinBox *_trackWidth;
StyleComboBox *_trackStyle; StyleComboBox *_trackStyle;
QSpinBox *_routeWidth; QSpinBox *_routeWidth;

View File

@ -47,7 +47,7 @@ PathView::PathView(Map *map, POI *poi, QWidget *parent)
_units = Metric; _units = Metric;
_opacity = 1.0; _opacity = 1.0;
_blendColor = Qt::white; _backgroundColor = Qt::white;
_showMap = true; _showMap = true;
_showTracks = true; _showTracks = true;
@ -70,6 +70,7 @@ PathView::PathView(Map *map, POI *poi, QWidget *parent)
_plot = false; _plot = false;
_digitalZoom = 0; _digitalZoom = 0;
_map->setBackgroundColor(_backgroundColor);
_scene->setSceneRect(_map->bounds()); _scene->setSceneRect(_map->bounds());
_res = _map->resolution(_scene->sceneRect().center()); _res = _map->resolution(_scene->sceneRect().center());
} }
@ -730,9 +731,10 @@ void PathView::setMapOpacity(int opacity)
resetCachedContent(); resetCachedContent();
} }
void PathView::setBlendColor(const QColor &color) void PathView::setBackgroundColor(const QColor &color)
{ {
_blendColor = color; _backgroundColor = color;
_map->setBackgroundColor(color);
resetCachedContent(); resetCachedContent();
} }
@ -740,12 +742,12 @@ void PathView::drawBackground(QPainter *painter, const QRectF &rect)
{ {
if (_showMap) { if (_showMap) {
if (_opacity < 1.0) { if (_opacity < 1.0) {
painter->fillRect(rect, _blendColor); painter->fillRect(rect, _backgroundColor);
painter->setOpacity(_opacity); painter->setOpacity(_opacity);
} }
_map->draw(painter, rect); _map->draw(painter, rect);
} else } else
painter->fillRect(rect, Qt::white); painter->fillRect(rect, _backgroundColor);
} }
void PathView::resizeEvent(QResizeEvent *event) void PathView::resizeEvent(QResizeEvent *event)
@ -794,3 +796,8 @@ void PathView::useOpenGL(bool use)
else else
setViewport(new QWidget); setViewport(new QWidget);
} }
void PathView::useAntiAliasing(bool use)
{
setRenderHint(QPainter::Antialiasing, use);
}

View File

@ -45,7 +45,18 @@ public:
void clear(); void clear();
void setTrackWidth(int width);
void setRouteWidth(int width);
void setTrackStyle(Qt::PenStyle style);
void setRouteStyle(Qt::PenStyle style);
void setWaypointSize(int size);
void setWaypointColor(const QColor &color);
void setPOISize(int size);
void setPOIColor(const QColor &color);
void setMapOpacity(int opacity);
void setBackgroundColor(const QColor &color);
void useOpenGL(bool use); void useOpenGL(bool use);
void useAntiAliasing(bool use);
public slots: public slots:
void redraw(); void redraw();
@ -59,16 +70,6 @@ public slots:
void showRoutes(bool show); void showRoutes(bool show);
void showWaypoints(bool show); void showWaypoints(bool show);
void showRouteWaypoints(bool show); void showRouteWaypoints(bool show);
void setTrackWidth(int width);
void setRouteWidth(int width);
void setTrackStyle(Qt::PenStyle style);
void setRouteStyle(Qt::PenStyle style);
void setWaypointSize(int size);
void setWaypointColor(const QColor &color);
void setPOISize(int size);
void setPOIColor(const QColor &color);
void setMapOpacity(int opacity);
void setBlendColor(const QColor &color);
private slots: private slots:
void updatePOI(); void updatePOI();
@ -114,7 +115,7 @@ private:
Units _units; Units _units;
qreal _opacity; qreal _opacity;
QColor _blendColor; QColor _backgroundColor;
bool _showMap; bool _showMap;
bool _showTracks; bool _showTracks;
bool _showRoutes; bool _showRoutes;

View File

@ -80,8 +80,8 @@
#define PALETTE_SHIFT_DEFAULT 0.62 #define PALETTE_SHIFT_DEFAULT 0.62
#define MAP_OPACITY_SETTING "mapOpacity" #define MAP_OPACITY_SETTING "mapOpacity"
#define MAP_OPACITY_DEFAULT 100 #define MAP_OPACITY_DEFAULT 100
#define BLEND_COLOR_SETTING "blendColor" #define BACKGROUND_COLOR_SETTING "backgroundColor"
#define BLEND_COLOR_DEFAULT QColor(Qt::white) #define BACKGROUND_COLOR_DEFAULT QColor(Qt::white)
#define TRACK_WIDTH_SETTING "trackWidth" #define TRACK_WIDTH_SETTING "trackWidth"
#define TRACK_WIDTH_DEFAULT 3 #define TRACK_WIDTH_DEFAULT 3
#define ROUTE_WIDTH_SETTING "routeWidth" #define ROUTE_WIDTH_SETTING "routeWidth"