mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 03:35:53 +01:00
Added options dialogue
This commit is contained in:
parent
181f60ed40
commit
a9668ca86e
11
gpxsee.pro
11
gpxsee.pro
@ -5,6 +5,7 @@ QT += core \
|
||||
network
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += printsupport
|
||||
lessThan(QT_MAJOR_VERSION, 5) : QT += opengl
|
||||
HEADERS += src/config.h \
|
||||
src/icons.h \
|
||||
src/gui.h \
|
||||
@ -70,7 +71,10 @@ HEADERS += src/config.h \
|
||||
src/cadencegraph.h \
|
||||
src/powergraph.h \
|
||||
src/igcparser.h \
|
||||
src/nmeaparser.h
|
||||
src/nmeaparser.h \
|
||||
src/optionsdialog.h \
|
||||
src/colorbox.h \
|
||||
src/stylecombobox.h
|
||||
SOURCES += src/main.cpp \
|
||||
src/gui.cpp \
|
||||
src/poi.cpp \
|
||||
@ -121,7 +125,10 @@ SOURCES += src/main.cpp \
|
||||
src/powergraph.cpp \
|
||||
src/igcparser.cpp \
|
||||
src/path.cpp \
|
||||
src/nmeaparser.cpp
|
||||
src/nmeaparser.cpp \
|
||||
src/optionsdialog.cpp \
|
||||
src/colorbox.cpp \
|
||||
src/stylecombobox.cpp
|
||||
RESOURCES += gpxsee.qrc
|
||||
TRANSLATIONS = lang/gpxsee_cs.ts
|
||||
macx {
|
||||
|
@ -15,6 +15,9 @@
|
||||
<file>icons/arrow-right-double.png</file>
|
||||
<file>icons/view-fullscreen.png</file>
|
||||
<file>icons/office-chart-line-stacked.png</file>
|
||||
<file>icons/preferences-desktop-display.png</file>
|
||||
<file>icons/flag_48.png</file>
|
||||
<file>icons/system-run.png</file>
|
||||
<file>lang/gpxsee_cs.qm</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
BIN
icons/flag_48.png
Normal file
BIN
icons/flag_48.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.1 KiB |
BIN
icons/preferences-desktop-display.png
Normal file
BIN
icons/preferences-desktop-display.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
BIN
icons/system-run.png
Normal file
BIN
icons/system-run.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
18
src/app.cpp
18
src/app.cpp
@ -3,6 +3,12 @@
|
||||
#include <QLocale>
|
||||
#include <QFileOpenEvent>
|
||||
#include <QNetworkProxyFactory>
|
||||
#include <QPixmapCache>
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
#include <QGLFormat>
|
||||
#else // QT 5
|
||||
#include <QSurfaceFormat>
|
||||
#endif // QT 5
|
||||
#include "gui.h"
|
||||
#include "app.h"
|
||||
|
||||
@ -21,6 +27,18 @@ App::App(int &argc, char **argv) : QApplication(argc, argv),
|
||||
|
||||
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
QGLFormat fmt;
|
||||
fmt.setSamples(10);
|
||||
QGLFormat::setDefaultFormat(fmt);
|
||||
#else
|
||||
QSurfaceFormat fmt;
|
||||
fmt.setSamples(10);
|
||||
QSurfaceFormat::setDefaultFormat(fmt);
|
||||
#endif
|
||||
|
||||
QPixmapCache::setCacheLimit(65536);
|
||||
|
||||
_gui = new GUI();
|
||||
}
|
||||
|
||||
|
68
src/colorbox.cpp
Normal file
68
src/colorbox.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
#include <QStylePainter>
|
||||
#include <QStyleOptionComboBox>
|
||||
#include <QMouseEvent>
|
||||
#include <QColorDialog>
|
||||
#include <QComboBox>
|
||||
#include "colorbox.h"
|
||||
|
||||
|
||||
ColorBox::ColorBox(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
_color = Qt::red;
|
||||
setSizePolicy(QSizePolicy::QSizePolicy::Minimum, QSizePolicy::Fixed);
|
||||
}
|
||||
|
||||
QSize ColorBox::sizeHint() const
|
||||
{
|
||||
static QSize size;
|
||||
if (size.isValid())
|
||||
return size;
|
||||
|
||||
QComboBox cb;
|
||||
size = cb.sizeHint();
|
||||
return size;
|
||||
}
|
||||
|
||||
void ColorBox::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
QStylePainter painter(this);
|
||||
|
||||
QStyleOptionComboBox option;
|
||||
option.initFrom(this);
|
||||
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
|
||||
painter.setBrush(_color);
|
||||
painter.drawPrimitive(QStyle::PE_Frame, option);
|
||||
#else // Q_OS_MAC || Q_OS_WIN32
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
painter.setBrush(_color);
|
||||
painter.drawRect(event->rect().adjusted(-1, -1, 0, 0));
|
||||
painter.drawPrimitive(QStyle::PE_FrameLineEdit, option);
|
||||
#else // QT 5
|
||||
option.palette.setBrush(QPalette::Base, _color);
|
||||
painter.drawPrimitive(QStyle::PE_FrameLineEdit, option);
|
||||
#endif // QT 5
|
||||
#endif // Q_OS_MAC || Q_OS_WIN32
|
||||
}
|
||||
|
||||
void ColorBox::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() != Qt::LeftButton)
|
||||
return;
|
||||
|
||||
QColor color = QColorDialog::getColor(_color, this, QString(),
|
||||
QColorDialog::ShowAlphaChannel);
|
||||
if (color.isValid()) {
|
||||
_color = color;
|
||||
update();
|
||||
emit colorChanged(_color);
|
||||
}
|
||||
}
|
||||
|
||||
void ColorBox::setColor(const QColor &color)
|
||||
{
|
||||
_color = color;
|
||||
update();
|
||||
}
|
29
src/colorbox.h
Normal file
29
src/colorbox.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef COLORBOX_H
|
||||
#define COLORBOX_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class ColorBox : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ColorBox(QWidget *parent = 0);
|
||||
|
||||
const QColor &color() const {return _color;}
|
||||
void setColor(const QColor &color);
|
||||
|
||||
QSize sizeHint() const;
|
||||
|
||||
signals:
|
||||
void colorChanged(const QColor &color);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
private:
|
||||
QColor _color;
|
||||
};
|
||||
|
||||
#endif // COLORBOX_H
|
@ -2,6 +2,10 @@
|
||||
#include "wgs84.h"
|
||||
#include "coordinates.h"
|
||||
|
||||
#define MIN_LAT deg2rad(-90.0)
|
||||
#define MAX_LAT deg2rad(90.0)
|
||||
#define MIN_LON deg2rad(-180.0)
|
||||
#define MAX_LON deg2rad(180.0)
|
||||
|
||||
qreal Coordinates::distanceTo(const Coordinates &c) const
|
||||
{
|
||||
@ -35,3 +39,31 @@ QDebug operator<<(QDebug dbg, const Coordinates &coordinates)
|
||||
|
||||
return dbg.maybeSpace();
|
||||
}
|
||||
|
||||
QPair<Coordinates, Coordinates> Coordinates::boundingRect(qreal distance) const
|
||||
{
|
||||
qreal radDist = distance / WGS84_RADIUS;
|
||||
|
||||
qreal minLat = deg2rad(_lat) - radDist;
|
||||
qreal maxLat = deg2rad(_lat) + radDist;
|
||||
|
||||
qreal minLon, maxLon;
|
||||
if (minLat > MIN_LAT && maxLat < MAX_LAT) {
|
||||
qreal deltaLon = asin(sin(radDist) / cos(_lat));
|
||||
minLon = deg2rad(_lon) - deltaLon;
|
||||
if (minLon < MIN_LON)
|
||||
minLon += 2.0 * M_PI;
|
||||
maxLon = deg2rad(_lon) + deltaLon;
|
||||
if (maxLon > MAX_LON)
|
||||
maxLon -= 2.0 * M_PI;
|
||||
} else {
|
||||
// a pole is within the distance
|
||||
minLat = qMax(minLat, MIN_LAT);
|
||||
maxLat = qMin(maxLat, MAX_LAT);
|
||||
minLon = MIN_LON;
|
||||
maxLon = MAX_LON;
|
||||
}
|
||||
|
||||
return QPair<Coordinates, Coordinates>(Coordinates(rad2deg(minLon),
|
||||
rad2deg(minLat)), Coordinates(rad2deg(maxLon), rad2deg(maxLat)));
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ public:
|
||||
&& _lat <= 90.0) ? true : false;}
|
||||
|
||||
qreal distanceTo(const Coordinates &c) const;
|
||||
QPair<Coordinates, Coordinates> boundingRect(qreal distance) const;
|
||||
|
||||
QPointF toMercator() const;
|
||||
static Coordinates fromMercator(const QPointF &m);
|
||||
|
@ -17,17 +17,17 @@
|
||||
#include "exportdialog.h"
|
||||
|
||||
|
||||
ExportDialog::ExportDialog(QPrinter *printer, QWidget *parent)
|
||||
: QDialog(parent), _printer(printer)
|
||||
ExportDialog::ExportDialog(Export *exp, QWidget *parent)
|
||||
: QDialog(parent), _export(exp)
|
||||
{
|
||||
int index;
|
||||
|
||||
_units = (QLocale::system().measurementSystem()
|
||||
== QLocale::ImperialSystem) ? QPrinter::Inch : QPrinter::Millimeter;
|
||||
_units = QLocale::system().measurementSystem() == QLocale::ImperialSystem ?
|
||||
QPrinter::Inch : QPrinter::Millimeter;
|
||||
|
||||
_fileSelect = new FileSelectWidget();
|
||||
_fileSelect->setFilter(tr("PDF files (*.pdf);;All files (*)"));
|
||||
_fileSelect->setFile(_printer->outputFileName());
|
||||
_fileSelect->setFile(_export->fileName);
|
||||
|
||||
_paperSize = new QComboBox();
|
||||
_paperSize->addItem("A3", QPrinter::A3);
|
||||
@ -36,7 +36,7 @@ ExportDialog::ExportDialog(QPrinter *printer, QWidget *parent)
|
||||
_paperSize->addItem("Tabloid", QPrinter::Tabloid);
|
||||
_paperSize->addItem("Legal", QPrinter::Legal);
|
||||
_paperSize->addItem("Letter", QPrinter::Letter);
|
||||
if ((index = _paperSize->findData(_printer->paperSize())) >= 0)
|
||||
if ((index = _paperSize->findData(_export->paperSize)) >= 0)
|
||||
_paperSize->setCurrentIndex(index);
|
||||
|
||||
_portrait = new QRadioButton(tr("Portrait"));
|
||||
@ -44,32 +44,34 @@ ExportDialog::ExportDialog(QPrinter *printer, QWidget *parent)
|
||||
QHBoxLayout *orientationLayout = new QHBoxLayout();
|
||||
orientationLayout->addWidget(_portrait);
|
||||
orientationLayout->addWidget(_landscape);
|
||||
if (_printer->orientation() == QPrinter::Portrait)
|
||||
if (_export->orientation == QPrinter::Portrait)
|
||||
_portrait->setChecked(true);
|
||||
else
|
||||
_landscape->setChecked(true);
|
||||
|
||||
qreal top, bottom, left, right;
|
||||
|
||||
_printer->getPageMargins(&left, &top, &right, &bottom, _units);
|
||||
QString us = _units == QPrinter::Inch ? tr("in") : tr("mm");
|
||||
_topMargin = new QDoubleSpinBox();
|
||||
_bottomMargin = new QDoubleSpinBox();
|
||||
_leftMargin = new QDoubleSpinBox();
|
||||
_rightMargin = new QDoubleSpinBox();
|
||||
_topMargin->setValue(top);
|
||||
QString us = (_units == QPrinter::Inch) ? tr("in") : tr("mm");
|
||||
_topMargin->setSuffix(UNIT_SPACE + us);
|
||||
_bottomMargin->setValue(bottom);
|
||||
_bottomMargin->setSuffix(UNIT_SPACE + us);
|
||||
_leftMargin->setValue(left);
|
||||
_leftMargin->setSuffix(UNIT_SPACE + us);
|
||||
_rightMargin->setValue(right);
|
||||
_rightMargin->setSuffix(UNIT_SPACE + us);
|
||||
if (_units == QPrinter::Inch) {
|
||||
_topMargin->setValue(_export->margins.top() * MM2IN);
|
||||
_bottomMargin->setValue(_export->margins.bottom() * MM2IN);
|
||||
_leftMargin->setValue(_export->margins.left() * MM2IN);
|
||||
_rightMargin->setValue(_export->margins.right() * MM2IN);
|
||||
_topMargin->setSingleStep(0.1);
|
||||
_bottomMargin->setSingleStep(0.1);
|
||||
_leftMargin->setSingleStep(0.1);
|
||||
_rightMargin->setSingleStep(0.1);
|
||||
} else {
|
||||
_topMargin->setValue(_export->margins.top());
|
||||
_bottomMargin->setValue(_export->margins.bottom());
|
||||
_leftMargin->setValue(_export->margins.left());
|
||||
_rightMargin->setValue(_export->margins.right());
|
||||
}
|
||||
|
||||
QGridLayout *marginsLayout = new QGridLayout();
|
||||
@ -164,12 +166,16 @@ void ExportDialog::accept()
|
||||
QPrinter::PaperSize paperSize = static_cast<QPrinter::PaperSize>
|
||||
(_paperSize->itemData(_paperSize->currentIndex()).toInt());
|
||||
|
||||
_printer->setOutputFormat(QPrinter::PdfFormat);
|
||||
_printer->setOutputFileName(_fileSelect->file());
|
||||
_printer->setPaperSize(paperSize);
|
||||
_printer->setOrientation(orientation);
|
||||
_printer->setPageMargins(_leftMargin->value(), _topMargin->value(),
|
||||
_rightMargin->value(), _bottomMargin->value(), _units);
|
||||
_export->fileName = _fileSelect->file();
|
||||
_export->paperSize = paperSize;
|
||||
_export->orientation = orientation;
|
||||
if (_units == QPrinter::Inch)
|
||||
_export->margins = MarginsF(_leftMargin->value() / MM2IN,
|
||||
_topMargin->value() / MM2IN, _rightMargin->value() / MM2IN,
|
||||
_bottomMargin->value() / MM2IN);
|
||||
else
|
||||
_export->margins = MarginsF(_leftMargin->value(), _topMargin->value(),
|
||||
_rightMargin->value(), _bottomMargin->value());
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
@ -3,18 +3,26 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QPrinter>
|
||||
#include "margins.h"
|
||||
|
||||
class QComboBox;
|
||||
class QRadioButton;
|
||||
class FileSelectWidget;
|
||||
class QDoubleSpinBox;
|
||||
|
||||
struct Export {
|
||||
QString fileName;
|
||||
QPrinter::PaperSize paperSize;
|
||||
QPrinter::Orientation orientation;
|
||||
MarginsF margins;
|
||||
};
|
||||
|
||||
class ExportDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ExportDialog(QPrinter *printer, QWidget *parent = 0);
|
||||
ExportDialog(Export *exp, QWidget *parent = 0);
|
||||
|
||||
public slots:
|
||||
void accept();
|
||||
@ -22,8 +30,7 @@ public slots:
|
||||
private:
|
||||
bool checkFile();
|
||||
|
||||
QPrinter *_printer;
|
||||
|
||||
Export *_export;
|
||||
QPrinter::Unit _units;
|
||||
|
||||
FileSelectWidget *_fileSelect;
|
||||
|
@ -2,20 +2,20 @@
|
||||
#include "graphitem.h"
|
||||
|
||||
|
||||
#define GRAPH_WIDTH 1
|
||||
#define HOVER_WIDTH 2
|
||||
|
||||
GraphItem::GraphItem(const Graph &graph, QGraphicsItem *parent)
|
||||
: QGraphicsObject(parent)
|
||||
{
|
||||
_id = 0;
|
||||
_width = 1;
|
||||
|
||||
_pen = QPen(Qt::black, GRAPH_WIDTH);
|
||||
_pen = QPen(Qt::black, _width);
|
||||
|
||||
_type = Distance;
|
||||
_graph = graph;
|
||||
_sx = 1.0; _sy = 1.0;
|
||||
|
||||
setZValue(1.0);
|
||||
|
||||
updatePath();
|
||||
updateBounds();
|
||||
}
|
||||
@ -51,6 +51,14 @@ void GraphItem::setColor(const QColor &color)
|
||||
update();
|
||||
}
|
||||
|
||||
void GraphItem::setWidth(int width)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
|
||||
_width = width;
|
||||
_pen.setWidth(width);
|
||||
}
|
||||
|
||||
qreal GraphItem::yAtX(qreal x)
|
||||
{
|
||||
int low = 0;
|
||||
@ -130,10 +138,10 @@ void GraphItem::emitSliderPositionChanged(qreal pos)
|
||||
void GraphItem::selected(bool selected)
|
||||
{
|
||||
if (selected) {
|
||||
_pen.setWidth(HOVER_WIDTH);
|
||||
_pen.setWidth(_width + 1);
|
||||
setZValue(zValue() + 1.0);
|
||||
} else {
|
||||
_pen.setWidth(GRAPH_WIDTH);
|
||||
_pen.setWidth(_width);
|
||||
setZValue(zValue() - 1.0);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ public:
|
||||
int id() const {return _id;}
|
||||
void setId(int id) {_id = id;}
|
||||
void setColor(const QColor &color);
|
||||
void setWidth(int width);
|
||||
|
||||
qreal yAtX(qreal x);
|
||||
qreal distanceAtTime(qreal time);
|
||||
@ -41,6 +42,7 @@ private:
|
||||
|
||||
int _id;
|
||||
QPen _pen;
|
||||
int _width;
|
||||
|
||||
Graph _graph;
|
||||
GraphType _type;
|
||||
|
@ -27,19 +27,21 @@ GraphView::GraphView(QWidget *parent)
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
_xAxis = new AxisItem(AxisItem::X);
|
||||
_xAxis->setZValue(1.0);
|
||||
_xAxis->setZValue(2.0);
|
||||
_yAxis = new AxisItem(AxisItem::Y);
|
||||
_yAxis->setZValue(1.0);
|
||||
_yAxis->setZValue(2.0);
|
||||
_slider = new SliderItem();
|
||||
_slider->setZValue(2.0);
|
||||
_slider->setZValue(3.0);
|
||||
_sliderInfo = new SliderInfoItem(_slider);
|
||||
_sliderInfo->setZValue(2.0);
|
||||
_sliderInfo->setZValue(3.0);
|
||||
_info = new InfoItem();
|
||||
_grid = new GridItem();
|
||||
|
||||
connect(_slider, SIGNAL(positionChanged(const QPointF&)), this,
|
||||
SLOT(emitSliderPositionChanged(const QPointF&)));
|
||||
|
||||
_width = 1;
|
||||
|
||||
_xScale = 1;
|
||||
_yScale = 1;
|
||||
_yOffset = 0;
|
||||
@ -169,7 +171,8 @@ void GraphView::loadGraph(const Graph &graph, PathItem *path, int id)
|
||||
GraphItem *gi = new GraphItem(graph);
|
||||
gi->setGraphType(_graphType);
|
||||
gi->setId(id);
|
||||
gi->setColor(_palette.color());
|
||||
gi->setColor(_palette.nextColor());
|
||||
gi->setWidth(_width);
|
||||
|
||||
connect(this, SIGNAL(sliderPositionChanged(qreal)), gi,
|
||||
SLOT(emitSliderPositionChanged(qreal)));
|
||||
@ -431,3 +434,18 @@ void GraphView::clearInfo()
|
||||
{
|
||||
_info->clear();
|
||||
}
|
||||
|
||||
void GraphView::setPalette(const Palette &palette)
|
||||
{
|
||||
_palette = palette;
|
||||
_palette.reset();
|
||||
|
||||
for (int i = 0; i < _graphs.count(); i++)
|
||||
_graphs.at(i)->setColor(_palette.nextColor());
|
||||
}
|
||||
|
||||
void GraphView::setGraphWidth(int width)
|
||||
{
|
||||
for (int i = 0; i < _graphs.count(); i++)
|
||||
_graphs.at(i)->setWidth(width);
|
||||
}
|
||||
|
@ -35,6 +35,9 @@ public:
|
||||
void setUnits(Units units);
|
||||
void showGrid(bool show);
|
||||
|
||||
void setPalette(const Palette &palette);
|
||||
void setGraphWidth(int width);
|
||||
|
||||
const QString &yLabel() const {return _yLabel;}
|
||||
const QString &yUnits() const {return _yUnits;}
|
||||
qreal yScale() const {return _yScale;}
|
||||
@ -60,7 +63,7 @@ protected:
|
||||
void redraw(const QSizeF &size);
|
||||
void addInfo(const QString &key, const QString &value);
|
||||
void clearInfo();
|
||||
void skipColor() {_palette.color();}
|
||||
void skipColor() {_palette.nextColor();}
|
||||
|
||||
private slots:
|
||||
void emitSliderPositionChanged(const QPointF &pos);
|
||||
@ -99,6 +102,7 @@ private:
|
||||
QSet<int> _hide;
|
||||
QRectF _bounds;
|
||||
Palette _palette;
|
||||
int _width;
|
||||
|
||||
Units _units;
|
||||
GraphType _graphType;
|
||||
|
265
src/gui.cpp
265
src/gui.cpp
@ -21,7 +21,6 @@
|
||||
#include <QLocale>
|
||||
#include <QMimeData>
|
||||
#include <QUrl>
|
||||
#include <QPixmapCache>
|
||||
#include "config.h"
|
||||
#include "icons.h"
|
||||
#include "keys.h"
|
||||
@ -39,7 +38,6 @@
|
||||
#include "trackinfo.h"
|
||||
#include "filebrowser.h"
|
||||
#include "cpuarch.h"
|
||||
#include "exportdialog.h"
|
||||
#include "graphtab.h"
|
||||
#include "format.h"
|
||||
#include "gui.h"
|
||||
@ -88,14 +86,7 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||
|
||||
readSettings();
|
||||
|
||||
_exportPaperSize = (QLocale::system().measurementSystem()
|
||||
== QLocale::ImperialSystem) ? QPrinter::Letter : QPrinter::A4;
|
||||
_exportOrientation = QPrinter::Portrait;
|
||||
_exportFileName = QString("%1/export.pdf").arg(QDir::currentPath());
|
||||
_exportMargins = MarginsF(5.0, 5.0, 5.0, 5.0);
|
||||
|
||||
setAcceptDrops(true);
|
||||
QPixmapCache::setCacheLimit(65536);
|
||||
}
|
||||
|
||||
GUI::~GUI()
|
||||
@ -198,7 +189,6 @@ void GUI::createActions()
|
||||
{
|
||||
QActionGroup *ag;
|
||||
|
||||
|
||||
// Action Groups
|
||||
_fileActionGroup = new QActionGroup(this);
|
||||
_fileActionGroup->setExclusive(false);
|
||||
@ -377,6 +367,9 @@ void GUI::createActions()
|
||||
connect(_fullscreenAction, SIGNAL(triggered(bool)), this,
|
||||
SLOT(showFullscreen(bool)));
|
||||
addAction(_fullscreenAction);
|
||||
_openOptionsAction = new QAction(tr("Options..."), this);
|
||||
connect(_openOptionsAction, SIGNAL(triggered()), this,
|
||||
SLOT(openOptions()));
|
||||
|
||||
// Navigation actions
|
||||
_nextAction = new QAction(QIcon(QPixmap(NEXT_FILE_ICON)), tr("Next"), this);
|
||||
@ -453,8 +446,9 @@ void GUI::createMenus()
|
||||
unitsMenu->addAction(_imperialUnitsAction);
|
||||
settingsMenu->addSeparator();
|
||||
settingsMenu->addAction(_showToolbarsAction);
|
||||
settingsMenu->addSeparator();
|
||||
settingsMenu->addAction(_fullscreenAction);
|
||||
settingsMenu->addSeparator();
|
||||
settingsMenu->addAction(_openOptionsAction);
|
||||
|
||||
QMenu *helpMenu = menuBar()->addMenu(tr("Help"));
|
||||
helpMenu->addAction(_dataSourcesAction);
|
||||
@ -746,26 +740,64 @@ void GUI::printFile()
|
||||
plot(&printer);
|
||||
}
|
||||
|
||||
void GUI::openOptions()
|
||||
{
|
||||
Options options(_options);
|
||||
|
||||
OptionsDialog dialog(&options, this);
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
if (options.palette != _options.palette) {
|
||||
_pathView->setPalette(options.palette);
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->setPalette(options.palette);
|
||||
}
|
||||
if (options.trackWidth != _options.trackWidth)
|
||||
_pathView->setTrackWidth(options.trackWidth);
|
||||
if (options.routeWidth != _options.routeWidth)
|
||||
_pathView->setRouteWidth(options.routeWidth);
|
||||
if (options.trackStyle != _options.trackStyle)
|
||||
_pathView->setTrackStyle(options.trackStyle);
|
||||
if (options.routeStyle != _options.routeStyle)
|
||||
_pathView->setRouteStyle(options.routeStyle);
|
||||
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.poiRadius != _options.poiRadius)
|
||||
_poi->setRadius(options.poiRadius);
|
||||
|
||||
if (options.useOpenGL != _options.useOpenGL)
|
||||
_pathView->useOpenGL(options.useOpenGL);
|
||||
|
||||
_options = options;
|
||||
}
|
||||
|
||||
void GUI::exportFile()
|
||||
{
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer.setCreator(QString(APP_NAME) + QString(" ") + QString(APP_VERSION));
|
||||
printer.setOrientation(_exportOrientation);
|
||||
printer.setOutputFileName(_exportFileName);
|
||||
printer.setPaperSize(_exportPaperSize);
|
||||
printer.setPageMargins(_exportMargins.left(), _exportMargins.top(),
|
||||
_exportMargins.right(), _exportMargins.bottom(), QPrinter::Millimeter);
|
||||
ExportDialog dialog(&printer, this);
|
||||
ExportDialog dialog(&_export, this);
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
_exportFileName = printer.outputFileName();
|
||||
_exportPaperSize = printer.paperSize();
|
||||
_exportOrientation = printer.orientation();
|
||||
printer.getPageMargins(&(_exportMargins.rleft()),
|
||||
&(_exportMargins.rtop()), &(_exportMargins.rright()),
|
||||
&(_exportMargins.rbottom()), QPrinter::Millimeter);
|
||||
plot(&printer);
|
||||
}
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||
printer.setCreator(QString(APP_NAME) + QString(" ")
|
||||
+ QString(APP_VERSION));
|
||||
printer.setOrientation(_export.orientation);
|
||||
printer.setOutputFileName(_export.fileName);
|
||||
printer.setPaperSize(_export.paperSize);
|
||||
printer.setPageMargins(_export.margins.left(), _export.margins.top(),
|
||||
_export.margins.right(), _export.margins.bottom(), QPrinter::Millimeter);
|
||||
|
||||
plot(&printer);
|
||||
}
|
||||
|
||||
void GUI::plot(QPrinter *printer)
|
||||
@ -1229,35 +1261,46 @@ void GUI::dropEvent(QDropEvent *event)
|
||||
void GUI::writeSettings()
|
||||
{
|
||||
QSettings settings(APP_NAME, APP_NAME);
|
||||
settings.clear();
|
||||
|
||||
settings.beginGroup(WINDOW_SETTINGS_GROUP);
|
||||
settings.setValue(WINDOW_SIZE_SETTING, size());
|
||||
settings.setValue(WINDOW_POS_SETTING, pos());
|
||||
if (size() != WINDOW_SIZE_DEFAULT)
|
||||
settings.setValue(WINDOW_SIZE_SETTING, size());
|
||||
if (pos() != WINDOW_POS_DEFAULT)
|
||||
settings.setValue(WINDOW_POS_SETTING, pos());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
|
||||
settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked()
|
||||
? Imperial : Metric);
|
||||
settings.setValue(SHOW_TOOLBARS_SETTING, _showToolbarsAction->isChecked());
|
||||
if (_showToolbarsAction->isChecked() != SHOW_TOOLBARS_DEFAULT)
|
||||
settings.setValue(SHOW_TOOLBARS_SETTING,
|
||||
_showToolbarsAction->isChecked());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(MAP_SETTINGS_GROUP);
|
||||
if (_currentMap)
|
||||
settings.setValue(CURRENT_MAP_SETTING, _currentMap->name());
|
||||
settings.setValue(SHOW_MAP_SETTING, _showMapAction->isChecked());
|
||||
if (_showMapAction->isChecked() != SHOW_MAP_DEFAULT)
|
||||
settings.setValue(SHOW_MAP_SETTING, _showMapAction->isChecked());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(GRAPH_SETTINGS_GROUP);
|
||||
settings.setValue(SHOW_GRAPHS_SETTING, _showGraphsAction->isChecked());
|
||||
settings.setValue(GRAPH_TYPE_SETTING, _timeGraphAction->isChecked()
|
||||
? Time : Distance);
|
||||
settings.setValue(SHOW_GRAPH_GRIDS_SETTING,
|
||||
_showGraphGridAction->isChecked());
|
||||
if (_showGraphsAction->isChecked() != SHOW_GRAPHS_DEFAULT)
|
||||
settings.setValue(SHOW_GRAPHS_SETTING, _showGraphsAction->isChecked());
|
||||
if ((_timeGraphAction->isChecked() ? Time : Distance) != GRAPH_TYPE_DEFAULT)
|
||||
settings.setValue(GRAPH_TYPE_SETTING, _timeGraphAction->isChecked()
|
||||
? Time : Distance);
|
||||
if (_showGraphGridAction->isChecked() != SHOW_GRAPH_GRIDS_DEFAULT)
|
||||
settings.setValue(SHOW_GRAPH_GRIDS_SETTING,
|
||||
_showGraphGridAction->isChecked());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(POI_SETTINGS_GROUP);
|
||||
settings.setValue(SHOW_POI_SETTING, _showPOIAction->isChecked());
|
||||
settings.setValue(OVERLAP_POI_SETTING, _overlapPOIAction->isChecked());
|
||||
if (_showPOIAction->isChecked() != SHOW_POI_DEFAULT)
|
||||
settings.setValue(SHOW_POI_SETTING, _showPOIAction->isChecked());
|
||||
if (_overlapPOIAction->isChecked() != OVERLAP_POI_DEFAULT)
|
||||
settings.setValue(OVERLAP_POI_SETTING, _overlapPOIAction->isChecked());
|
||||
|
||||
settings.remove(DISABLED_POI_FILE_SETTINGS_PREFIX);
|
||||
settings.beginWriteArray(DISABLED_POI_FILE_SETTINGS_PREFIX);
|
||||
@ -1271,15 +1314,61 @@ void GUI::writeSettings()
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(DATA_SETTINGS_GROUP);
|
||||
settings.setValue(SHOW_TRACKS_SETTING, _showTracksAction->isChecked());
|
||||
settings.setValue(SHOW_ROUTES_SETTING, _showRoutesAction->isChecked());
|
||||
settings.setValue(SHOW_WAYPOINTS_SETTING,
|
||||
_showWaypointsAction->isChecked());
|
||||
settings.setValue(SHOW_WAYPOINT_LABELS_SETTING,
|
||||
_showWaypointLabelsAction->isChecked());
|
||||
settings.setValue(SHOW_ROUTE_WAYPOINTS_SETTING,
|
||||
_showRouteWaypointsAction->isChecked());
|
||||
if (_showTracksAction->isChecked() != SHOW_TRACKS_DEFAULT)
|
||||
settings.setValue(SHOW_TRACKS_SETTING, _showTracksAction->isChecked());
|
||||
if (_showRoutesAction->isChecked() != SHOW_ROUTES_DEFAULT)
|
||||
settings.setValue(SHOW_ROUTES_SETTING, _showRoutesAction->isChecked());
|
||||
if (_showWaypointsAction->isChecked() != SHOW_WAYPOINTS_DEFAULT)
|
||||
settings.setValue(SHOW_WAYPOINTS_SETTING,
|
||||
_showWaypointsAction->isChecked());
|
||||
if (_showWaypointLabelsAction->isChecked() != SHOW_WAYPOINT_LABELS_DEFAULT)
|
||||
settings.setValue(SHOW_WAYPOINT_LABELS_SETTING,
|
||||
_showWaypointLabelsAction->isChecked());
|
||||
if (_showRouteWaypointsAction->isChecked() != SHOW_ROUTE_WAYPOINTS_DEFAULT)
|
||||
settings.setValue(SHOW_ROUTE_WAYPOINTS_SETTING,
|
||||
_showRouteWaypointsAction->isChecked());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(EXPORT_SETTINGS_GROUP);
|
||||
if (_export.orientation != PAPER_ORIENTATION_DEFAULT)
|
||||
settings.setValue(PAPER_ORIENTATION_SETTING, _export.orientation);
|
||||
if (_export.paperSize != PAPER_SIZE_DEFAULT)
|
||||
settings.setValue(PAPER_SIZE_SETTING, _export.paperSize);
|
||||
if (_export.margins.left() != MARGIN_LEFT_DEFAULT)
|
||||
settings.setValue(MARGIN_LEFT_SETTING, _export.margins.left());
|
||||
if (_export.margins.top() != MARGIN_TOP_DEFAULT)
|
||||
settings.setValue(MARGIN_TOP_SETTING, _export.margins.top());
|
||||
if (_export.margins.right() != MARGIN_RIGHT_DEFAULT)
|
||||
settings.setValue(MARGIN_RIGHT_SETTING, _export.margins.right());
|
||||
if (_export.margins.bottom() != MARGIN_BOTTOM_DEFAULT)
|
||||
settings.setValue(MARGIN_BOTTOM_SETTING, _export.margins.bottom());
|
||||
if (_export.fileName != EXPORT_FILENAME_DEFAULT)
|
||||
settings.setValue(EXPORT_FILENAME_SETTING, _export.fileName);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(OPTIONS_SETTINGS_GROUP);
|
||||
if (_options.palette.color() != PALETTE_COLOR_DEFAULT)
|
||||
settings.setValue(PALETTE_COLOR_SETTING, _options.palette.color());
|
||||
if (_options.palette.shift() != PALETTE_SHIFT_DEFAULT)
|
||||
settings.setValue(PALETTE_SHIFT_SETTING, _options.palette.shift());
|
||||
if (_options.trackWidth != TRACK_WIDTH_DEFAULT)
|
||||
settings.setValue(TRACK_WIDTH_SETTING, _options.trackWidth);
|
||||
if (_options.routeWidth != ROUTE_WIDTH_DEFAULT)
|
||||
settings.setValue(ROUTE_WIDTH_SETTING, _options.routeWidth);
|
||||
if (_options.trackStyle != TRACK_STYLE_DEFAULT)
|
||||
settings.setValue(TRACK_STYLE_SETTING, (int)_options.trackStyle);
|
||||
if (_options.routeStyle != ROUTE_STYLE_DEFAULT)
|
||||
settings.setValue(ROUTE_STYLE_SETTING, (int)_options.routeStyle);
|
||||
if (_options.graphWidth != GRAPH_WIDTH_DEFAULT)
|
||||
settings.setValue(GRAPH_WIDTH_SETTING, _options.graphWidth);
|
||||
if (_options.pathAntiAliasing != PATH_AA_DEFAULT)
|
||||
settings.setValue(PATH_AA_SETTING, _options.pathAntiAliasing);
|
||||
if (_options.graphAntiAliasing != GRAPH_AA_DEFAULT)
|
||||
settings.setValue(GRAPH_AA_SETTING, _options.graphAntiAliasing);
|
||||
if (_options.poiRadius != POI_RADIUS_DEFAULT)
|
||||
settings.setValue(POI_RADIUS_SETTING, _options.poiRadius);
|
||||
if (_options.useOpenGL != USE_OPENGL_DEFAULT)
|
||||
settings.setValue(USE_OPENGL_SETTING, _options.useOpenGL);
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
@ -1288,26 +1377,24 @@ void GUI::readSettings()
|
||||
QSettings settings(APP_NAME, APP_NAME);
|
||||
|
||||
settings.beginGroup(WINDOW_SETTINGS_GROUP);
|
||||
resize(settings.value(WINDOW_SIZE_SETTING, QSize(600, 800)).toSize());
|
||||
move(settings.value(WINDOW_POS_SETTING, QPoint(10, 10)).toPoint());
|
||||
resize(settings.value(WINDOW_SIZE_SETTING, WINDOW_SIZE_DEFAULT).toSize());
|
||||
move(settings.value(WINDOW_POS_SETTING, WINDOW_POS_DEFAULT).toPoint());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
|
||||
Units u = QLocale::system().measurementSystem() == QLocale::ImperialSystem
|
||||
? Imperial : Metric;
|
||||
if (settings.value(UNITS_SETTING, u).toInt() == Imperial) {
|
||||
if (settings.value(UNITS_SETTING, UNITS_DEFAULT).toInt() == Imperial) {
|
||||
setImperialUnits();
|
||||
_imperialUnitsAction->setChecked(true);
|
||||
} else
|
||||
_metricUnitsAction->setChecked(true);
|
||||
if (settings.value(SHOW_TOOLBARS_SETTING, true).toBool() == false)
|
||||
if (!settings.value(SHOW_TOOLBARS_SETTING, SHOW_TOOLBARS_DEFAULT).toBool())
|
||||
showToolbars(false);
|
||||
else
|
||||
_showToolbarsAction->setChecked(true);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(MAP_SETTINGS_GROUP);
|
||||
if (settings.value(SHOW_MAP_SETTING, true).toBool() == true)
|
||||
if (settings.value(SHOW_MAP_SETTING, SHOW_MAP_DEFAULT).toBool())
|
||||
_showMapAction->setChecked(true);
|
||||
if (_maps.count()) {
|
||||
int index = mapIndex(settings.value(CURRENT_MAP_SETTING).toString());
|
||||
@ -1320,31 +1407,33 @@ void GUI::readSettings()
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(GRAPH_SETTINGS_GROUP);
|
||||
if (settings.value(SHOW_GRAPHS_SETTING, true).toBool() == false)
|
||||
if (!settings.value(SHOW_GRAPHS_SETTING, SHOW_GRAPHS_DEFAULT).toBool())
|
||||
showGraphs(false);
|
||||
else
|
||||
_showGraphsAction->setChecked(true);
|
||||
if (settings.value(GRAPH_TYPE_SETTING, Distance).toInt() == Time) {
|
||||
if (settings.value(GRAPH_TYPE_SETTING, GRAPH_TYPE_DEFAULT).toInt()
|
||||
== Time) {
|
||||
setTimeGraph();
|
||||
_timeGraphAction->setChecked(true);
|
||||
} else
|
||||
_distanceGraphAction->setChecked(true);
|
||||
if (settings.value(SHOW_GRAPH_GRIDS_SETTING, true).toBool() == false)
|
||||
if (!settings.value(SHOW_GRAPH_GRIDS_SETTING, SHOW_GRAPH_GRIDS_DEFAULT)
|
||||
.toBool())
|
||||
showGraphGrids(false);
|
||||
else
|
||||
_showGraphGridAction->setChecked(true);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(POI_SETTINGS_GROUP);
|
||||
if (settings.value(OVERLAP_POI_SETTING, true).toBool() == false)
|
||||
if (!settings.value(OVERLAP_POI_SETTING, OVERLAP_POI_DEFAULT).toBool())
|
||||
_pathView->setPOIOverlap(false);
|
||||
else
|
||||
_overlapPOIAction->setChecked(true);
|
||||
if (settings.value(LABELS_POI_SETTING, true).toBool() == false)
|
||||
if (!settings.value(LABELS_POI_SETTING, LABELS_POI_DEFAULT).toBool())
|
||||
_pathView->showPOILabels(false);
|
||||
else
|
||||
_showPOILabelsAction->setChecked(true);
|
||||
if (settings.value(SHOW_POI_SETTING, false).toBool() == true)
|
||||
if (settings.value(SHOW_POI_SETTING, SHOW_POI_DEFAULT).toBool())
|
||||
_showPOIAction->setChecked(true);
|
||||
else
|
||||
_pathView->showPOI(false);
|
||||
@ -1364,31 +1453,77 @@ void GUI::readSettings()
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(DATA_SETTINGS_GROUP);
|
||||
if (settings.value(SHOW_TRACKS_SETTING, true).toBool() == false) {
|
||||
if (!settings.value(SHOW_TRACKS_SETTING, SHOW_TRACKS_DEFAULT).toBool()) {
|
||||
_pathView->showTracks(false);
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->showTracks(false);
|
||||
} else
|
||||
_showTracksAction->setChecked(true);
|
||||
if (settings.value(SHOW_ROUTES_SETTING, true).toBool() == false) {
|
||||
if (!settings.value(SHOW_ROUTES_SETTING, SHOW_ROUTES_DEFAULT).toBool()) {
|
||||
_pathView->showRoutes(false);
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
_tabs.at(i)->showRoutes(false);
|
||||
} else
|
||||
_showRoutesAction->setChecked(true);
|
||||
if (settings.value(SHOW_WAYPOINTS_SETTING, true).toBool() == false)
|
||||
if (!settings.value(SHOW_WAYPOINTS_SETTING, SHOW_WAYPOINTS_DEFAULT)
|
||||
.toBool())
|
||||
_pathView->showWaypoints(false);
|
||||
else
|
||||
_showWaypointsAction->setChecked(true);
|
||||
if (settings.value(SHOW_WAYPOINT_LABELS_SETTING, true).toBool() == false)
|
||||
if (!settings.value(SHOW_WAYPOINT_LABELS_SETTING,
|
||||
SHOW_WAYPOINT_LABELS_DEFAULT).toBool())
|
||||
_pathView->showWaypointLabels(false);
|
||||
else
|
||||
_showWaypointLabelsAction->setChecked(true);
|
||||
if (settings.value(SHOW_ROUTE_WAYPOINTS_SETTING, true).toBool() == false)
|
||||
if (!settings.value(SHOW_ROUTE_WAYPOINTS_SETTING,
|
||||
SHOW_ROUTE_WAYPOINTS_SETTING).toBool())
|
||||
_pathView->showRouteWaypoints(false);
|
||||
else
|
||||
_showRouteWaypointsAction->setChecked(true);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(EXPORT_SETTINGS_GROUP);
|
||||
_export.orientation = (QPrinter::Orientation) settings.value(
|
||||
PAPER_ORIENTATION_SETTING, PAPER_ORIENTATION_DEFAULT).toInt();
|
||||
_export.paperSize = (QPrinter::PaperSize) settings.value(PAPER_SIZE_SETTING,
|
||||
PAPER_SIZE_DEFAULT).toInt();
|
||||
qreal ml = settings.value(MARGIN_LEFT_SETTING, MARGIN_LEFT_DEFAULT)
|
||||
.toReal();
|
||||
qreal mt = settings.value(MARGIN_TOP_SETTING, MARGIN_TOP_DEFAULT).toReal();
|
||||
qreal mr = settings.value(MARGIN_RIGHT_SETTING, MARGIN_RIGHT_DEFAULT)
|
||||
.toReal();
|
||||
qreal mb = settings.value(MARGIN_BOTTOM_SETTING, MARGIN_BOTTOM_DEFAULT)
|
||||
.toReal();
|
||||
_export.margins = MarginsF(ml, mt, mr, mb);
|
||||
_export.fileName = settings.value(EXPORT_FILENAME_SETTING,
|
||||
EXPORT_FILENAME_DEFAULT).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(OPTIONS_SETTINGS_GROUP);
|
||||
QColor pc = settings.value(PALETTE_COLOR_SETTING, PALETTE_COLOR_DEFAULT)
|
||||
.value<QColor>();
|
||||
qreal ps = settings.value(PALETTE_SHIFT_SETTING, PALETTE_SHIFT_DEFAULT)
|
||||
.toDouble();
|
||||
_options.palette = Palette(pc, ps);
|
||||
_options.trackWidth = settings.value(TRACK_WIDTH_SETTING,
|
||||
TRACK_WIDTH_DEFAULT).toInt();
|
||||
_options.routeWidth = settings.value(ROUTE_WIDTH_SETTING,
|
||||
ROUTE_WIDTH_DEFAULT).toInt();
|
||||
_options.trackStyle = (Qt::PenStyle) settings.value(TRACK_STYLE_SETTING,
|
||||
(int)TRACK_STYLE_DEFAULT).toInt();
|
||||
_options.routeStyle = (Qt::PenStyle) settings.value(ROUTE_STYLE_SETTING,
|
||||
(int)ROUTE_STYLE_DEFAULT).toInt();
|
||||
_options.graphWidth = settings.value(GRAPH_WIDTH_SETTING,
|
||||
GRAPH_WIDTH_DEFAULT).toInt();
|
||||
_options.pathAntiAliasing = settings.value(PATH_AA_SETTING, PATH_AA_DEFAULT)
|
||||
.toBool();
|
||||
_options.graphAntiAliasing = settings.value(GRAPH_AA_SETTING,
|
||||
GRAPH_AA_DEFAULT).toBool();
|
||||
_options.poiRadius = settings.value(POI_RADIUS_SETTING, POI_RADIUS_DEFAULT)
|
||||
.toInt();
|
||||
_options.useOpenGL = settings.value(USE_OPENGL_SETTING, USE_OPENGL_DEFAULT)
|
||||
.toBool();
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
int GUI::mapIndex(const QString &name)
|
||||
|
11
src/gui.h
11
src/gui.h
@ -9,7 +9,8 @@
|
||||
#include "units.h"
|
||||
#include "graph.h"
|
||||
#include "poi.h"
|
||||
#include "margins.h"
|
||||
#include "exportdialog.h"
|
||||
#include "optionsdialog.h"
|
||||
|
||||
class QMenu;
|
||||
class QToolBar;
|
||||
@ -55,6 +56,7 @@ private slots:
|
||||
void clearMapCache();
|
||||
void nextMap();
|
||||
void prevMap();
|
||||
void openOptions();
|
||||
|
||||
void mapChanged(int);
|
||||
void graphChanged(int);
|
||||
@ -159,6 +161,7 @@ private:
|
||||
QAction *_showWaypointsAction;
|
||||
QAction *_showWaypointLabelsAction;
|
||||
QAction *_showRouteWaypointsAction;
|
||||
QAction *_openOptionsAction;
|
||||
QList<QAction*> _mapActions;
|
||||
QList<QAction*> _poiFilesActions;
|
||||
|
||||
@ -192,10 +195,8 @@ private:
|
||||
int _frameStyle;
|
||||
bool _showGraphs;
|
||||
|
||||
QString _exportFileName;
|
||||
QPrinter::PaperSize _exportPaperSize;
|
||||
QPrinter::Orientation _exportOrientation;
|
||||
MarginsF _exportMargins;
|
||||
Export _export;
|
||||
Options _options;
|
||||
};
|
||||
|
||||
#endif // GUI_H
|
||||
|
@ -1,7 +1,9 @@
|
||||
#ifndef ICONS_H
|
||||
#define ICONS_H
|
||||
|
||||
#define APP_ICON ":/icons/gpxsee.png"
|
||||
#define APP_ICON ":/icons/gpxsee.png"
|
||||
|
||||
// Toolbar/menu icons
|
||||
#define OPEN_FILE_ICON ":/icons/document-open.png"
|
||||
#define EXPORT_FILE_ICON ":/icons/document-export.png"
|
||||
#define PRINT_FILE_ICON ":/icons/document-print.png"
|
||||
@ -17,4 +19,9 @@
|
||||
#define FIRST_FILE_ICON ":/icons/arrow-left-double.png"
|
||||
#define FULLSCREEN_ICON ":/icons/view-fullscreen.png"
|
||||
|
||||
// Options dialog icons
|
||||
#define APPEARANCE_ICON ":/icons/preferences-desktop-display.png"
|
||||
#define POI_ICON ":/icons/flag_48.png"
|
||||
#define SYSTEM_ICON ":/icons/system-run.png"
|
||||
|
||||
#endif /* ICONS_H */
|
||||
|
203
src/optionsdialog.cpp
Normal file
203
src/optionsdialog.cpp
Normal file
@ -0,0 +1,203 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QFormLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QListWidget>
|
||||
#include <QListWidgetItem>
|
||||
#include <QStackedWidget>
|
||||
#include <QTabWidget>
|
||||
#include <QSpinBox>
|
||||
#include <QGroupBox>
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QSysInfo>
|
||||
#include "config.h"
|
||||
#include "units.h"
|
||||
#include "icons.h"
|
||||
#include "colorbox.h"
|
||||
#include "stylecombobox.h"
|
||||
#include "optionsdialog.h"
|
||||
|
||||
#define MENU_MARGIN 20
|
||||
|
||||
|
||||
QWidget *OptionsDialog::createAppearancePage()
|
||||
{
|
||||
_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);
|
||||
|
||||
QWidget *colorTab = new QWidget();
|
||||
colorTab->setLayout(paletteLayout);
|
||||
|
||||
|
||||
_trackWidth = new QSpinBox();
|
||||
_trackWidth->setValue(_options->trackWidth);
|
||||
_trackWidth->setMinimum(1);
|
||||
_trackStyle = new StyleComboBox();
|
||||
_trackStyle->setValue(_options->trackStyle);
|
||||
QGroupBox *trackBox = new QGroupBox(tr("Tracks"));
|
||||
QFormLayout *trackLayout = new QFormLayout();
|
||||
trackLayout->addRow(tr("Line width:"), _trackWidth);
|
||||
trackLayout->addRow(tr("Line style:"), _trackStyle);
|
||||
trackBox->setLayout(trackLayout);
|
||||
|
||||
_routeWidth = new QSpinBox();
|
||||
_routeWidth->setValue(_options->routeWidth);
|
||||
_routeWidth->setMinimum(1);
|
||||
_routeStyle = new StyleComboBox();
|
||||
_routeStyle->setValue(_options->routeStyle);
|
||||
QGroupBox *routeBox = new QGroupBox(tr("Routes"));
|
||||
QFormLayout *routeLayout = new QFormLayout();
|
||||
routeLayout->addRow(tr("Line width:"), _routeWidth);
|
||||
routeLayout->addRow(tr("Line style:"), _routeStyle);
|
||||
routeBox->setLayout(routeLayout);
|
||||
|
||||
_pathAA = new QCheckBox(tr("Use anti-aliasing"));
|
||||
_pathAA->setChecked(_options->pathAntiAliasing);
|
||||
|
||||
QWidget *pathTab = new QWidget();
|
||||
QVBoxLayout *pathTabLayout = new QVBoxLayout();
|
||||
pathTabLayout->addWidget(trackBox);
|
||||
pathTabLayout->addWidget(routeBox);
|
||||
pathTabLayout->addWidget(_pathAA);
|
||||
pathTab->setLayout(pathTabLayout);
|
||||
|
||||
|
||||
_graphWidth = new QSpinBox();
|
||||
_graphWidth->setValue(_options->graphWidth);
|
||||
_graphWidth->setMinimum(1);
|
||||
QFormLayout *graphLayout = new QFormLayout();
|
||||
graphLayout->addRow(tr("Line width:"), _graphWidth);
|
||||
|
||||
_graphAA = new QCheckBox(tr("Use anti-aliasing"));
|
||||
_graphAA->setChecked(_options->graphAntiAliasing);
|
||||
|
||||
QWidget *graphTab = new QWidget();
|
||||
QVBoxLayout *graphTabLayout = new QVBoxLayout();
|
||||
graphTabLayout->addLayout(graphLayout);
|
||||
graphTabLayout->addWidget(_graphAA);
|
||||
graphTabLayout->addStretch();
|
||||
graphTab->setLayout(graphTabLayout);
|
||||
|
||||
QTabWidget *appearancePage = new QTabWidget();
|
||||
appearancePage->addTab(colorTab, tr("Colors"));
|
||||
appearancePage->addTab(pathTab, tr("Paths"));
|
||||
appearancePage->addTab(graphTab, tr("Graphs"));
|
||||
|
||||
return appearancePage;
|
||||
}
|
||||
|
||||
QWidget *OptionsDialog::createPOIPage()
|
||||
{
|
||||
_poiRadius = new QDoubleSpinBox();
|
||||
_poiRadius->setSingleStep(1);
|
||||
_poiRadius->setDecimals(1);
|
||||
_poiRadius->setValue(_options->poiRadius / 1000);
|
||||
_poiRadius->setSuffix(UNIT_SPACE + tr("km"));
|
||||
|
||||
QFormLayout *poiLayout = new QFormLayout();
|
||||
poiLayout->addRow(tr("POI radius:"), _poiRadius);
|
||||
|
||||
QWidget *poiTab = new QWidget();
|
||||
poiTab->setLayout(poiLayout);
|
||||
|
||||
QTabWidget *poiPage = new QTabWidget();
|
||||
poiPage->addTab(poiTab, tr("POI"));
|
||||
|
||||
return poiPage;
|
||||
}
|
||||
|
||||
QWidget *OptionsDialog::createSystemPage()
|
||||
{
|
||||
_useOpenGL = new QCheckBox(tr("Use OpenGL"));
|
||||
#ifdef Q_OS_WIN32
|
||||
if (QSysInfo::WindowsVersion < QSysInfo::WV_VISTA) {
|
||||
_useOpenGL->setChecked(false);
|
||||
_useOpenGL->setEnabled(false);
|
||||
} else
|
||||
#endif // Q_OS_WIN32
|
||||
_useOpenGL->setChecked(_options->useOpenGL);
|
||||
|
||||
QFormLayout *systemLayout = new QFormLayout();
|
||||
systemLayout->addWidget(_useOpenGL);
|
||||
|
||||
QWidget *systemTab = new QWidget();
|
||||
systemTab->setLayout(systemLayout);
|
||||
|
||||
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(createPOIPage());
|
||||
pages->addWidget(createSystemPage());
|
||||
|
||||
QListWidget *menu = new QListWidget();
|
||||
new QListWidgetItem(QIcon(QPixmap(APPEARANCE_ICON)), tr("Appearance"),
|
||||
menu);
|
||||
new QListWidgetItem(QIcon(QPixmap(POI_ICON)), tr("POI"), menu);
|
||||
new QListWidgetItem(QIcon(QPixmap(SYSTEM_ICON)), tr("System"), menu);
|
||||
|
||||
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->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();
|
||||
_options->graphWidth = _graphWidth->value();
|
||||
_options->graphAntiAliasing = _graphAA->isChecked();
|
||||
|
||||
_options->poiRadius = _poiRadius->value() * 1000;
|
||||
|
||||
_options->useOpenGL = _useOpenGL->isChecked();
|
||||
|
||||
QDialog::accept();
|
||||
}
|
60
src/optionsdialog.h
Normal file
60
src/optionsdialog.h
Normal file
@ -0,0 +1,60 @@
|
||||
#ifndef OPTIONSDIALOG_H
|
||||
#define OPTIONSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "palette.h"
|
||||
|
||||
class ColorBox;
|
||||
class StyleComboBox;
|
||||
class QSpinBox;
|
||||
class QDoubleSpinBox;
|
||||
class QComboBox;
|
||||
class QCheckBox;
|
||||
|
||||
struct Options {
|
||||
// Appearance
|
||||
Palette palette;
|
||||
int trackWidth;
|
||||
int routeWidth;
|
||||
Qt::PenStyle trackStyle;
|
||||
Qt::PenStyle routeStyle;
|
||||
int graphWidth;
|
||||
bool pathAntiAliasing;
|
||||
bool graphAntiAliasing;
|
||||
// POI
|
||||
int poiRadius;
|
||||
// System
|
||||
bool useOpenGL;
|
||||
};
|
||||
|
||||
class OptionsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OptionsDialog(Options *options, QWidget *parent = 0);
|
||||
|
||||
public slots:
|
||||
void accept();
|
||||
|
||||
private:
|
||||
QWidget *createAppearancePage();
|
||||
QWidget *createPOIPage();
|
||||
QWidget *createSystemPage();
|
||||
|
||||
Options *_options;
|
||||
|
||||
ColorBox *_baseColor;
|
||||
QDoubleSpinBox *_colorOffset;
|
||||
QSpinBox *_trackWidth;
|
||||
StyleComboBox *_trackStyle;
|
||||
QSpinBox *_routeWidth;
|
||||
StyleComboBox *_routeStyle;
|
||||
QCheckBox *_pathAA;
|
||||
QSpinBox *_graphWidth;
|
||||
QCheckBox *_graphAA;
|
||||
QDoubleSpinBox *_poiRadius;
|
||||
QCheckBox *_useOpenGL;
|
||||
};
|
||||
|
||||
#endif // OPTIONSDIALOG_H
|
@ -1,62 +1,38 @@
|
||||
#include "palette.h"
|
||||
|
||||
|
||||
#define HUE_INIT 0.1f
|
||||
#define HUE_INCREMENT 0.62f
|
||||
#define SATURATION 0.99f
|
||||
#define VALUE 0.99f
|
||||
|
||||
static unsigned hsv2rgb(float h, float s, float v)
|
||||
Palette::Palette(const QColor &color, qreal shift)
|
||||
{
|
||||
unsigned hi;
|
||||
float r = 0, g = 0, b = 0, p, q, t, f;
|
||||
_h = 0; _s = 0; _v = 0; _a = 1.0;
|
||||
|
||||
hi = (unsigned)(h * 6.0f);
|
||||
f = h * 6.0f - hi;
|
||||
p = v * (1.0f - s);
|
||||
q = v * (1.0f - f * s);
|
||||
t = v * (1.0f - (1.0f - f) * s);
|
||||
setColor(color);
|
||||
setShift(shift);
|
||||
|
||||
switch (hi) {
|
||||
case 0:
|
||||
r = v; g = t; b = p;
|
||||
break;
|
||||
case 1:
|
||||
r = q; g = v; b = p;
|
||||
break;
|
||||
case 2:
|
||||
r = p; g = v; b = t;
|
||||
break;
|
||||
case 3:
|
||||
r = p; g = q; b = v;
|
||||
break;
|
||||
case 4:
|
||||
r = t; g = p; b = v;
|
||||
break;
|
||||
case 5:
|
||||
r = v; g = p; b = q;
|
||||
break;
|
||||
}
|
||||
|
||||
return ((unsigned)(r * 256) << 16)
|
||||
+ ((unsigned)(g * 256) << 8)
|
||||
+ (unsigned)(b * 256);
|
||||
_state = _h;
|
||||
}
|
||||
|
||||
Palette::Palette()
|
||||
void Palette::setColor(const QColor &color)
|
||||
{
|
||||
_hueState = HUE_INIT;
|
||||
if (color.isValid())
|
||||
color.getHsvF(&_h, &_s, &_v, &_a);
|
||||
}
|
||||
|
||||
QColor Palette::color()
|
||||
void Palette::setShift(qreal shift)
|
||||
{
|
||||
_hueState += HUE_INCREMENT;
|
||||
_hueState -= (int) _hueState;
|
||||
if (shift >= 0 && shift <= 1.0)
|
||||
_shift = shift;
|
||||
}
|
||||
|
||||
return QColor(hsv2rgb(_hueState, SATURATION, VALUE));
|
||||
QColor Palette::nextColor()
|
||||
{
|
||||
QColor ret = QColor::fromHsvF(_state, _s, _v, _a);
|
||||
|
||||
_state += _shift;
|
||||
_state -= (int) _state;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Palette::reset()
|
||||
{
|
||||
_hueState = HUE_INIT;
|
||||
_state = _h;
|
||||
}
|
||||
|
@ -6,12 +6,25 @@
|
||||
class Palette
|
||||
{
|
||||
public:
|
||||
Palette();
|
||||
QColor color();
|
||||
Palette(const QColor &color = Qt::blue, qreal shift = 0.62);
|
||||
|
||||
QColor color() const {return QColor::fromHsvF(_h, _s, _v, _a);}
|
||||
qreal shift() const {return _shift;}
|
||||
void setColor(const QColor &color);
|
||||
void setShift(qreal shift);
|
||||
|
||||
QColor nextColor();
|
||||
void reset();
|
||||
|
||||
bool operator==(const Palette &other) const
|
||||
{return (_h == other._h && _s == other._s && _v == other._v
|
||||
&& _a == other._a && _shift == other._shift);}
|
||||
bool operator!=(const Palette &other) const
|
||||
{return !(*this == other);}
|
||||
|
||||
private:
|
||||
float _hueState;
|
||||
qreal _h, _s, _v, _a, _shift;
|
||||
qreal _state;
|
||||
};
|
||||
|
||||
#endif // PALLETE_H
|
||||
|
@ -6,13 +6,10 @@
|
||||
#include "pathitem.h"
|
||||
|
||||
|
||||
#define PATH_WIDTH 3
|
||||
#define HOVER_WIDTH 4
|
||||
|
||||
void PathItem::updateShape()
|
||||
{
|
||||
QPainterPathStroker s;
|
||||
s.setWidth(HOVER_WIDTH * 1.0/scale());
|
||||
s.setWidth((_width + 1) * 1.0/scale());
|
||||
_shape = s.createStroke(_path);
|
||||
|
||||
if (qMax(boundingRect().width(), boundingRect().height()) * scale() <= 768)
|
||||
@ -23,8 +20,10 @@ void PathItem::updateShape()
|
||||
|
||||
PathItem::PathItem(QGraphicsItem *parent) : QGraphicsObject(parent)
|
||||
{
|
||||
_width = 3;
|
||||
|
||||
QBrush brush(Qt::SolidPattern);
|
||||
_pen = QPen(brush, PATH_WIDTH);
|
||||
_pen = QPen(brush, _width);
|
||||
|
||||
_units = Metric;
|
||||
|
||||
@ -54,7 +53,7 @@ void PathItem::setScale(qreal scale)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
|
||||
_pen.setWidthF(PATH_WIDTH * 1.0/scale);
|
||||
_pen.setWidthF(_width * 1.0/scale);
|
||||
QGraphicsItem::setScale(scale);
|
||||
_marker->setScale(1.0/scale);
|
||||
|
||||
@ -67,6 +66,22 @@ void PathItem::setColor(const QColor &color)
|
||||
update();
|
||||
}
|
||||
|
||||
void PathItem::setWidth(int width)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
|
||||
_width = width;
|
||||
_pen.setWidthF(_width * 1.0/scale());
|
||||
|
||||
updateShape();
|
||||
}
|
||||
|
||||
void PathItem::setStyle(Qt::PenStyle style)
|
||||
{
|
||||
_pen.setStyle(style);
|
||||
update();
|
||||
}
|
||||
|
||||
void PathItem::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
@ -120,7 +135,7 @@ void PathItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
_pen.setWidthF(HOVER_WIDTH * 1.0/scale());
|
||||
_pen.setWidthF((_width + 1) * 1.0/scale());
|
||||
setZValue(zValue() + 1.0);
|
||||
update();
|
||||
|
||||
@ -131,7 +146,7 @@ void PathItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
|
||||
_pen.setWidthF(PATH_WIDTH * 1.0/scale());
|
||||
_pen.setWidthF(_width * 1.0/scale());
|
||||
setZValue(zValue() - 1.0);
|
||||
update();
|
||||
|
||||
|
@ -24,6 +24,8 @@ public:
|
||||
void setScale(qreal scale);
|
||||
void setUnits(enum Units units);
|
||||
void setColor(const QColor &color);
|
||||
void setWidth(int width);
|
||||
void setStyle(Qt::PenStyle style);
|
||||
|
||||
public slots:
|
||||
void moveMarker(qreal distance);
|
||||
@ -36,11 +38,7 @@ protected:
|
||||
|
||||
QVector<qreal> _distance;
|
||||
QPainterPath _path;
|
||||
QPainterPath _shape;
|
||||
QPen _pen;
|
||||
|
||||
MarkerItem *_marker;
|
||||
|
||||
Units _units;
|
||||
|
||||
private:
|
||||
@ -48,6 +46,10 @@ private:
|
||||
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
|
||||
int _width;
|
||||
QPen _pen;
|
||||
QPainterPath _shape;
|
||||
};
|
||||
|
||||
#endif // PATHITEM_H
|
||||
|
@ -1,6 +1,12 @@
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsScene>
|
||||
#include <QWheelEvent>
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
#include <QGLWidget>
|
||||
#else // QT 5
|
||||
#include <QOpenGLWidget>
|
||||
#endif // QT 5
|
||||
#include <QSysInfo>
|
||||
#include "rd.h"
|
||||
#include "poi.h"
|
||||
#include "data.h"
|
||||
@ -90,7 +96,7 @@ PathView::PathView(QWidget *parent)
|
||||
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setRenderHints(QPainter::Antialiasing);
|
||||
setRenderHint(QPainter::Antialiasing, true);
|
||||
setAcceptDrops(false);
|
||||
|
||||
_mapScale = new ScaleItem();
|
||||
@ -110,6 +116,10 @@ PathView::PathView(QWidget *parent)
|
||||
_showPOILabels = true;
|
||||
_overlapPOIs = true;
|
||||
_showRouteWaypoints = true;
|
||||
_trackWidth = 3;
|
||||
_routeWidth = 3;
|
||||
_trackStyle = Qt::SolidLine;
|
||||
_routeStyle = Qt::DashLine;
|
||||
|
||||
_plot = false;
|
||||
}
|
||||
@ -123,7 +133,7 @@ PathView::~PathView()
|
||||
PathItem *PathView::addTrack(const Track &track)
|
||||
{
|
||||
if (track.isNull()) {
|
||||
_palette.color();
|
||||
_palette.nextColor();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -132,7 +142,9 @@ PathItem *PathView::addTrack(const Track &track)
|
||||
_tr |= ti->path().boundingRect();
|
||||
_zoom = scale2zoom(contentsScale());
|
||||
ti->setScale(1.0/mapScale(_zoom));
|
||||
ti->setColor(_palette.color());
|
||||
ti->setColor(_palette.nextColor());
|
||||
ti->setWidth(_trackWidth);
|
||||
ti->setStyle(_trackStyle);
|
||||
ti->setVisible(_showTracks);
|
||||
_scene->addItem(ti);
|
||||
|
||||
@ -145,7 +157,7 @@ PathItem *PathView::addTrack(const Track &track)
|
||||
PathItem *PathView::addRoute(const Route &route)
|
||||
{
|
||||
if (route.isNull()) {
|
||||
_palette.color();
|
||||
_palette.nextColor();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -154,7 +166,9 @@ PathItem *PathView::addRoute(const Route &route)
|
||||
_rr |= ri->path().boundingRect();
|
||||
_zoom = scale2zoom(contentsScale());
|
||||
ri->setScale(1.0/mapScale(_zoom));
|
||||
ri->setColor(_palette.color());
|
||||
ri->setColor(_palette.nextColor());
|
||||
ri->setWidth(_routeWidth);
|
||||
ri->setStyle(_routeStyle);
|
||||
ri->setVisible(_showRoutes);
|
||||
ri->showWaypoints(_showRouteWaypoints);
|
||||
ri->showWaypointLabels(_showWaypointLabels);
|
||||
@ -297,6 +311,17 @@ void PathView::rescale(int zoom)
|
||||
updatePOIVisibility();
|
||||
}
|
||||
|
||||
void PathView::setPalette(const Palette &palette)
|
||||
{
|
||||
_palette = palette;
|
||||
_palette.reset();
|
||||
|
||||
for (int i = 0; i < _tracks.count(); i++)
|
||||
_tracks.at(i)->setColor(_palette.nextColor());
|
||||
for (int i = 0; i < _routes.count(); i++)
|
||||
_routes.at(i)->setColor(_palette.nextColor());
|
||||
}
|
||||
|
||||
void PathView::setPOI(POI *poi)
|
||||
{
|
||||
if (_poi)
|
||||
@ -585,6 +610,38 @@ void PathView::setPOIOverlap(bool overlap)
|
||||
updatePOIVisibility();
|
||||
}
|
||||
|
||||
void PathView::setTrackWidth(int width)
|
||||
{
|
||||
_trackWidth = width;
|
||||
|
||||
for (int i = 0; i < _tracks.count(); i++)
|
||||
_tracks.at(i)->setWidth(width);
|
||||
}
|
||||
|
||||
void PathView::setRouteWidth(int width)
|
||||
{
|
||||
_routeWidth = width;
|
||||
|
||||
for (int i = 0; i < _routes.count(); i++)
|
||||
_routes.at(i)->setWidth(width);
|
||||
}
|
||||
|
||||
void PathView::setTrackStyle(Qt::PenStyle style)
|
||||
{
|
||||
_trackStyle = style;
|
||||
|
||||
for (int i = 0; i < _tracks.count(); i++)
|
||||
_tracks.at(i)->setStyle(style);
|
||||
}
|
||||
|
||||
void PathView::setRouteStyle(Qt::PenStyle style)
|
||||
{
|
||||
_routeStyle = style;
|
||||
|
||||
for (int i = 0; i < _routes.count(); i++)
|
||||
_routes.at(i)->setStyle(style);
|
||||
}
|
||||
|
||||
void PathView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
if ((_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||
@ -652,3 +709,18 @@ void PathView::paintEvent(QPaintEvent *event)
|
||||
|
||||
QGraphicsView::paintEvent(event);
|
||||
}
|
||||
|
||||
void PathView::useOpenGL(bool use)
|
||||
{
|
||||
if (use) {
|
||||
#ifdef Q_OS_WIN32
|
||||
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
|
||||
#endif // Q_OS_WIN32
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
setViewport(new QGLWidget);
|
||||
#else // QT 5
|
||||
setViewport(new QOpenGLWidget);
|
||||
#endif // QT 5
|
||||
} else
|
||||
setViewport(new QWidget);
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
|
||||
QList<PathItem*> loadData(const Data &data);
|
||||
|
||||
void setPalette(const Palette &palette);
|
||||
void setPOI(POI *poi);
|
||||
void setMap(Map *map);
|
||||
void setUnits(enum Units units);
|
||||
@ -42,6 +43,8 @@ public:
|
||||
|
||||
void clear();
|
||||
|
||||
void useOpenGL(bool use);
|
||||
|
||||
public slots:
|
||||
void redraw();
|
||||
|
||||
@ -53,6 +56,10 @@ public slots:
|
||||
void showRoutes(bool show);
|
||||
void showWaypoints(bool show);
|
||||
void showRouteWaypoints(bool show);
|
||||
void setTrackWidth(int width);
|
||||
void setRouteWidth(int width);
|
||||
void setTrackStyle(Qt::PenStyle style);
|
||||
void setRouteStyle(Qt::PenStyle style);
|
||||
|
||||
private slots:
|
||||
void updatePOI();
|
||||
@ -103,6 +110,10 @@ private:
|
||||
bool _showPOILabels;
|
||||
bool _overlapPOIs;
|
||||
bool _showRouteWaypoints;
|
||||
int _trackWidth;
|
||||
int _routeWidth;
|
||||
Qt::PenStyle _trackStyle;
|
||||
Qt::PenStyle _routeStyle;
|
||||
|
||||
bool _plot;
|
||||
};
|
||||
|
40
src/poi.cpp
40
src/poi.cpp
@ -10,7 +10,7 @@
|
||||
POI::POI(QObject *parent) : QObject(parent)
|
||||
{
|
||||
_errorLine = 0;
|
||||
_radius = 0.01;
|
||||
_radius = 1000;
|
||||
}
|
||||
|
||||
bool POI::loadFile(const QString &fileName)
|
||||
@ -66,11 +66,15 @@ QVector<Waypoint> POI::points(const PathItem *path) const
|
||||
const QPainterPath &pp = path->path();
|
||||
|
||||
for (int i = 0; i < pp.elementCount(); i++) {
|
||||
Coordinates p = Coordinates::fromMercator(pp.elementAt(i));
|
||||
min[0] = p.lon() - _radius;
|
||||
min[1] = -p.lat() - _radius;
|
||||
max[0] = p.lon() + _radius;
|
||||
max[1] = -p.lat() + _radius;
|
||||
const QPainterPath::Element &pe = pp.elementAt(i);
|
||||
Coordinates p = Coordinates::fromMercator(QPointF(pe.x, -pe.y));
|
||||
|
||||
QPair<Coordinates, Coordinates> br = p.boundingRect(_radius);
|
||||
min[0] = br.first.lon();
|
||||
min[1] = br.first.lat();
|
||||
max[0] = br.second.lon();
|
||||
max[1] = br.second.lat();
|
||||
|
||||
_tree.Search(min, max, cb, &set);
|
||||
}
|
||||
|
||||
@ -92,10 +96,13 @@ QVector<Waypoint> POI::points(const QList<WaypointItem*> &list)
|
||||
|
||||
for (int i = 0; i < list.count(); i++) {
|
||||
const Coordinates &p = list.at(i)->waypoint().coordinates();
|
||||
min[0] = p.lon() - _radius;
|
||||
min[1] = p.lat() - _radius;
|
||||
max[0] = p.lon() + _radius;
|
||||
max[1] = p.lat() + _radius;
|
||||
|
||||
QPair<Coordinates, Coordinates> br = p.boundingRect(_radius);
|
||||
min[0] = br.first.lon();
|
||||
min[1] = br.first.lat();
|
||||
max[0] = br.second.lon();
|
||||
max[1] = br.second.lat();
|
||||
|
||||
_tree.Search(min, max, cb, &set);
|
||||
}
|
||||
|
||||
@ -116,10 +123,13 @@ QVector<Waypoint> POI::points(const QList<Waypoint> &list) const
|
||||
|
||||
for (int i = 0; i < list.count(); i++) {
|
||||
const Coordinates &p = list.at(i).coordinates();
|
||||
min[0] = p.lon() - _radius;
|
||||
min[1] = p.lat() - _radius;
|
||||
max[0] = p.lon() + _radius;
|
||||
max[1] = p.lat() + _radius;
|
||||
|
||||
QPair<Coordinates, Coordinates> br = p.boundingRect(_radius);
|
||||
min[0] = br.first.lon();
|
||||
min[1] = br.first.lat();
|
||||
max[0] = br.second.lon();
|
||||
max[1] = br.second.lat();
|
||||
|
||||
_tree.Search(min, max, cb, &set);
|
||||
}
|
||||
|
||||
@ -168,7 +178,7 @@ void POI::clear()
|
||||
emit pointsChanged();
|
||||
}
|
||||
|
||||
void POI::setRadius(qreal radius)
|
||||
void POI::setRadius(unsigned radius)
|
||||
{
|
||||
_radius = radius;
|
||||
|
||||
|
@ -22,8 +22,8 @@ public:
|
||||
const QString &errorString() const {return _errorString;}
|
||||
int errorLine() const {return _errorLine;}
|
||||
|
||||
qreal radius() const {return _radius;}
|
||||
void setRadius(qreal radius);
|
||||
unsigned radius() const {return _radius;}
|
||||
void setRadius(unsigned radius);
|
||||
|
||||
QVector<Waypoint> points(const PathItem *path) const;
|
||||
QVector<Waypoint> points(const QList<WaypointItem*> &list) const;
|
||||
@ -49,7 +49,7 @@ private:
|
||||
QStringList _files;
|
||||
QList<FileIndex> _indexes;
|
||||
|
||||
qreal _radius;
|
||||
unsigned _radius;
|
||||
|
||||
QString _errorString;
|
||||
int _errorLine;
|
||||
|
@ -52,8 +52,6 @@ RouteItem::RouteItem(const Route &route, QGraphicsItem *parent)
|
||||
|
||||
_marker->setPos(_path.elementAt(0));
|
||||
|
||||
_pen.setStyle(Qt::DotLine);
|
||||
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
||||
|
@ -3,33 +3,94 @@
|
||||
|
||||
#define WINDOW_SETTINGS_GROUP "Window"
|
||||
#define WINDOW_SIZE_SETTING "size"
|
||||
#define WINDOW_SIZE_DEFAULT QSize(600, 800)
|
||||
#define WINDOW_POS_SETTING "pos"
|
||||
#define WINDOW_POS_DEFAULT QPoint(10, 10)
|
||||
|
||||
#define SETTINGS_SETTINGS_GROUP "Settings"
|
||||
#define UNITS_SETTING "units"
|
||||
#define UNITS_DEFAULT \
|
||||
(QLocale::system().measurementSystem() == QLocale::ImperialSystem) \
|
||||
? Imperial : Metric
|
||||
#define SHOW_TOOLBARS_SETTING "toolbar"
|
||||
#define SHOW_TOOLBARS_DEFAULT true
|
||||
|
||||
#define GRAPH_SETTINGS_GROUP "Graph"
|
||||
#define SHOW_GRAPHS_SETTING "show"
|
||||
#define SHOW_GRAPHS_DEFAULT true
|
||||
#define GRAPH_TYPE_SETTING "type"
|
||||
#define GRAPH_TYPE_DEFAULT Distance
|
||||
#define SHOW_GRAPH_GRIDS_SETTING "grid"
|
||||
#define SHOW_GRAPH_GRIDS_DEFAULT true
|
||||
|
||||
#define MAP_SETTINGS_GROUP "Map"
|
||||
#define CURRENT_MAP_SETTING "map"
|
||||
#define SHOW_MAP_SETTING "show"
|
||||
#define SHOW_MAP_DEFAULT true
|
||||
|
||||
#define POI_SETTINGS_GROUP "POI"
|
||||
#define OVERLAP_POI_SETTING "overlap"
|
||||
#define OVERLAP_POI_DEFAULT false
|
||||
#define LABELS_POI_SETTING "labels"
|
||||
#define LABELS_POI_DEFAULT true
|
||||
#define SHOW_POI_SETTING "show"
|
||||
#define SHOW_POI_DEFAULT false
|
||||
#define DISABLED_POI_FILE_SETTINGS_PREFIX "disabled"
|
||||
#define DISABLED_POI_FILE_SETTING "file"
|
||||
|
||||
#define DATA_SETTINGS_GROUP "Data"
|
||||
#define SHOW_TRACKS_SETTING "tracks"
|
||||
#define SHOW_TRACKS_DEFAULT true
|
||||
#define SHOW_ROUTES_SETTING "routes"
|
||||
#define SHOW_ROUTES_DEFAULT true
|
||||
#define SHOW_WAYPOINTS_SETTING "waypoints"
|
||||
#define SHOW_WAYPOINTS_DEFAULT true
|
||||
#define SHOW_ROUTE_WAYPOINTS_SETTING "routeWaypoints"
|
||||
#define SHOW_ROUTE_WAYPOINTS_DEFAULT true
|
||||
#define SHOW_WAYPOINT_LABELS_SETTING "waypointLabels"
|
||||
#define SHOW_WAYPOINT_LABELS_DEFAULT true
|
||||
|
||||
#define EXPORT_SETTINGS_GROUP "Export"
|
||||
#define PAPER_ORIENTATION_SETTING "orientation"
|
||||
#define PAPER_ORIENTATION_DEFAULT QPrinter::Portrait
|
||||
#define PAPER_SIZE_SETTING "size"
|
||||
#define PAPER_SIZE_DEFAULT \
|
||||
(QLocale::system().measurementSystem() == QLocale::ImperialSystem) \
|
||||
? QPrinter::Letter : QPrinter::A4
|
||||
#define MARGIN_LEFT_SETTING "marginLeft"
|
||||
#define MARGIN_LEFT_DEFAULT 5
|
||||
#define MARGIN_TOP_SETTING "marginTop"
|
||||
#define MARGIN_TOP_DEFAULT 5
|
||||
#define MARGIN_RIGHT_SETTING "marginRight"
|
||||
#define MARGIN_RIGHT_DEFAULT 5
|
||||
#define MARGIN_BOTTOM_SETTING "marginBottom"
|
||||
#define MARGIN_BOTTOM_DEFAULT 5
|
||||
#define EXPORT_FILENAME_SETTING "fileName"
|
||||
#define EXPORT_FILENAME_DEFAULT \
|
||||
QString("%1/export.pdf").arg(QDir::currentPath())
|
||||
|
||||
#define OPTIONS_SETTINGS_GROUP "Options"
|
||||
#define PALETTE_COLOR_SETTING "paletteColor"
|
||||
#define PALETTE_COLOR_DEFAULT QColor(Qt::blue)
|
||||
#define PALETTE_SHIFT_SETTING "paletteShift"
|
||||
#define PALETTE_SHIFT_DEFAULT 0.62
|
||||
#define TRACK_WIDTH_SETTING "trackWidth"
|
||||
#define TRACK_WIDTH_DEFAULT 3
|
||||
#define ROUTE_WIDTH_SETTING "routeWidth"
|
||||
#define ROUTE_WIDTH_DEFAULT 3
|
||||
#define TRACK_STYLE_SETTING "trackStyle"
|
||||
#define TRACK_STYLE_DEFAULT Qt::SolidLine
|
||||
#define ROUTE_STYLE_SETTING "routeStyle"
|
||||
#define ROUTE_STYLE_DEFAULT Qt::DotLine
|
||||
#define GRAPH_WIDTH_SETTING "graphWidth"
|
||||
#define GRAPH_WIDTH_DEFAULT 1
|
||||
#define PATH_AA_SETTING "pathAntiAliasing"
|
||||
#define PATH_AA_DEFAULT true
|
||||
#define GRAPH_AA_SETTING "graphAntiAliasing"
|
||||
#define GRAPH_AA_DEFAULT false
|
||||
#define POI_RADIUS_SETTING "poiRadius"
|
||||
#define POI_RADIUS_DEFAULT 1000
|
||||
#define USE_OPENGL_SETTING "useOpenGL"
|
||||
#define USE_OPENGL_DEFAULT false
|
||||
|
||||
#endif // SETTINGS_H
|
||||
|
@ -32,9 +32,11 @@ void SliderInfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
||||
font.setPixelSize(FONT_SIZE);
|
||||
font.setFamily(FONT_FAMILY);
|
||||
QFontMetrics fm(font);
|
||||
painter->setFont(font);
|
||||
|
||||
painter->setFont(font);
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
painter->setPen(Qt::red);
|
||||
|
||||
if (_side == Right)
|
||||
painter->drawText(SIZE, fm.height() - fm.descent(), _text);
|
||||
else
|
||||
|
61
src/stylecombobox.cpp
Normal file
61
src/stylecombobox.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
#include <QPen>
|
||||
#include <QPainter>
|
||||
#include <QResizeEvent>
|
||||
#include "stylecombobox.h"
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*a))
|
||||
|
||||
StyleComboBox::StyleComboBox(QWidget *parent) : QComboBox(parent)
|
||||
{
|
||||
Qt::PenStyle styles[] = {Qt::SolidLine, Qt::DashLine, Qt::DotLine,
|
||||
Qt::DashDotLine, Qt::DashDotDotLine};
|
||||
|
||||
QSize is = iconSize();
|
||||
setIconSize(QSize(sizeHint().width(), is.height()));
|
||||
is = iconSize();
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(styles); i++) {
|
||||
QPixmap pm(is);
|
||||
pm.fill(Qt::transparent);
|
||||
|
||||
QBrush brush(Qt::black);
|
||||
QPen pen(brush, is.height() / 7, styles[i]);
|
||||
|
||||
QPainter painter(&pm);
|
||||
painter.setPen(pen);
|
||||
painter.drawLine(0, is.height() / 2, is.width(), is.height() / 2);
|
||||
|
||||
addItem(QIcon(pm), QString(), QVariant((int)styles[i]));
|
||||
}
|
||||
}
|
||||
|
||||
void StyleComboBox::setValue(Qt::PenStyle value)
|
||||
{
|
||||
for (int i = 0; i < count(); i++) {
|
||||
if ((Qt::PenStyle) itemData(i).toInt() == value) {
|
||||
setCurrentIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StyleComboBox::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QSize is = iconSize();
|
||||
setIconSize(QSize(event->size().width() - 30, is.height()));
|
||||
is = iconSize();
|
||||
|
||||
for (int i = 0; i < count(); i++) {
|
||||
QPixmap pm(is);
|
||||
pm.fill(Qt::transparent);
|
||||
|
||||
QBrush brush(Qt::black);
|
||||
QPen pen(brush, is.height() / 7, (Qt::PenStyle) itemData(i).toInt());
|
||||
|
||||
QPainter painter(&pm);
|
||||
painter.setPen(pen);
|
||||
painter.drawLine(0, is.height() / 2, is.width(), is.height() / 2);
|
||||
|
||||
setItemIcon(i, QIcon(pm));
|
||||
}
|
||||
}
|
19
src/stylecombobox.h
Normal file
19
src/stylecombobox.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef STYLECOMBOBOX_H
|
||||
#define STYLECOMBOBOX_H
|
||||
|
||||
#include <QComboBox>
|
||||
|
||||
class StyleComboBox : public QComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
StyleComboBox(QWidget *parent = 0);
|
||||
|
||||
void setValue(Qt::PenStyle value);
|
||||
|
||||
private:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
};
|
||||
|
||||
#endif // STYLECOMBOBOX_H
|
Loading…
Reference in New Issue
Block a user