mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-18 19:52:09 +01:00
Added slider/marker color setting
This commit is contained in:
parent
a20a268975
commit
cbdfe4c105
@ -490,3 +490,9 @@ void GraphView::useAntiAliasing(bool use)
|
||||
{
|
||||
setRenderHint(QPainter::Antialiasing, use);
|
||||
}
|
||||
|
||||
void GraphView::setSliderColor(const QColor &color)
|
||||
{
|
||||
_slider->setColor(color);
|
||||
_sliderInfo->setColor(color);
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
void useAntiAliasing(bool use);
|
||||
|
||||
void setSliderPosition(qreal pos);
|
||||
void setSliderColor(const QColor &color);
|
||||
|
||||
signals:
|
||||
void sliderPositionChanged(qreal);
|
||||
|
@ -850,11 +850,13 @@ void GUI::openOptions()
|
||||
SET_VIEW_OPTION(poiColor, setPOIColor);
|
||||
SET_VIEW_OPTION(pathAntiAliasing, useAntiAliasing);
|
||||
SET_VIEW_OPTION(useOpenGL, useOpenGL);
|
||||
SET_VIEW_OPTION(sliderColor, setMarkerColor);
|
||||
|
||||
SET_TAB_OPTION(palette, setPalette);
|
||||
SET_TAB_OPTION(graphWidth, setGraphWidth);
|
||||
SET_TAB_OPTION(graphAntiAliasing, useAntiAliasing);
|
||||
SET_TAB_OPTION(useOpenGL, useOpenGL);
|
||||
SET_TAB_OPTION(sliderColor, setSliderColor);
|
||||
|
||||
SET_TRACK_OPTION(elevationFilter, setElevationFilter);
|
||||
SET_TRACK_OPTION(speedFilter, setSpeedFilter);
|
||||
@ -1627,6 +1629,8 @@ void GUI::writeSettings()
|
||||
if (_options.separateGraphPage != SEPARATE_GRAPH_PAGE_DEFAULT)
|
||||
settings.setValue(SEPARATE_GRAPH_PAGE_SETTING,
|
||||
_options.separateGraphPage);
|
||||
if (_options.sliderColor != SLIDER_COLOR_DEFAULT)
|
||||
settings.setValue(SLIDER_COLOR_SETTING, _options.sliderColor);
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
@ -1840,6 +1844,8 @@ void GUI::readSettings()
|
||||
PRINT_ITEM_COUNT_DEFAULT).toBool();
|
||||
_options.separateGraphPage = settings.value(SEPARATE_GRAPH_PAGE_SETTING,
|
||||
SEPARATE_GRAPH_PAGE_DEFAULT).toBool();
|
||||
_options.sliderColor = settings.value(SLIDER_COLOR_SETTING,
|
||||
SLIDER_COLOR_DEFAULT).value<QColor>();
|
||||
|
||||
_mapView->setPalette(_options.palette);
|
||||
_mapView->setMapOpacity(_options.mapOpacity);
|
||||
@ -1853,6 +1859,7 @@ void GUI::readSettings()
|
||||
_mapView->setPOISize(_options.poiSize);
|
||||
_mapView->setPOIColor(_options.poiColor);
|
||||
_mapView->setRenderHint(QPainter::Antialiasing, _options.pathAntiAliasing);
|
||||
_mapView->setMarkerColor(_options.sliderColor);
|
||||
if (_options.useOpenGL)
|
||||
_mapView->useOpenGL(true);
|
||||
|
||||
@ -1861,6 +1868,7 @@ void GUI::readSettings()
|
||||
_tabs.at(i)->setGraphWidth(_options.graphWidth);
|
||||
_tabs.at(i)->setRenderHint(QPainter::Antialiasing,
|
||||
_options.graphAntiAliasing);
|
||||
_tabs.at(i)->setSliderColor(_options.sliderColor);
|
||||
if (_options.useOpenGL)
|
||||
_tabs.at(i)->useOpenGL(true);
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
||||
_units = Metric;
|
||||
_opacity = 1.0;
|
||||
_backgroundColor = Qt::white;
|
||||
_markerColor = Qt::red;
|
||||
|
||||
_showMap = true;
|
||||
_showTracks = true;
|
||||
@ -113,6 +114,7 @@ PathItem *MapView::addTrack(const Track &track)
|
||||
ti->setUnits(_units);
|
||||
ti->setVisible(_showTracks);
|
||||
ti->setDigitalZoom(_digitalZoom);
|
||||
ti->setMarkerColor(_markerColor);
|
||||
_scene->addItem(ti);
|
||||
|
||||
if (_showTracks)
|
||||
@ -139,6 +141,7 @@ PathItem *MapView::addRoute(const Route &route)
|
||||
ri->showWaypoints(_showRouteWaypoints);
|
||||
ri->showWaypointLabels(_showWaypointLabels);
|
||||
ri->setDigitalZoom(_digitalZoom);
|
||||
ri->setMarkerColor(_markerColor);
|
||||
_scene->addItem(ri);
|
||||
|
||||
if (_showRoutes)
|
||||
@ -791,6 +794,16 @@ void MapView::useAntiAliasing(bool use)
|
||||
setRenderHint(QPainter::Antialiasing, use);
|
||||
}
|
||||
|
||||
void MapView::setMarkerColor(const QColor &color)
|
||||
{
|
||||
_markerColor = color;
|
||||
|
||||
for (int i = 0; i < _tracks.size(); i++)
|
||||
_tracks.at(i)->setMarkerColor(color);
|
||||
for (int i = 0; i < _routes.size(); i++)
|
||||
_routes.at(i)->setMarkerColor(color);
|
||||
}
|
||||
|
||||
void MapView::reloadMap()
|
||||
{
|
||||
resetCachedContent();
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
void setBackgroundColor(const QColor &color);
|
||||
void useOpenGL(bool use);
|
||||
void useAntiAliasing(bool use);
|
||||
void setMarkerColor(const QColor &color);
|
||||
|
||||
public slots:
|
||||
void showMap(bool show);
|
||||
@ -127,6 +128,7 @@ private:
|
||||
int _poiSize;
|
||||
QColor _waypointColor;
|
||||
QColor _poiColor;
|
||||
QColor _markerColor;
|
||||
|
||||
int _digitalZoom;
|
||||
bool _plot;
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
MarkerItem::MarkerItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||
{
|
||||
|
||||
_color = Qt::red;
|
||||
}
|
||||
|
||||
QRectF MarkerItem::boundingRect() const
|
||||
@ -22,9 +22,15 @@ void MarkerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
||||
Q_UNUSED(widget);
|
||||
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
painter->setPen(QPen(Qt::red, WIDTH));
|
||||
painter->setPen(QPen(_color, WIDTH));
|
||||
painter->drawLine(-SIZE/2, 0, SIZE/2, 0);
|
||||
painter->drawLine(0, -SIZE/2, 0, SIZE/2);
|
||||
|
||||
// painter->drawRect(boundingRect());
|
||||
}
|
||||
|
||||
void MarkerItem::setColor(const QColor &color)
|
||||
{
|
||||
_color = color;
|
||||
update();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define MARKERITEM_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QColor>
|
||||
|
||||
class MarkerItem : public QGraphicsItem
|
||||
{
|
||||
@ -11,6 +12,11 @@ public:
|
||||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
|
||||
void setColor(const QColor &color);
|
||||
|
||||
private:
|
||||
QColor _color;
|
||||
};
|
||||
|
||||
#endif // MARKERITEM_H
|
||||
|
@ -157,11 +157,15 @@ QWidget *OptionsDialog::createAppearancePage()
|
||||
|
||||
|
||||
// Graphs
|
||||
_sliderColor = new ColorBox();
|
||||
_sliderColor->setColor(_options->sliderColor);
|
||||
_graphWidth = new QSpinBox();
|
||||
_graphWidth->setValue(_options->graphWidth);
|
||||
_graphWidth->setMinimum(1);
|
||||
|
||||
QFormLayout *graphLayout = new QFormLayout();
|
||||
graphLayout->addRow(tr("Line width:"), _graphWidth);
|
||||
graphLayout->addRow(tr("Slider color:"), _sliderColor);
|
||||
|
||||
_graphAA = new QCheckBox(tr("Use anti-aliasing"));
|
||||
_graphAA->setChecked(_options->graphAntiAliasing);
|
||||
@ -485,6 +489,7 @@ void OptionsDialog::accept()
|
||||
_options->poiSize = _poiSize->value();
|
||||
_options->poiColor = _poiColor->color();
|
||||
_options->graphWidth = _graphWidth->value();
|
||||
_options->sliderColor = _sliderColor->color();
|
||||
_options->graphAntiAliasing = _graphAA->isChecked();
|
||||
|
||||
_options->elevationFilter = _elevationFilter->value();
|
||||
|
@ -27,6 +27,7 @@ struct Options {
|
||||
int waypointSize;
|
||||
int poiSize;
|
||||
int graphWidth;
|
||||
QColor sliderColor;
|
||||
bool pathAntiAliasing;
|
||||
bool graphAntiAliasing;
|
||||
int mapOpacity;
|
||||
@ -92,6 +93,7 @@ private:
|
||||
QSpinBox *_poiSize;
|
||||
ColorBox *_poiColor;
|
||||
QSpinBox *_graphWidth;
|
||||
ColorBox *_sliderColor;
|
||||
QCheckBox *_graphAA;
|
||||
// Data
|
||||
OddSpinBox *_elevationFilter;
|
||||
|
@ -167,6 +167,11 @@ void PathItem::moveMarker(qreal distance)
|
||||
_marker->setVisible(false);
|
||||
}
|
||||
|
||||
void PathItem::setMarkerColor(const QColor &color)
|
||||
{
|
||||
_marker->setColor(color);
|
||||
}
|
||||
|
||||
void PathItem::hover(bool hover)
|
||||
{
|
||||
if (hover) {
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
void setWidth(qreal width);
|
||||
void setStyle(Qt::PenStyle style);
|
||||
void setDigitalZoom(int zoom);
|
||||
void setMarkerColor(const QColor &color);
|
||||
|
||||
public slots:
|
||||
void moveMarker(qreal distance);
|
||||
|
@ -144,5 +144,7 @@
|
||||
#define PRINT_ITEM_COUNT_DEFAULT true
|
||||
#define SEPARATE_GRAPH_PAGE_SETTING "separateGraphPage"
|
||||
#define SEPARATE_GRAPH_PAGE_DEFAULT false
|
||||
#define SLIDER_COLOR_SETTING "sliderColor"
|
||||
#define SLIDER_COLOR_DEFAULT QColor(Qt::red)
|
||||
|
||||
#endif // SETTINGS_H
|
||||
|
@ -8,6 +8,7 @@
|
||||
SliderInfoItem::SliderInfoItem(QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||
{
|
||||
_side = Right;
|
||||
_color = Qt::red;
|
||||
}
|
||||
|
||||
void SliderInfoItem::updateBoundingRect()
|
||||
@ -58,7 +59,7 @@ void SliderInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
||||
|
||||
painter->setFont(font);
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
painter->setPen(Qt::red);
|
||||
painter->setPen(_color);
|
||||
|
||||
if (_side == Right) {
|
||||
painter->drawText(SIZE, -fm.descent()/2, _y);
|
||||
@ -88,3 +89,9 @@ void SliderInfoItem::setSide(Side side)
|
||||
_side = side;
|
||||
updateBoundingRect();
|
||||
}
|
||||
|
||||
void SliderInfoItem::setColor(const QColor &color)
|
||||
{
|
||||
_color = color;
|
||||
update();
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ public:
|
||||
|
||||
void setText(const QString &x, const QString &y);
|
||||
void setSide(Side side);
|
||||
void setColor(const QColor &color);
|
||||
|
||||
private:
|
||||
void updateBoundingRect();
|
||||
@ -23,6 +24,7 @@ private:
|
||||
Side _side;
|
||||
QString _x, _y;
|
||||
QRectF _boundingRect;
|
||||
QColor _color;
|
||||
};
|
||||
|
||||
#endif // SLIDERINFOITEM_H
|
||||
|
@ -8,6 +8,8 @@ SliderItem::SliderItem(QGraphicsItem *parent) : QGraphicsObject(parent)
|
||||
{
|
||||
setFlag(ItemIsMovable);
|
||||
setFlag(ItemSendsGeometryChanges);
|
||||
|
||||
_color = Qt::red;
|
||||
}
|
||||
|
||||
QRectF SliderItem::boundingRect() const
|
||||
@ -22,7 +24,7 @@ void SliderItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
||||
Q_UNUSED(widget);
|
||||
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
painter->setPen(Qt::red);
|
||||
painter->setPen(_color);
|
||||
painter->drawLine(0, 0, 0, -_area.height());
|
||||
|
||||
// painter->drawRect(boundingRect());
|
||||
@ -59,3 +61,9 @@ void SliderItem::setArea(const QRectF &area)
|
||||
prepareGeometryChange();
|
||||
_area = area;
|
||||
}
|
||||
|
||||
void SliderItem::setColor(const QColor &color)
|
||||
{
|
||||
_color = color;
|
||||
update();
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include <QGraphicsObject>
|
||||
|
||||
class QColor;
|
||||
|
||||
class SliderItem : public QGraphicsObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -17,6 +19,8 @@ public:
|
||||
const QRectF &area() const {return _area;}
|
||||
void setArea(const QRectF &area);
|
||||
|
||||
void setColor(const QColor &color);
|
||||
|
||||
void clear();
|
||||
|
||||
signals:
|
||||
@ -27,6 +31,7 @@ protected:
|
||||
|
||||
private:
|
||||
QRectF _area;
|
||||
QColor _color;
|
||||
};
|
||||
|
||||
#endif // SLIDERITEM_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user