2016-04-29 21:13:38 +02:00
|
|
|
#include <QApplication>
|
2016-10-19 23:38:28 +02:00
|
|
|
#include <QSplitter>
|
2015-10-05 01:43:48 +02:00
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QMenuBar>
|
|
|
|
#include <QStatusBar>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QFileDialog>
|
2016-05-15 22:38:15 +02:00
|
|
|
#include <QPrintDialog>
|
2015-10-05 01:43:48 +02:00
|
|
|
#include <QPainter>
|
2016-05-22 15:47:23 +02:00
|
|
|
#include <QPaintEngine>
|
|
|
|
#include <QPaintDevice>
|
2015-10-05 01:43:48 +02:00
|
|
|
#include <QKeyEvent>
|
2016-03-05 18:01:13 +01:00
|
|
|
#include <QMenu>
|
|
|
|
#include <QToolBar>
|
|
|
|
#include <QTabWidget>
|
|
|
|
#include <QActionGroup>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QLabel>
|
2016-04-26 09:39:16 +02:00
|
|
|
#include <QSettings>
|
2016-05-21 16:18:48 +02:00
|
|
|
#include <QLocale>
|
2016-10-04 10:16:46 +02:00
|
|
|
#include <QMimeData>
|
2016-10-08 21:16:56 +02:00
|
|
|
#include <QUrl>
|
2017-05-03 23:55:16 +02:00
|
|
|
#include <QPixmapCache>
|
2018-08-18 21:06:36 +02:00
|
|
|
#include <QWindow>
|
|
|
|
#include <QScreen>
|
|
|
|
#include <QStyle>
|
2021-02-19 19:36:26 +01:00
|
|
|
#include <QTabBar>
|
2018-11-02 20:01:19 +01:00
|
|
|
#include "common/programpaths.h"
|
2017-11-26 18:54:03 +01:00
|
|
|
#include "data/data.h"
|
2018-06-04 23:40:42 +02:00
|
|
|
#include "data/poi.h"
|
2017-11-26 18:54:03 +01:00
|
|
|
#include "map/maplist.h"
|
|
|
|
#include "map/emptymap.h"
|
2018-04-27 19:31:27 +02:00
|
|
|
#include "map/downloader.h"
|
2021-06-17 21:58:25 +02:00
|
|
|
#include "map/crs.h"
|
2015-10-05 01:43:48 +02:00
|
|
|
#include "icons.h"
|
|
|
|
#include "keys.h"
|
2016-04-28 08:49:06 +02:00
|
|
|
#include "settings.h"
|
2015-10-12 01:12:12 +02:00
|
|
|
#include "elevationgraph.h"
|
|
|
|
#include "speedgraph.h"
|
2016-03-21 22:37:55 +01:00
|
|
|
#include "heartrategraph.h"
|
2016-06-16 20:47:32 +02:00
|
|
|
#include "temperaturegraph.h"
|
2016-11-06 03:28:08 +01:00
|
|
|
#include "cadencegraph.h"
|
|
|
|
#include "powergraph.h"
|
2018-07-03 01:29:14 +02:00
|
|
|
#include "gearratiograph.h"
|
2017-12-01 00:22:16 +01:00
|
|
|
#include "mapview.h"
|
2016-05-12 09:03:05 +02:00
|
|
|
#include "trackinfo.h"
|
2015-10-20 22:18:41 +02:00
|
|
|
#include "filebrowser.h"
|
2016-06-24 00:55:44 +02:00
|
|
|
#include "graphtab.h"
|
2018-05-04 19:36:37 +02:00
|
|
|
#include "graphitem.h"
|
|
|
|
#include "pathitem.h"
|
2020-12-02 23:58:11 +01:00
|
|
|
#include "mapitem.h"
|
2020-03-17 21:06:51 +01:00
|
|
|
#include "mapaction.h"
|
2021-03-21 20:23:20 +01:00
|
|
|
#include "poiaction.h"
|
2015-10-19 00:35:08 +02:00
|
|
|
#include "gui.h"
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
|
2018-08-18 21:06:36 +02:00
|
|
|
#define TOOLBAR_ICON_SIZE 22
|
|
|
|
|
2017-03-18 01:30:31 +01:00
|
|
|
GUI::GUI()
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2021-03-20 09:59:03 +01:00
|
|
|
TreeNode<MapAction*> mapActions;
|
2021-03-21 20:23:20 +01:00
|
|
|
TreeNode<POIAction*> poiActions;
|
2021-03-20 09:59:03 +01:00
|
|
|
|
2021-03-21 20:23:20 +01:00
|
|
|
_poi = new POI(this);
|
2015-11-23 02:37:08 +01:00
|
|
|
|
2017-12-01 00:22:16 +01:00
|
|
|
createMapView();
|
2016-09-27 01:27:38 +02:00
|
|
|
createGraphTabs();
|
2015-10-05 01:43:48 +02:00
|
|
|
createStatusBar();
|
2021-03-21 20:23:20 +01:00
|
|
|
createActions(mapActions, poiActions);
|
|
|
|
createMenus(mapActions, poiActions);
|
2016-08-09 01:16:19 +02:00
|
|
|
createToolBars();
|
2016-10-23 11:09:20 +02:00
|
|
|
createBrowser();
|
2015-10-20 22:18:41 +02:00
|
|
|
|
2018-05-04 19:36:37 +02:00
|
|
|
_splitter = new QSplitter();
|
|
|
|
_splitter->setOrientation(Qt::Vertical);
|
|
|
|
_splitter->setChildrenCollapsible(false);
|
|
|
|
_splitter->addWidget(_mapView);
|
|
|
|
_splitter->addWidget(_graphTabWidget);
|
|
|
|
_splitter->setContentsMargins(0, 0, 0, 0);
|
|
|
|
_splitter->setStretchFactor(0, 255);
|
|
|
|
_splitter->setStretchFactor(1, 1);
|
|
|
|
setCentralWidget(_splitter);
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2018-08-18 21:06:36 +02:00
|
|
|
setWindowIcon(QIcon(APP_ICON));
|
2015-10-05 01:43:48 +02:00
|
|
|
setWindowTitle(APP_NAME);
|
|
|
|
setUnifiedTitleAndToolBarOnMac(true);
|
2016-12-06 21:02:44 +01:00
|
|
|
setAcceptDrops(true);
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2016-02-08 17:53:09 +01:00
|
|
|
_trackCount = 0;
|
2016-08-09 23:08:49 +02:00
|
|
|
_routeCount = 0;
|
|
|
|
_waypointCount = 0;
|
2019-01-31 01:46:53 +01:00
|
|
|
_areaCount = 0;
|
2016-08-10 20:36:09 +02:00
|
|
|
_trackDistance = 0;
|
|
|
|
_routeDistance = 0;
|
|
|
|
_time = 0;
|
2017-01-31 09:37:01 +01:00
|
|
|
_movingTime = 0;
|
2021-03-06 12:19:18 +01:00
|
|
|
_lastTab = 0;
|
2016-03-30 20:50:51 +02:00
|
|
|
|
2017-12-03 14:18:41 +01:00
|
|
|
readSettings();
|
|
|
|
|
2021-07-12 00:21:21 +02:00
|
|
|
_dataDir = _options.dataPath;
|
|
|
|
_mapDir = _options.mapsPath;
|
|
|
|
_poiDir = _options.poiPath;
|
|
|
|
|
2016-03-23 09:38:22 +01:00
|
|
|
updateGraphTabs();
|
2016-08-10 21:17:12 +02:00
|
|
|
updateStatusBarInfo();
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2017-07-27 19:47:46 +02:00
|
|
|
void GUI::createBrowser()
|
|
|
|
{
|
|
|
|
_browser = new FileBrowser(this);
|
|
|
|
_browser->setFilter(Data::filter());
|
2021-05-27 22:08:40 +02:00
|
|
|
connect(_browser, &FileBrowser::listChanged, this,
|
|
|
|
&GUI::updateNavigationActions);
|
2017-07-27 19:47:46 +02:00
|
|
|
}
|
|
|
|
|
2021-03-21 20:23:20 +01:00
|
|
|
TreeNode<MapAction*> GUI::createMapActions()
|
|
|
|
{
|
|
|
|
_mapsActionGroup = new QActionGroup(this);
|
|
|
|
_mapsActionGroup->setExclusive(true);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_mapsActionGroup, &QActionGroup::triggered, this, &GUI::mapChanged);
|
2021-03-21 20:23:20 +01:00
|
|
|
|
|
|
|
QString mapDir(ProgramPaths::mapDir());
|
|
|
|
if (mapDir.isNull())
|
|
|
|
return TreeNode<MapAction*>();
|
|
|
|
|
2021-06-17 21:58:25 +02:00
|
|
|
TreeNode<Map*> maps(MapList::loadMaps(mapDir,
|
|
|
|
CRS::projection(_options.inputProjection)));
|
2021-03-21 20:23:20 +01:00
|
|
|
return createMapActionsNode(maps);
|
|
|
|
}
|
|
|
|
|
2021-03-20 09:59:03 +01:00
|
|
|
TreeNode<MapAction*> GUI::createMapActionsNode(const TreeNode<Map*> &node)
|
2015-11-23 02:37:08 +01:00
|
|
|
{
|
2021-03-20 09:59:03 +01:00
|
|
|
TreeNode<MapAction*> tree(node.name());
|
2015-11-23 02:37:08 +01:00
|
|
|
|
2021-03-20 09:59:03 +01:00
|
|
|
for (int i = 0; i < node.childs().size(); i++)
|
|
|
|
tree.addChild(createMapActionsNode(node.childs().at(i)));
|
2015-11-23 02:37:08 +01:00
|
|
|
|
2021-03-20 09:59:03 +01:00
|
|
|
for (int i = 0; i < node.items().size(); i++) {
|
|
|
|
Map *map = node.items().at(i);
|
2020-12-09 23:07:05 +01:00
|
|
|
if (map->isValid()) {
|
2021-03-21 20:23:20 +01:00
|
|
|
MapAction *a = new MapAction(map, _mapsActionGroup);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(a, &MapAction::loaded, this, &GUI::mapInitialized);
|
2021-03-20 09:59:03 +01:00
|
|
|
tree.addItem(a);
|
2020-12-09 23:07:05 +01:00
|
|
|
} else {
|
|
|
|
qWarning("%s: %s", qPrintable(map->path()),
|
|
|
|
qPrintable(map->errorString()));
|
|
|
|
delete map;
|
|
|
|
}
|
2020-03-17 21:06:51 +01:00
|
|
|
}
|
2021-03-20 09:59:03 +01:00
|
|
|
|
|
|
|
return tree;
|
|
|
|
}
|
|
|
|
|
2020-03-17 21:06:51 +01:00
|
|
|
void GUI::mapInitialized()
|
|
|
|
{
|
|
|
|
MapAction *action = static_cast<MapAction*>(QObject::sender());
|
|
|
|
Map *map = action->data().value<Map*>();
|
|
|
|
|
|
|
|
if (map->isValid()) {
|
|
|
|
if (!_mapsActionGroup->checkedAction())
|
|
|
|
action->trigger();
|
|
|
|
_showMapAction->setEnabled(true);
|
|
|
|
_clearMapCacheAction->setEnabled(true);
|
|
|
|
} else {
|
2020-12-09 23:07:05 +01:00
|
|
|
qWarning("%s: %s", qPrintable(map->path()), qPrintable(map->errorString()));
|
2020-03-17 21:06:51 +01:00
|
|
|
action->deleteLater();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-21 20:23:20 +01:00
|
|
|
TreeNode<POIAction *> GUI::createPOIActions()
|
2016-03-05 18:01:13 +01:00
|
|
|
{
|
2021-03-21 20:23:20 +01:00
|
|
|
_poisActionGroup = new QActionGroup(this);
|
|
|
|
_poisActionGroup->setExclusive(false);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_poisActionGroup, &QActionGroup::triggered, this,
|
|
|
|
&GUI::poiFileChecked);
|
2016-03-05 18:01:13 +01:00
|
|
|
|
2021-03-21 20:23:20 +01:00
|
|
|
TreeNode<QString> poiFiles;
|
|
|
|
QString poiDir(ProgramPaths::poiDir());
|
|
|
|
if (!poiDir.isNull())
|
|
|
|
poiFiles = _poi->loadDir(poiDir);
|
|
|
|
|
|
|
|
return createPOIActionsNode(poiFiles);
|
2016-03-05 22:42:22 +01:00
|
|
|
}
|
2016-03-05 18:01:13 +01:00
|
|
|
|
2021-03-21 20:23:20 +01:00
|
|
|
TreeNode<POIAction *> GUI::createPOIActionsNode(const TreeNode<QString> &node)
|
2016-03-05 22:42:22 +01:00
|
|
|
{
|
2021-03-21 20:23:20 +01:00
|
|
|
TreeNode<POIAction*> tree(node.name());
|
2016-03-05 18:01:13 +01:00
|
|
|
|
2021-03-21 20:23:20 +01:00
|
|
|
for (int i = 0; i < node.childs().size(); i++)
|
|
|
|
tree.addChild(createPOIActionsNode(node.childs().at(i)));
|
|
|
|
for (int i = 0; i < node.items().size(); i++)
|
|
|
|
tree.addItem(new POIAction(node.items().at(i), _poisActionGroup));
|
2016-03-05 22:42:22 +01:00
|
|
|
|
2021-03-21 20:23:20 +01:00
|
|
|
return tree;
|
2016-03-05 18:01:13 +01:00
|
|
|
}
|
|
|
|
|
2021-03-21 20:23:20 +01:00
|
|
|
void GUI::createActions(TreeNode<MapAction*> &mapActions,
|
|
|
|
TreeNode<POIAction*> &poiActions)
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2016-09-19 00:56:10 +02:00
|
|
|
QActionGroup *ag;
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
// Action Groups
|
|
|
|
_fileActionGroup = new QActionGroup(this);
|
|
|
|
_fileActionGroup->setExclusive(false);
|
|
|
|
_fileActionGroup->setEnabled(false);
|
|
|
|
|
2015-12-18 22:21:11 +01:00
|
|
|
_navigationActionGroup = new QActionGroup(this);
|
|
|
|
_navigationActionGroup->setEnabled(false);
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
// General actions
|
2018-08-18 21:06:36 +02:00
|
|
|
_exitAction = new QAction(QIcon(QUIT_ICON), tr("Quit"), this);
|
2016-04-11 22:08:00 +02:00
|
|
|
_exitAction->setShortcut(QUIT_SHORTCUT);
|
2017-05-31 23:37:02 +02:00
|
|
|
_exitAction->setMenuRole(QAction::QuitRole);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_exitAction, &QAction::triggered, this, &GUI::close);
|
2016-04-05 09:10:19 +02:00
|
|
|
addAction(_exitAction);
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2015-10-21 01:09:17 +02:00
|
|
|
// Help & About
|
2018-01-31 08:14:25 +01:00
|
|
|
_pathsAction = new QAction(tr("Paths"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_pathsAction->setMenuRole(QAction::NoRole);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_pathsAction, &QAction::triggered, this, &GUI::paths);
|
2015-10-21 01:09:17 +02:00
|
|
|
_keysAction = new QAction(tr("Keyboard controls"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_keysAction->setMenuRole(QAction::NoRole);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_keysAction, &QAction::triggered, this, &GUI::keys);
|
2018-08-18 21:06:36 +02:00
|
|
|
_aboutAction = new QAction(QIcon(APP_ICON), tr("About GPXSee"), this);
|
2017-05-31 23:37:02 +02:00
|
|
|
_aboutAction->setMenuRole(QAction::AboutRole);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_aboutAction, &QAction::triggered, this, &GUI::about);
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2016-08-09 01:16:19 +02:00
|
|
|
// File actions
|
2018-08-18 21:06:36 +02:00
|
|
|
_openFileAction = new QAction(QIcon(OPEN_FILE_ICON), tr("Open..."), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_openFileAction->setMenuRole(QAction::NoRole);
|
2016-04-11 22:08:00 +02:00
|
|
|
_openFileAction->setShortcut(OPEN_SHORTCUT);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_openFileAction, &QAction::triggered, this,
|
|
|
|
QOverload<>::of(&GUI::openFile));
|
2016-04-05 09:10:19 +02:00
|
|
|
addAction(_openFileAction);
|
2018-08-18 21:06:36 +02:00
|
|
|
_printFileAction = new QAction(QIcon(PRINT_FILE_ICON), tr("Print..."),
|
|
|
|
this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_printFileAction->setMenuRole(QAction::NoRole);
|
2016-05-15 22:38:15 +02:00
|
|
|
_printFileAction->setActionGroup(_fileActionGroup);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_printFileAction, &QAction::triggered, this, &GUI::printFile);
|
2016-05-15 22:38:15 +02:00
|
|
|
addAction(_printFileAction);
|
2020-09-27 00:34:38 +02:00
|
|
|
_exportPDFFileAction = new QAction(QIcon(EXPORT_FILE_ICON),
|
2016-05-27 22:45:58 +02:00
|
|
|
tr("Export to PDF..."), this);
|
2020-09-27 00:34:38 +02:00
|
|
|
_exportPDFFileAction->setMenuRole(QAction::NoRole);
|
2020-10-07 22:57:30 +02:00
|
|
|
_exportPDFFileAction->setShortcut(PDF_EXPORT_SHORTCUT);
|
2020-09-27 00:34:38 +02:00
|
|
|
_exportPDFFileAction->setActionGroup(_fileActionGroup);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_exportPDFFileAction, &QAction::triggered, this, &GUI::exportPDFFile);
|
2020-09-27 00:34:38 +02:00
|
|
|
addAction(_exportPDFFileAction);
|
|
|
|
_exportPNGFileAction = new QAction(QIcon(EXPORT_FILE_ICON),
|
|
|
|
tr("Export to PNG..."), this);
|
|
|
|
_exportPNGFileAction->setMenuRole(QAction::NoRole);
|
2020-10-07 22:57:30 +02:00
|
|
|
_exportPNGFileAction->setShortcut(PNG_EXPORT_SHORTCUT);
|
2020-09-27 00:34:38 +02:00
|
|
|
_exportPNGFileAction->setActionGroup(_fileActionGroup);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_exportPNGFileAction, &QAction::triggered, this, &GUI::exportPNGFile);
|
2020-09-27 00:34:38 +02:00
|
|
|
addAction(_exportPNGFileAction);
|
2018-08-18 21:06:36 +02:00
|
|
|
_closeFileAction = new QAction(QIcon(CLOSE_FILE_ICON), tr("Close"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_closeFileAction->setMenuRole(QAction::NoRole);
|
2016-04-11 22:08:00 +02:00
|
|
|
_closeFileAction->setShortcut(CLOSE_SHORTCUT);
|
2015-10-05 01:43:48 +02:00
|
|
|
_closeFileAction->setActionGroup(_fileActionGroup);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_closeFileAction, &QAction::triggered, this, &GUI::closeAll);
|
2016-04-05 09:10:19 +02:00
|
|
|
addAction(_closeFileAction);
|
2018-08-18 21:06:36 +02:00
|
|
|
_reloadFileAction = new QAction(QIcon(RELOAD_FILE_ICON), tr("Reload"),
|
|
|
|
this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_reloadFileAction->setMenuRole(QAction::NoRole);
|
2016-04-11 22:08:00 +02:00
|
|
|
_reloadFileAction->setShortcut(RELOAD_SHORTCUT);
|
2015-10-20 22:18:41 +02:00
|
|
|
_reloadFileAction->setActionGroup(_fileActionGroup);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_reloadFileAction, &QAction::triggered, this, &GUI::reloadFiles);
|
2016-04-05 09:10:19 +02:00
|
|
|
addAction(_reloadFileAction);
|
2018-07-21 16:13:18 +02:00
|
|
|
_statisticsAction = new QAction(tr("Statistics..."), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_statisticsAction->setMenuRole(QAction::NoRole);
|
2018-07-21 16:13:18 +02:00
|
|
|
_statisticsAction->setShortcut(STATISTICS_SHORTCUT);
|
|
|
|
_statisticsAction->setActionGroup(_fileActionGroup);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_statisticsAction, &QAction::triggered, this, &GUI::statistics);
|
2018-07-21 23:25:24 +02:00
|
|
|
addAction(_statisticsAction);
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
// POI actions
|
2021-03-21 22:40:39 +01:00
|
|
|
poiActions = createPOIActions();
|
2018-08-18 21:06:36 +02:00
|
|
|
_openPOIAction = new QAction(QIcon(OPEN_FILE_ICON), tr("Load POI file..."),
|
|
|
|
this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_openPOIAction->setMenuRole(QAction::NoRole);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_openPOIAction, &QAction::triggered, this,
|
|
|
|
QOverload<>::of(&GUI::openPOIFile));
|
2021-03-21 22:40:39 +01:00
|
|
|
_selectAllPOIAction = new QAction(tr("Select all files"), this);
|
|
|
|
_selectAllPOIAction->setMenuRole(QAction::NoRole);
|
|
|
|
_selectAllPOIAction->setEnabled(!_poisActionGroup->actions().isEmpty());
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_selectAllPOIAction, &QAction::triggered, this,
|
|
|
|
&GUI::selectAllPOIs);
|
2021-03-21 22:40:39 +01:00
|
|
|
_unselectAllPOIAction = new QAction(tr("Unselect all files"), this);
|
|
|
|
_unselectAllPOIAction->setMenuRole(QAction::NoRole);
|
|
|
|
_unselectAllPOIAction->setEnabled(_selectAllPOIAction->isEnabled());
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_unselectAllPOIAction, &QAction::triggered, this,
|
|
|
|
&GUI::unselectAllPOIs);
|
2016-08-02 20:46:22 +02:00
|
|
|
_overlapPOIAction = new QAction(tr("Overlap POIs"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_overlapPOIAction->setMenuRole(QAction::NoRole);
|
2016-08-02 20:46:22 +02:00
|
|
|
_overlapPOIAction->setCheckable(true);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_overlapPOIAction, &QAction::triggered, _mapView,
|
|
|
|
&MapView::showOverlappedPOIs);
|
2016-08-09 01:16:19 +02:00
|
|
|
_showPOILabelsAction = new QAction(tr("Show POI labels"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_showPOILabelsAction->setMenuRole(QAction::NoRole);
|
2016-08-09 01:16:19 +02:00
|
|
|
_showPOILabelsAction->setCheckable(true);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_showPOILabelsAction, &QAction::triggered, _mapView,
|
|
|
|
&MapView::showPOILabels);
|
2018-08-18 21:06:36 +02:00
|
|
|
_showPOIAction = new QAction(QIcon(SHOW_POI_ICON), tr("Show POIs"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_showPOIAction->setMenuRole(QAction::NoRole);
|
2015-10-05 01:43:48 +02:00
|
|
|
_showPOIAction->setCheckable(true);
|
2016-04-11 22:08:00 +02:00
|
|
|
_showPOIAction->setShortcut(SHOW_POI_SHORTCUT);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_showPOIAction, &QAction::triggered, _mapView, &MapView::showPOI);
|
2016-04-05 09:10:19 +02:00
|
|
|
addAction(_showPOIAction);
|
2015-11-23 02:37:08 +01:00
|
|
|
|
|
|
|
// Map actions
|
2021-03-20 09:59:03 +01:00
|
|
|
mapActions = createMapActions();
|
2018-08-18 21:06:36 +02:00
|
|
|
_showMapAction = new QAction(QIcon(SHOW_MAP_ICON), tr("Show map"),
|
2015-11-23 02:37:08 +01:00
|
|
|
this);
|
2020-03-17 21:06:51 +01:00
|
|
|
_showMapAction->setEnabled(false);
|
2018-07-21 23:25:24 +02:00
|
|
|
_showMapAction->setMenuRole(QAction::NoRole);
|
2015-11-23 02:37:08 +01:00
|
|
|
_showMapAction->setCheckable(true);
|
2016-04-11 22:08:00 +02:00
|
|
|
_showMapAction->setShortcut(SHOW_MAP_SHORTCUT);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_showMapAction, &QAction::triggered, _mapView,
|
|
|
|
&MapView::showMap);
|
2016-04-05 09:10:19 +02:00
|
|
|
addAction(_showMapAction);
|
2018-08-18 21:06:36 +02:00
|
|
|
_loadMapAction = new QAction(QIcon(OPEN_FILE_ICON), tr("Load map..."),
|
|
|
|
this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_loadMapAction->setMenuRole(QAction::NoRole);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_loadMapAction, &QAction::triggered, this,
|
|
|
|
QOverload<>::of(&GUI::loadMap));
|
2020-12-02 23:58:11 +01:00
|
|
|
_loadMapDirAction = new QAction(QIcon(OPEN_FILE_ICON),
|
|
|
|
tr("Load map directory..."), this);
|
|
|
|
_loadMapDirAction->setMenuRole(QAction::NoRole);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_loadMapDirAction, &QAction::triggered, this, &GUI::loadMapDir);
|
2016-04-01 19:25:34 +02:00
|
|
|
_clearMapCacheAction = new QAction(tr("Clear tile cache"), this);
|
2020-03-17 21:06:51 +01:00
|
|
|
_clearMapCacheAction->setEnabled(false);
|
2018-07-21 23:25:24 +02:00
|
|
|
_clearMapCacheAction->setMenuRole(QAction::NoRole);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_clearMapCacheAction, &QAction::triggered, this,
|
|
|
|
&GUI::clearMapCache);
|
2017-04-21 21:15:58 +02:00
|
|
|
_nextMapAction = new QAction(tr("Next map"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_nextMapAction->setMenuRole(QAction::NoRole);
|
2017-04-21 21:15:58 +02:00
|
|
|
_nextMapAction->setShortcut(NEXT_MAP_SHORTCUT);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_nextMapAction, &QAction::triggered, this, &GUI::nextMap);
|
2017-04-21 21:15:58 +02:00
|
|
|
addAction(_nextMapAction);
|
|
|
|
_prevMapAction = new QAction(tr("Next map"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_prevMapAction->setMenuRole(QAction::NoRole);
|
2017-04-21 21:15:58 +02:00
|
|
|
_prevMapAction->setShortcut(PREV_MAP_SHORTCUT);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_prevMapAction, &QAction::triggered, this, &GUI::prevMap);
|
2017-04-21 21:15:58 +02:00
|
|
|
addAction(_prevMapAction);
|
2019-02-17 20:20:20 +01:00
|
|
|
_showCoordinatesAction = new QAction(tr("Show cursor coordinates"), this);
|
|
|
|
_showCoordinatesAction->setMenuRole(QAction::NoRole);
|
|
|
|
_showCoordinatesAction->setCheckable(true);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_showCoordinatesAction, &QAction::triggered, _mapView,
|
|
|
|
&MapView::showCoordinates);
|
2015-11-24 00:24:26 +01:00
|
|
|
|
2016-08-09 01:16:19 +02:00
|
|
|
// Data actions
|
2016-08-16 00:27:54 +02:00
|
|
|
_showTracksAction = new QAction(tr("Show tracks"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_showTracksAction->setMenuRole(QAction::NoRole);
|
2016-08-09 01:16:19 +02:00
|
|
|
_showTracksAction->setCheckable(true);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_showTracksAction, &QAction::triggered, this, &GUI::showTracks);
|
2016-08-16 00:27:54 +02:00
|
|
|
_showRoutesAction = new QAction(tr("Show routes"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_showRoutesAction->setMenuRole(QAction::NoRole);
|
2016-08-09 01:16:19 +02:00
|
|
|
_showRoutesAction->setCheckable(true);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_showRoutesAction, &QAction::triggered, this, &GUI::showRoutes);
|
2016-08-16 00:27:54 +02:00
|
|
|
_showWaypointsAction = new QAction(tr("Show waypoints"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_showWaypointsAction->setMenuRole(QAction::NoRole);
|
2016-08-09 01:16:19 +02:00
|
|
|
_showWaypointsAction->setCheckable(true);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_showWaypointsAction, &QAction::triggered, _mapView,
|
|
|
|
&MapView::showWaypoints);
|
2019-01-31 01:46:53 +01:00
|
|
|
_showAreasAction = new QAction(tr("Show areas"), this);
|
|
|
|
_showAreasAction->setMenuRole(QAction::NoRole);
|
|
|
|
_showAreasAction->setCheckable(true);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_showAreasAction, &QAction::triggered, _mapView,
|
|
|
|
&MapView::showAreas);
|
2016-08-09 10:47:49 +02:00
|
|
|
_showWaypointLabelsAction = new QAction(tr("Waypoint labels"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_showWaypointLabelsAction->setMenuRole(QAction::NoRole);
|
2016-08-09 01:16:19 +02:00
|
|
|
_showWaypointLabelsAction->setCheckable(true);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_showWaypointLabelsAction, &QAction::triggered, _mapView,
|
|
|
|
&MapView::showWaypointLabels);
|
2016-08-16 00:27:54 +02:00
|
|
|
_showRouteWaypointsAction = new QAction(tr("Route waypoints"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_showRouteWaypointsAction->setMenuRole(QAction::NoRole);
|
2016-08-09 10:47:49 +02:00
|
|
|
_showRouteWaypointsAction->setCheckable(true);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_showRouteWaypointsAction, &QAction::triggered, _mapView,
|
|
|
|
&MapView::showRouteWaypoints);
|
2019-05-23 08:44:55 +02:00
|
|
|
_showTicksAction = new QAction(tr("km/mi markers"), this);
|
|
|
|
_showTicksAction->setMenuRole(QAction::NoRole);
|
|
|
|
_showTicksAction->setCheckable(true);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_showTicksAction, &QAction::triggered, _mapView,
|
|
|
|
&MapView::showTicks);
|
2021-02-12 22:41:38 +01:00
|
|
|
QActionGroup *markerInfoGroup = new QActionGroup(this);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(markerInfoGroup, &QActionGroup::triggered, this,
|
|
|
|
&GUI::showPathMarkerInfo);
|
2021-02-12 22:41:38 +01:00
|
|
|
_hideMarkersAction = new QAction(tr("Do not show"), this);
|
|
|
|
_hideMarkersAction->setMenuRole(QAction::NoRole);
|
|
|
|
_hideMarkersAction->setCheckable(true);
|
|
|
|
_hideMarkersAction->setActionGroup(markerInfoGroup);
|
|
|
|
_showMarkersAction = new QAction(tr("Marker only"), this);
|
2021-01-17 16:02:37 +01:00
|
|
|
_showMarkersAction->setMenuRole(QAction::NoRole);
|
|
|
|
_showMarkersAction->setCheckable(true);
|
2021-02-12 22:41:38 +01:00
|
|
|
_showMarkersAction->setActionGroup(markerInfoGroup);
|
|
|
|
_showMarkerDateAction = new QAction(tr("Date/time"), this);
|
|
|
|
_showMarkerDateAction->setMenuRole(QAction::NoRole);
|
|
|
|
_showMarkerDateAction->setCheckable(true);
|
|
|
|
_showMarkerDateAction->setActionGroup(markerInfoGroup);
|
|
|
|
_showMarkerCoordinatesAction = new QAction(tr("Coordinates"), this);
|
|
|
|
_showMarkerCoordinatesAction->setMenuRole(QAction::NoRole);
|
|
|
|
_showMarkerCoordinatesAction->setCheckable(true);
|
|
|
|
_showMarkerCoordinatesAction->setActionGroup(markerInfoGroup);
|
2016-08-09 01:16:19 +02:00
|
|
|
|
2016-09-19 00:56:10 +02:00
|
|
|
// Graph actions
|
2018-08-18 21:06:36 +02:00
|
|
|
_showGraphsAction = new QAction(QIcon(SHOW_GRAPHS_ICON), tr("Show graphs"),
|
|
|
|
this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_showGraphsAction->setMenuRole(QAction::NoRole);
|
2015-11-24 00:24:26 +01:00
|
|
|
_showGraphsAction->setCheckable(true);
|
2016-04-11 22:08:00 +02:00
|
|
|
_showGraphsAction->setShortcut(SHOW_GRAPHS_SHORTCUT);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_showGraphsAction, &QAction::triggered, this, &GUI::showGraphs);
|
2016-04-05 09:10:19 +02:00
|
|
|
addAction(_showGraphsAction);
|
2016-09-19 00:56:10 +02:00
|
|
|
ag = new QActionGroup(this);
|
|
|
|
ag->setExclusive(true);
|
|
|
|
_distanceGraphAction = new QAction(tr("Distance"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_distanceGraphAction->setMenuRole(QAction::NoRole);
|
2016-09-19 00:56:10 +02:00
|
|
|
_distanceGraphAction->setCheckable(true);
|
|
|
|
_distanceGraphAction->setActionGroup(ag);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_distanceGraphAction, &QAction::triggered, this,
|
|
|
|
&GUI::setDistanceGraph);
|
2016-10-17 23:14:07 +02:00
|
|
|
addAction(_distanceGraphAction);
|
2016-09-19 00:56:10 +02:00
|
|
|
_timeGraphAction = new QAction(tr("Time"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_timeGraphAction->setMenuRole(QAction::NoRole);
|
2016-09-19 00:56:10 +02:00
|
|
|
_timeGraphAction->setCheckable(true);
|
|
|
|
_timeGraphAction->setActionGroup(ag);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_timeGraphAction, &QAction::triggered, this, &GUI::setTimeGraph);
|
2016-10-17 23:14:07 +02:00
|
|
|
addAction(_timeGraphAction);
|
|
|
|
_showGraphGridAction = new QAction(tr("Show grid"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_showGraphGridAction->setMenuRole(QAction::NoRole);
|
2016-10-17 23:14:07 +02:00
|
|
|
_showGraphGridAction->setCheckable(true);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_showGraphGridAction, &QAction::triggered, this,
|
|
|
|
&GUI::showGraphGrids);
|
2017-09-29 11:43:09 +02:00
|
|
|
_showGraphSliderInfoAction = new QAction(tr("Show slider info"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_showGraphSliderInfoAction->setMenuRole(QAction::NoRole);
|
2017-09-29 11:43:09 +02:00
|
|
|
_showGraphSliderInfoAction->setCheckable(true);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_showGraphSliderInfoAction, &QAction::triggered, this,
|
|
|
|
&GUI::showGraphSliderInfo);
|
2016-09-19 00:56:10 +02:00
|
|
|
|
|
|
|
// Settings actions
|
2015-11-24 00:24:26 +01:00
|
|
|
_showToolbarsAction = new QAction(tr("Show toolbars"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_showToolbarsAction->setMenuRole(QAction::NoRole);
|
2015-11-24 00:24:26 +01:00
|
|
|
_showToolbarsAction->setCheckable(true);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_showToolbarsAction, &QAction::triggered, this, &GUI::showToolbars);
|
2016-09-19 00:56:10 +02:00
|
|
|
ag = new QActionGroup(this);
|
2015-12-19 20:23:07 +01:00
|
|
|
ag->setExclusive(true);
|
2017-02-12 19:57:55 +01:00
|
|
|
_totalTimeAction = new QAction(tr("Total time"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_totalTimeAction->setMenuRole(QAction::NoRole);
|
2017-02-12 19:57:55 +01:00
|
|
|
_totalTimeAction->setCheckable(true);
|
|
|
|
_totalTimeAction->setActionGroup(ag);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_totalTimeAction, &QAction::triggered, this, &GUI::setTotalTime);
|
2017-02-12 19:57:55 +01:00
|
|
|
_movingTimeAction = new QAction(tr("Moving time"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_movingTimeAction->setMenuRole(QAction::NoRole);
|
2017-02-12 19:57:55 +01:00
|
|
|
_movingTimeAction->setCheckable(true);
|
|
|
|
_movingTimeAction->setActionGroup(ag);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_movingTimeAction, &QAction::triggered, this, &GUI::setMovingTime);
|
2017-02-12 19:57:55 +01:00
|
|
|
ag = new QActionGroup(this);
|
|
|
|
ag->setExclusive(true);
|
2015-12-19 20:23:07 +01:00
|
|
|
_metricUnitsAction = new QAction(tr("Metric"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_metricUnitsAction->setMenuRole(QAction::NoRole);
|
2015-12-19 20:23:07 +01:00
|
|
|
_metricUnitsAction->setCheckable(true);
|
|
|
|
_metricUnitsAction->setActionGroup(ag);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_metricUnitsAction, &QAction::triggered, this, &GUI::setMetricUnits);
|
2015-12-19 20:23:07 +01:00
|
|
|
_imperialUnitsAction = new QAction(tr("Imperial"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_imperialUnitsAction->setMenuRole(QAction::NoRole);
|
2015-12-19 20:23:07 +01:00
|
|
|
_imperialUnitsAction->setCheckable(true);
|
|
|
|
_imperialUnitsAction->setActionGroup(ag);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_imperialUnitsAction, &QAction::triggered, this,
|
|
|
|
&GUI::setImperialUnits);
|
2018-02-11 23:51:57 +01:00
|
|
|
_nauticalUnitsAction = new QAction(tr("Nautical"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_nauticalUnitsAction->setMenuRole(QAction::NoRole);
|
2018-02-11 23:51:57 +01:00
|
|
|
_nauticalUnitsAction->setCheckable(true);
|
|
|
|
_nauticalUnitsAction->setActionGroup(ag);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_nauticalUnitsAction, &QAction::triggered, this,
|
|
|
|
&GUI::setNauticalUnits);
|
2018-02-11 20:39:39 +01:00
|
|
|
ag = new QActionGroup(this);
|
|
|
|
ag->setExclusive(true);
|
|
|
|
_decimalDegreesAction = new QAction(tr("Decimal degrees (DD)"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_decimalDegreesAction->setMenuRole(QAction::NoRole);
|
2018-02-11 20:39:39 +01:00
|
|
|
_decimalDegreesAction->setCheckable(true);
|
|
|
|
_decimalDegreesAction->setActionGroup(ag);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_decimalDegreesAction, &QAction::triggered, this,
|
|
|
|
&GUI::setDecimalDegrees);
|
2018-02-11 20:39:39 +01:00
|
|
|
_degreesMinutesAction = new QAction(tr("Degrees and decimal minutes (DMM)"),
|
|
|
|
this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_degreesMinutesAction->setMenuRole(QAction::NoRole);
|
2018-02-11 20:39:39 +01:00
|
|
|
_degreesMinutesAction->setCheckable(true);
|
|
|
|
_degreesMinutesAction->setActionGroup(ag);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_degreesMinutesAction, &QAction::triggered, this,
|
|
|
|
&GUI::setDegreesMinutes);
|
2020-01-23 23:19:32 +01:00
|
|
|
_dmsAction = new QAction(tr("Degrees, minutes, seconds (DMS)"), this);
|
|
|
|
_dmsAction->setMenuRole(QAction::NoRole);
|
|
|
|
_dmsAction->setCheckable(true);
|
|
|
|
_dmsAction->setActionGroup(ag);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_dmsAction, &QAction::triggered, this, &GUI::setDMS);
|
2018-08-18 21:06:36 +02:00
|
|
|
_fullscreenAction = new QAction(QIcon(FULLSCREEN_ICON),
|
2016-04-05 09:10:19 +02:00
|
|
|
tr("Fullscreen mode"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_fullscreenAction->setMenuRole(QAction::NoRole);
|
2016-04-05 09:10:19 +02:00
|
|
|
_fullscreenAction->setCheckable(true);
|
2016-04-11 22:08:00 +02:00
|
|
|
_fullscreenAction->setShortcut(FULLSCREEN_SHORTCUT);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_fullscreenAction, &QAction::triggered, this, &GUI::showFullscreen);
|
2016-04-05 09:10:19 +02:00
|
|
|
addAction(_fullscreenAction);
|
2016-12-06 01:48:26 +01:00
|
|
|
_openOptionsAction = new QAction(tr("Options..."), this);
|
2017-05-31 23:37:02 +02:00
|
|
|
_openOptionsAction->setMenuRole(QAction::PreferencesRole);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_openOptionsAction, &QAction::triggered, this, &GUI::openOptions);
|
2015-12-18 22:21:11 +01:00
|
|
|
|
|
|
|
// Navigation actions
|
2018-08-18 21:06:36 +02:00
|
|
|
_nextAction = new QAction(QIcon(NEXT_FILE_ICON), tr("Next"), this);
|
2015-12-18 22:21:11 +01:00
|
|
|
_nextAction->setActionGroup(_navigationActionGroup);
|
2018-07-21 23:25:24 +02:00
|
|
|
_nextAction->setMenuRole(QAction::NoRole);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_nextAction, &QAction::triggered, this, &GUI::next);
|
2018-08-18 21:06:36 +02:00
|
|
|
_prevAction = new QAction(QIcon(PREV_FILE_ICON), tr("Previous"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_prevAction->setMenuRole(QAction::NoRole);
|
2015-12-18 22:21:11 +01:00
|
|
|
_prevAction->setActionGroup(_navigationActionGroup);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_prevAction, &QAction::triggered, this, &GUI::prev);
|
2018-08-18 21:06:36 +02:00
|
|
|
_lastAction = new QAction(QIcon(LAST_FILE_ICON), tr("Last"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_lastAction->setMenuRole(QAction::NoRole);
|
2015-12-18 22:21:11 +01:00
|
|
|
_lastAction->setActionGroup(_navigationActionGroup);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_lastAction, &QAction::triggered, this, &GUI::last);
|
2018-08-18 21:06:36 +02:00
|
|
|
_firstAction = new QAction(QIcon(FIRST_FILE_ICON), tr("First"), this);
|
2018-07-21 23:25:24 +02:00
|
|
|
_firstAction->setMenuRole(QAction::NoRole);
|
2015-12-18 22:21:11 +01:00
|
|
|
_firstAction->setActionGroup(_navigationActionGroup);
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_firstAction, &QAction::triggered, this, &GUI::first);
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2021-03-20 09:59:03 +01:00
|
|
|
void GUI::createMapNodeMenu(const TreeNode<MapAction*> &node, QMenu *menu)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < node.childs().size(); i++) {
|
|
|
|
QMenu *cm = new QMenu(node.childs().at(i).name(), menu);
|
|
|
|
menu->addMenu(cm);
|
|
|
|
createMapNodeMenu(node.childs().at(i), cm);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < node.items().size(); i++)
|
|
|
|
menu->addAction(node.items().at(i));
|
|
|
|
}
|
|
|
|
|
2021-03-21 20:23:20 +01:00
|
|
|
void GUI::createPOINodeMenu(const TreeNode<POIAction*> &node, QMenu *menu)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < node.childs().size(); i++) {
|
|
|
|
QMenu *cm = new QMenu(node.childs().at(i).name(), menu);
|
|
|
|
menu->addMenu(cm);
|
|
|
|
createPOINodeMenu(node.childs().at(i), cm);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < node.items().size(); i++)
|
|
|
|
menu->addAction(node.items().at(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::createMenus(const TreeNode<MapAction*> &mapActions,
|
|
|
|
const TreeNode<POIAction*> &poiActions)
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2018-02-22 08:18:10 +01:00
|
|
|
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
|
2016-08-09 01:16:19 +02:00
|
|
|
fileMenu->addAction(_openFileAction);
|
|
|
|
fileMenu->addSeparator();
|
|
|
|
fileMenu->addAction(_printFileAction);
|
2020-09-27 00:34:38 +02:00
|
|
|
fileMenu->addAction(_exportPDFFileAction);
|
|
|
|
fileMenu->addAction(_exportPNGFileAction);
|
2016-08-09 01:16:19 +02:00
|
|
|
fileMenu->addSeparator();
|
2018-07-21 16:13:18 +02:00
|
|
|
fileMenu->addAction(_statisticsAction);
|
2016-08-09 01:16:19 +02:00
|
|
|
fileMenu->addSeparator();
|
2018-07-21 16:13:18 +02:00
|
|
|
fileMenu->addAction(_reloadFileAction);
|
2016-08-09 01:16:19 +02:00
|
|
|
fileMenu->addAction(_closeFileAction);
|
2015-12-01 23:13:20 +01:00
|
|
|
#ifndef Q_OS_MAC
|
2016-08-09 01:16:19 +02:00
|
|
|
fileMenu->addSeparator();
|
|
|
|
fileMenu->addAction(_exitAction);
|
2015-12-01 23:13:20 +01:00
|
|
|
#endif // Q_OS_MAC
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2018-02-22 08:18:10 +01:00
|
|
|
_mapMenu = menuBar()->addMenu(tr("&Map"));
|
2021-03-20 09:59:03 +01:00
|
|
|
createMapNodeMenu(mapActions, _mapMenu);
|
2017-04-21 21:15:58 +02:00
|
|
|
_mapsEnd = _mapMenu->addSeparator();
|
|
|
|
_mapMenu->addAction(_loadMapAction);
|
2020-12-02 23:58:11 +01:00
|
|
|
_mapMenu->addAction(_loadMapDirAction);
|
2017-04-21 21:15:58 +02:00
|
|
|
_mapMenu->addAction(_clearMapCacheAction);
|
|
|
|
_mapMenu->addSeparator();
|
2019-02-17 20:20:20 +01:00
|
|
|
_mapMenu->addAction(_showCoordinatesAction);
|
|
|
|
_mapMenu->addSeparator();
|
2017-04-21 21:15:58 +02:00
|
|
|
_mapMenu->addAction(_showMapAction);
|
2015-11-23 02:37:08 +01:00
|
|
|
|
2018-02-22 08:18:10 +01:00
|
|
|
QMenu *graphMenu = menuBar()->addMenu(tr("&Graph"));
|
2016-09-19 00:56:10 +02:00
|
|
|
graphMenu->addAction(_distanceGraphAction);
|
|
|
|
graphMenu->addAction(_timeGraphAction);
|
|
|
|
graphMenu->addSeparator();
|
2016-10-17 23:14:07 +02:00
|
|
|
graphMenu->addAction(_showGraphGridAction);
|
2017-09-29 11:43:09 +02:00
|
|
|
graphMenu->addAction(_showGraphSliderInfoAction);
|
2016-10-17 23:14:07 +02:00
|
|
|
graphMenu->addSeparator();
|
2016-09-19 00:56:10 +02:00
|
|
|
graphMenu->addAction(_showGraphsAction);
|
|
|
|
|
2021-03-21 20:23:20 +01:00
|
|
|
_poiMenu = menuBar()->addMenu(tr("&POI"));
|
|
|
|
createPOINodeMenu(poiActions, _poiMenu);
|
|
|
|
_poisEnd = _poiMenu->addSeparator();
|
|
|
|
_poiMenu->addAction(_openPOIAction);
|
2021-03-21 22:40:39 +01:00
|
|
|
_poiMenu->addAction(_selectAllPOIAction);
|
|
|
|
_poiMenu->addAction(_unselectAllPOIAction);
|
2021-03-21 20:23:20 +01:00
|
|
|
_poiMenu->addSeparator();
|
|
|
|
_poiMenu->addAction(_showPOILabelsAction);
|
|
|
|
_poiMenu->addAction(_overlapPOIAction);
|
|
|
|
_poiMenu->addSeparator();
|
|
|
|
_poiMenu->addAction(_showPOIAction);
|
2016-08-09 01:16:19 +02:00
|
|
|
|
2018-02-22 08:18:10 +01:00
|
|
|
QMenu *dataMenu = menuBar()->addMenu(tr("&Data"));
|
2021-02-12 22:41:38 +01:00
|
|
|
dataMenu->addAction(_showWaypointLabelsAction);
|
|
|
|
dataMenu->addAction(_showRouteWaypointsAction);
|
|
|
|
dataMenu->addAction(_showTicksAction);
|
|
|
|
QMenu *markerMenu = dataMenu->addMenu(tr("Position info"));
|
|
|
|
markerMenu->addAction(_hideMarkersAction);
|
|
|
|
markerMenu->addAction(_showMarkersAction);
|
|
|
|
markerMenu->addAction(_showMarkerDateAction);
|
|
|
|
markerMenu->addAction(_showMarkerCoordinatesAction);
|
2016-08-09 10:47:49 +02:00
|
|
|
dataMenu->addSeparator();
|
2016-08-09 01:16:19 +02:00
|
|
|
dataMenu->addAction(_showTracksAction);
|
|
|
|
dataMenu->addAction(_showRoutesAction);
|
2019-01-31 01:46:53 +01:00
|
|
|
dataMenu->addAction(_showAreasAction);
|
2016-08-09 01:16:19 +02:00
|
|
|
dataMenu->addAction(_showWaypointsAction);
|
|
|
|
|
2018-02-22 08:18:10 +01:00
|
|
|
QMenu *settingsMenu = menuBar()->addMenu(tr("&Settings"));
|
2017-02-12 19:57:55 +01:00
|
|
|
QMenu *timeMenu = settingsMenu->addMenu(tr("Time"));
|
|
|
|
timeMenu->addAction(_totalTimeAction);
|
|
|
|
timeMenu->addAction(_movingTimeAction);
|
2016-08-09 01:16:19 +02:00
|
|
|
QMenu *unitsMenu = settingsMenu->addMenu(tr("Units"));
|
|
|
|
unitsMenu->addAction(_metricUnitsAction);
|
|
|
|
unitsMenu->addAction(_imperialUnitsAction);
|
2018-02-11 23:51:57 +01:00
|
|
|
unitsMenu->addAction(_nauticalUnitsAction);
|
2018-02-11 20:39:39 +01:00
|
|
|
QMenu *coordinatesMenu = settingsMenu->addMenu(tr("Coordinates format"));
|
|
|
|
coordinatesMenu->addAction(_decimalDegreesAction);
|
|
|
|
coordinatesMenu->addAction(_degreesMinutesAction);
|
2020-01-23 23:19:32 +01:00
|
|
|
coordinatesMenu->addAction(_dmsAction);
|
2016-08-09 01:16:19 +02:00
|
|
|
settingsMenu->addSeparator();
|
|
|
|
settingsMenu->addAction(_showToolbarsAction);
|
|
|
|
settingsMenu->addAction(_fullscreenAction);
|
2016-12-06 01:48:26 +01:00
|
|
|
settingsMenu->addSeparator();
|
|
|
|
settingsMenu->addAction(_openOptionsAction);
|
2016-08-09 01:16:19 +02:00
|
|
|
|
2018-02-22 08:18:10 +01:00
|
|
|
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
|
2018-01-31 08:14:25 +01:00
|
|
|
helpMenu->addAction(_pathsAction);
|
2016-08-09 01:16:19 +02:00
|
|
|
helpMenu->addAction(_keysAction);
|
|
|
|
helpMenu->addSeparator();
|
|
|
|
helpMenu->addAction(_aboutAction);
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::createToolBars()
|
|
|
|
{
|
2018-08-18 21:06:36 +02:00
|
|
|
int is = style()->pixelMetric(QStyle::PM_ToolBarIconSize);
|
|
|
|
QSize iconSize(qMin(is, TOOLBAR_ICON_SIZE), qMin(is, TOOLBAR_ICON_SIZE));
|
|
|
|
|
2016-05-14 09:28:56 +02:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
|
|
#endif // Q_OS_MAC
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
_fileToolBar = addToolBar(tr("File"));
|
2019-02-18 22:33:18 +01:00
|
|
|
_fileToolBar->setObjectName("File");
|
2018-08-18 21:06:36 +02:00
|
|
|
_fileToolBar->setIconSize(iconSize);
|
2015-10-05 01:43:48 +02:00
|
|
|
_fileToolBar->addAction(_openFileAction);
|
2015-10-20 22:18:41 +02:00
|
|
|
_fileToolBar->addAction(_reloadFileAction);
|
2015-10-05 01:43:48 +02:00
|
|
|
_fileToolBar->addAction(_closeFileAction);
|
2016-05-15 22:38:15 +02:00
|
|
|
_fileToolBar->addAction(_printFileAction);
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2015-11-23 02:37:08 +01:00
|
|
|
_showToolBar = addToolBar(tr("Show"));
|
2019-02-18 22:33:18 +01:00
|
|
|
_showToolBar->setObjectName("Show");
|
2018-08-18 21:06:36 +02:00
|
|
|
_showToolBar->setIconSize(iconSize);
|
2015-11-23 02:37:08 +01:00
|
|
|
_showToolBar->addAction(_showPOIAction);
|
|
|
|
_showToolBar->addAction(_showMapAction);
|
2016-09-19 00:56:10 +02:00
|
|
|
_showToolBar->addAction(_showGraphsAction);
|
2015-12-18 22:21:11 +01:00
|
|
|
|
|
|
|
_navigationToolBar = addToolBar(tr("Navigation"));
|
2019-02-18 22:33:18 +01:00
|
|
|
_navigationToolBar->setObjectName("Navigation");
|
2018-08-18 21:06:36 +02:00
|
|
|
_navigationToolBar->setIconSize(iconSize);
|
2015-12-18 22:21:11 +01:00
|
|
|
_navigationToolBar->addAction(_firstAction);
|
|
|
|
_navigationToolBar->addAction(_prevAction);
|
|
|
|
_navigationToolBar->addAction(_nextAction);
|
|
|
|
_navigationToolBar->addAction(_lastAction);
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2017-12-01 00:22:16 +01:00
|
|
|
void GUI::createMapView()
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2020-03-17 21:06:51 +01:00
|
|
|
_map = new EmptyMap(this);
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView = new MapView(_map, _poi, this);
|
|
|
|
_mapView->setSizePolicy(QSizePolicy(QSizePolicy::Ignored,
|
2016-10-19 23:38:28 +02:00
|
|
|
QSizePolicy::Expanding));
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->setMinimumHeight(200);
|
2016-04-12 23:15:17 +02:00
|
|
|
#ifdef Q_OS_WIN32
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->setFrameShape(QFrame::NoFrame);
|
2016-04-12 23:15:17 +02:00
|
|
|
#endif // Q_OS_WIN32
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2016-09-27 01:27:38 +02:00
|
|
|
void GUI::createGraphTabs()
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2016-10-19 23:38:28 +02:00
|
|
|
_graphTabWidget = new QTabWidget();
|
|
|
|
_graphTabWidget->setSizePolicy(QSizePolicy(QSizePolicy::Ignored,
|
|
|
|
QSizePolicy::Preferred));
|
|
|
|
_graphTabWidget->setMinimumHeight(200);
|
2020-11-24 21:11:32 +01:00
|
|
|
#ifndef Q_OS_MAC
|
2016-09-27 01:27:38 +02:00
|
|
|
_graphTabWidget->setDocumentMode(true);
|
2020-11-24 21:11:32 +01:00
|
|
|
#endif // Q_OS_MAC
|
2020-11-23 22:20:06 +01:00
|
|
|
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_graphTabWidget, &QTabWidget::currentChanged, this,
|
|
|
|
&GUI::graphChanged);
|
2016-05-13 18:48:42 +02:00
|
|
|
|
2018-06-01 19:07:21 +02:00
|
|
|
_tabs.append(new ElevationGraph(_graphTabWidget));
|
|
|
|
_tabs.append(new SpeedGraph(_graphTabWidget));
|
|
|
|
_tabs.append(new HeartRateGraph(_graphTabWidget));
|
|
|
|
_tabs.append(new CadenceGraph(_graphTabWidget));
|
|
|
|
_tabs.append(new PowerGraph(_graphTabWidget));
|
|
|
|
_tabs.append(new TemperatureGraph(_graphTabWidget));
|
2018-07-03 01:29:14 +02:00
|
|
|
_tabs.append(new GearRatioGraph(_graphTabWidget));
|
2016-06-24 00:55:44 +02:00
|
|
|
|
2021-02-23 23:12:14 +01:00
|
|
|
for (int i = 0; i < _tabs.size(); i++)
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(_tabs.at(i), &GraphTab::sliderPositionChanged, _mapView,
|
|
|
|
&MapView::setMarkerPosition);
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::createStatusBar()
|
|
|
|
{
|
2015-10-14 02:54:36 +02:00
|
|
|
_fileNameLabel = new QLabel();
|
|
|
|
_distanceLabel = new QLabel();
|
2017-02-12 19:57:55 +01:00
|
|
|
_timeLabel = new QLabel();
|
2015-10-14 02:54:36 +02:00
|
|
|
_distanceLabel->setAlignment(Qt::AlignHCenter);
|
|
|
|
_timeLabel->setAlignment(Qt::AlignHCenter);
|
|
|
|
|
|
|
|
statusBar()->addPermanentWidget(_fileNameLabel, 8);
|
|
|
|
statusBar()->addPermanentWidget(_distanceLabel, 1);
|
|
|
|
statusBar()->addPermanentWidget(_timeLabel, 1);
|
2015-10-05 01:43:48 +02:00
|
|
|
statusBar()->setSizeGripEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::about()
|
|
|
|
{
|
2015-10-22 00:05:45 +02:00
|
|
|
QMessageBox msgBox(this);
|
2017-06-26 00:16:38 +02:00
|
|
|
QUrl homepage(APP_HOMEPAGE);
|
2015-10-22 00:05:45 +02:00
|
|
|
|
|
|
|
msgBox.setWindowTitle(tr("About GPXSee"));
|
2018-10-08 22:24:05 +02:00
|
|
|
msgBox.setText("<h2>" + QString(APP_NAME) + "</h2><p><p>" + tr("Version %1")
|
2020-12-22 22:09:09 +01:00
|
|
|
.arg(QString(APP_VERSION) + " (" + QSysInfo::buildCpuArchitecture()
|
|
|
|
+ ", Qt " + QT_VERSION_STR + ")") + "</p>");
|
2017-02-02 20:06:17 +01:00
|
|
|
msgBox.setInformativeText("<table width=\"300\"><tr><td>"
|
2015-10-22 00:05:45 +02:00
|
|
|
+ tr("GPXSee is distributed under the terms of the GNU General Public "
|
|
|
|
"License version 3. For more info about GPXSee visit the project "
|
2018-10-08 22:08:59 +02:00
|
|
|
"homepage at %1.").arg("<a href=\"" + homepage.toString() + "\">"
|
|
|
|
+ homepage.toString(QUrl::RemoveScheme).mid(2) + "</a>")
|
|
|
|
+ "</td></tr></table>");
|
2015-10-22 00:05:45 +02:00
|
|
|
|
|
|
|
QIcon icon = msgBox.windowIcon();
|
|
|
|
QSize size = icon.actualSize(QSize(64, 64));
|
|
|
|
msgBox.setIconPixmap(icon.pixmap(size));
|
|
|
|
|
|
|
|
msgBox.exec();
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2015-10-21 01:09:17 +02:00
|
|
|
void GUI::keys()
|
|
|
|
{
|
|
|
|
QMessageBox msgBox(this);
|
2015-10-22 00:05:45 +02:00
|
|
|
|
|
|
|
msgBox.setWindowTitle(tr("Keyboard controls"));
|
2017-02-02 20:06:17 +01:00
|
|
|
msgBox.setText("<h3>" + tr("Keyboard controls") + "</h3>");
|
2015-10-22 00:05:45 +02:00
|
|
|
msgBox.setInformativeText(
|
2017-04-05 22:53:25 +02:00
|
|
|
"<style>td {padding-right: 1.5em;}</style><div><table><tr><td>"
|
|
|
|
+ tr("Next file") + "</td><td><i>" + QKeySequence(NEXT_KEY).toString()
|
2017-02-02 20:06:17 +01:00
|
|
|
+ "</i></td></tr><tr><td>" + tr("Previous file")
|
|
|
|
+ "</td><td><i>" + QKeySequence(PREV_KEY).toString()
|
|
|
|
+ "</i></td></tr><tr><td>" + tr("First file") + "</td><td><i>"
|
|
|
|
+ QKeySequence(FIRST_KEY).toString() + "</i></td></tr><tr><td>"
|
|
|
|
+ tr("Last file") + "</td><td><i>" + QKeySequence(LAST_KEY).toString()
|
2017-04-05 22:53:25 +02:00
|
|
|
+ "</i></td></tr><tr><td>" + tr("Append file")
|
|
|
|
+ "</td><td><i>" + QKeySequence(MODIFIER).toString() + tr("Next/Previous")
|
2017-09-26 07:46:46 +02:00
|
|
|
+ "</i></td></tr><tr><td></td><td></td></tr><tr><td>"
|
|
|
|
+ tr("Toggle graph type") + "</td><td><i>"
|
|
|
|
+ QKeySequence(TOGGLE_GRAPH_TYPE_KEY).toString() + "</i></td></tr><tr><td>"
|
|
|
|
+ tr("Toggle time type") + "</td><td><i>"
|
2021-02-12 22:41:38 +01:00
|
|
|
+ QKeySequence(TOGGLE_TIME_TYPE_KEY).toString() + "</i></td></tr><tr><td>"
|
|
|
|
+ tr("Toggle position info") + "</td><td><i>"
|
|
|
|
+ QKeySequence(TOGGLE_MARKER_INFO_KEY).toString() + "</i></td></tr>"
|
2017-09-26 07:46:46 +02:00
|
|
|
+ "<tr><td></td><td></td></tr><tr><td>" + tr("Next map")
|
2017-04-05 22:53:25 +02:00
|
|
|
+ "</td><td><i>" + NEXT_MAP_SHORTCUT.toString() + "</i></td></tr><tr><td>"
|
|
|
|
+ tr("Previous map") + "</td><td><i>" + PREV_MAP_SHORTCUT.toString()
|
|
|
|
+ "</i></td></tr><tr><td></td><td></td></tr><tr><td>" + tr("Zoom in")
|
|
|
|
+ "</td><td><i>" + QKeySequence(ZOOM_IN).toString()
|
|
|
|
+ "</i></td></tr><tr><td>" + tr("Zoom out") + "</td><td><i>"
|
|
|
|
+ QKeySequence(ZOOM_OUT).toString() + "</i></td></tr><tr><td>"
|
|
|
|
+ tr("Digital zoom") + "</td><td><i>" + QKeySequence(MODIFIER).toString()
|
2020-11-13 20:15:17 +01:00
|
|
|
+ tr("Zoom") + "</i></td></tr><tr><td></td><td></td></tr><tr><td>"
|
|
|
|
+ tr("Copy coordinates") + "</td><td><i>"
|
|
|
|
+ QKeySequence(MODIFIER).toString() + tr("Left Click")
|
|
|
|
+ "</i></td></tr></table></div>");
|
2015-10-22 00:05:45 +02:00
|
|
|
|
2015-10-21 01:09:17 +02:00
|
|
|
msgBox.exec();
|
|
|
|
}
|
|
|
|
|
2018-01-31 08:14:25 +01:00
|
|
|
void GUI::paths()
|
2015-11-30 22:42:51 +01:00
|
|
|
{
|
|
|
|
QMessageBox msgBox(this);
|
|
|
|
|
2018-01-31 08:14:25 +01:00
|
|
|
msgBox.setWindowTitle(tr("Paths"));
|
|
|
|
msgBox.setText("<h3>" + tr("Paths") + "</h3>");
|
2018-07-21 14:24:13 +02:00
|
|
|
msgBox.setInformativeText(
|
2018-11-02 20:01:19 +01:00
|
|
|
"<style>td {white-space: pre; padding-right: 1em;}</style><table><tr><td>"
|
|
|
|
+ tr("Map directory:") + "</td><td><code>"
|
|
|
|
+ QDir::cleanPath(ProgramPaths::mapDir(true)) + "</code></td></tr><tr><td>"
|
|
|
|
+ tr("POI directory:") + "</td><td><code>"
|
|
|
|
+ QDir::cleanPath(ProgramPaths::poiDir(true)) + "</code></td></tr><tr><td>"
|
2018-07-21 12:52:52 +02:00
|
|
|
+ tr("GCS/PCS directory:") + "</td><td><code>"
|
2018-11-07 22:53:27 +01:00
|
|
|
+ QDir::cleanPath(ProgramPaths::csvDir(true)) + "</code></td></tr><tr><td>"
|
2019-01-06 18:45:09 +01:00
|
|
|
+ tr("DEM directory:") + "</td><td><code>"
|
|
|
|
+ QDir::cleanPath(ProgramPaths::demDir(true)) + "</code></td></tr><tr><td>"
|
2019-05-16 20:23:37 +02:00
|
|
|
+ tr("Styles directory:") + "</td><td><code>"
|
|
|
|
+ QDir::cleanPath(ProgramPaths::styleDir(true)) + "</code></td></tr><tr><td>"
|
2018-11-07 22:53:27 +01:00
|
|
|
+ tr("Tile cache directory:") + "</td><td><code>"
|
|
|
|
+ QDir::cleanPath(ProgramPaths::tilesDir()) + "</code></td></tr></table>"
|
2015-11-30 22:42:51 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
msgBox.exec();
|
|
|
|
}
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
void GUI::openFile()
|
|
|
|
{
|
2020-12-06 13:03:32 +01:00
|
|
|
QStringList files(QFileDialog::getOpenFileNames(this, tr("Open file"),
|
|
|
|
_dataDir, Data::formats()));
|
|
|
|
|
|
|
|
for (int i = 0; i < files.size(); i++)
|
|
|
|
openFile(files.at(i));
|
|
|
|
if (!files.isEmpty())
|
|
|
|
_dataDir = QFileInfo(files.last()).path();
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2020-12-06 19:17:09 +01:00
|
|
|
bool GUI::openFile(const QString &fileName, bool silent)
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2020-12-06 19:17:09 +01:00
|
|
|
if (_files.contains(fileName))
|
2020-12-08 21:29:20 +01:00
|
|
|
return true;
|
2015-10-20 22:18:41 +02:00
|
|
|
|
2020-12-06 19:17:09 +01:00
|
|
|
if (!loadFile(fileName, silent))
|
2020-12-02 23:58:11 +01:00
|
|
|
return false;
|
2016-10-28 19:29:42 +02:00
|
|
|
|
2020-12-02 23:58:11 +01:00
|
|
|
_files.append(fileName);
|
|
|
|
_browser->setCurrent(fileName);
|
|
|
|
_fileActionGroup->setEnabled(true);
|
2020-12-03 20:58:22 +01:00
|
|
|
// Explicitly enable the reload action as it may be disabled by loadMapDir()
|
|
|
|
_reloadFileAction->setEnabled(true);
|
2020-12-02 23:58:11 +01:00
|
|
|
_navigationActionGroup->setEnabled(true);
|
2018-01-29 22:43:55 +01:00
|
|
|
|
2020-12-02 23:58:11 +01:00
|
|
|
updateNavigationActions();
|
|
|
|
updateStatusBarInfo();
|
|
|
|
updateWindowTitle();
|
2016-03-23 20:56:39 +01:00
|
|
|
|
2020-12-02 23:58:11 +01:00
|
|
|
return true;
|
2015-10-20 22:18:41 +02:00
|
|
|
}
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2020-12-06 19:17:09 +01:00
|
|
|
bool GUI::loadFile(const QString &fileName, bool silent)
|
2015-10-20 22:18:41 +02:00
|
|
|
{
|
2020-12-06 19:17:09 +01:00
|
|
|
Data data(fileName, !silent);
|
2015-10-17 12:08:30 +02:00
|
|
|
|
2019-01-18 00:17:28 +01:00
|
|
|
if (data.isValid()) {
|
2020-12-06 19:17:09 +01:00
|
|
|
loadData(data);
|
2015-10-20 22:18:41 +02:00
|
|
|
return true;
|
2020-12-06 19:17:09 +01:00
|
|
|
} else if (!silent) {
|
2016-10-28 19:29:42 +02:00
|
|
|
updateNavigationActions();
|
|
|
|
updateStatusBarInfo();
|
|
|
|
updateWindowTitle();
|
|
|
|
updateGraphTabs();
|
|
|
|
|
2016-10-29 12:22:28 +02:00
|
|
|
QString error = tr("Error loading data file:") + "\n\n"
|
|
|
|
+ fileName + "\n\n" + data.errorString();
|
2016-10-23 11:09:20 +02:00
|
|
|
if (data.errorLine())
|
2016-10-29 12:22:28 +02:00
|
|
|
error.append("\n" + tr("Line: %1").arg(data.errorLine()));
|
|
|
|
QMessageBox::critical(this, APP_NAME, error);
|
2015-10-20 22:18:41 +02:00
|
|
|
return false;
|
2020-12-06 19:17:09 +01:00
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::loadData(const Data &data)
|
|
|
|
{
|
|
|
|
QList<QList<GraphItem*> > graphs;
|
|
|
|
QList<PathItem*> paths;
|
|
|
|
|
|
|
|
for (int i = 0; i < data.tracks().count(); i++) {
|
|
|
|
const Track &track = data.tracks().at(i);
|
|
|
|
_trackDistance += track.distance();
|
|
|
|
_time += track.time();
|
|
|
|
_movingTime += track.movingTime();
|
2020-12-22 22:09:09 +01:00
|
|
|
const QDateTime date = track.date().toTimeZone(_options.timeZone.zone());
|
2020-12-06 19:17:09 +01:00
|
|
|
if (_dateRange.first.isNull() || _dateRange.first > date)
|
|
|
|
_dateRange.first = date;
|
|
|
|
if (_dateRange.second.isNull() || _dateRange.second < date)
|
|
|
|
_dateRange.second = date;
|
|
|
|
}
|
|
|
|
_trackCount += data.tracks().count();
|
|
|
|
|
|
|
|
for (int i = 0; i < data.routes().count(); i++)
|
|
|
|
_routeDistance += data.routes().at(i).distance();
|
|
|
|
_routeCount += data.routes().count();
|
|
|
|
|
|
|
|
_waypointCount += data.waypoints().count();
|
|
|
|
_areaCount += data.areas().count();
|
|
|
|
|
|
|
|
if (_pathName.isNull()) {
|
|
|
|
if (data.tracks().count() == 1 && !data.routes().count())
|
|
|
|
_pathName = data.tracks().first().name();
|
|
|
|
else if (data.routes().count() == 1 && !data.tracks().count())
|
|
|
|
_pathName = data.routes().first().name();
|
|
|
|
} else
|
|
|
|
_pathName = QString();
|
|
|
|
|
|
|
|
for (int i = 0; i < _tabs.count(); i++)
|
|
|
|
graphs.append(_tabs.at(i)->loadData(data));
|
|
|
|
if (updateGraphTabs())
|
|
|
|
_splitter->refresh();
|
|
|
|
paths = _mapView->loadData(data);
|
|
|
|
|
2021-01-18 00:18:52 +01:00
|
|
|
GraphTab *gt = static_cast<GraphTab*>(_graphTabWidget->currentWidget());
|
|
|
|
|
2020-12-06 19:17:09 +01:00
|
|
|
for (int i = 0; i < paths.count(); i++) {
|
2021-01-18 00:18:52 +01:00
|
|
|
PathItem *pi = paths.at(i);
|
2021-01-23 18:24:58 +01:00
|
|
|
if (!pi)
|
|
|
|
continue;
|
2021-01-18 00:18:52 +01:00
|
|
|
|
2021-01-17 16:02:37 +01:00
|
|
|
for (int j = 0; j < graphs.count(); j++)
|
2021-01-18 00:18:52 +01:00
|
|
|
pi->addGraph(graphs.at(j).at(i));
|
|
|
|
|
2021-02-23 22:35:59 +01:00
|
|
|
if (gt) {
|
|
|
|
pi->setGraph(_tabs.indexOf(gt));
|
2021-02-08 19:52:48 +01:00
|
|
|
pi->setMarkerPosition(gt->sliderPosition());
|
|
|
|
}
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::openPOIFile()
|
|
|
|
{
|
2020-12-06 13:03:32 +01:00
|
|
|
QStringList files(QFileDialog::getOpenFileNames(this, tr("Open POI file"),
|
|
|
|
_poiDir, Data::formats()));
|
|
|
|
|
|
|
|
for (int i = 0; i < files.size(); i++)
|
|
|
|
openPOIFile(files.at(i));
|
|
|
|
if (!files.isEmpty())
|
|
|
|
_poiDir = QFileInfo(files.last()).path();
|
2016-03-22 19:47:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool GUI::openPOIFile(const QString &fileName)
|
|
|
|
{
|
2021-03-21 20:23:20 +01:00
|
|
|
if (_poi->isLoaded(fileName))
|
2020-12-08 21:29:20 +01:00
|
|
|
return true;
|
2016-03-22 19:47:11 +01:00
|
|
|
|
2018-10-07 13:07:04 +02:00
|
|
|
if (_poi->loadFile(fileName)) {
|
|
|
|
_mapView->showPOI(true);
|
|
|
|
_showPOIAction->setChecked(true);
|
2021-03-21 20:23:20 +01:00
|
|
|
QAction *action = new POIAction(fileName, _poisActionGroup);
|
2018-10-07 13:07:04 +02:00
|
|
|
action->setChecked(true);
|
2021-03-21 20:23:20 +01:00
|
|
|
_poiMenu->insertAction(_poisEnd, action);
|
2018-10-07 13:07:04 +02:00
|
|
|
|
2021-03-21 22:40:39 +01:00
|
|
|
_selectAllPOIAction->setEnabled(true);
|
|
|
|
_unselectAllPOIAction->setEnabled(true);
|
|
|
|
|
2018-10-07 13:07:04 +02:00
|
|
|
return true;
|
|
|
|
} else {
|
2016-10-29 12:22:28 +02:00
|
|
|
QString error = tr("Error loading POI file:") + "\n\n"
|
|
|
|
+ fileName + "\n\n" + _poi->errorString();
|
2016-10-09 23:46:30 +02:00
|
|
|
if (_poi->errorLine())
|
2016-10-29 12:22:28 +02:00
|
|
|
error.append("\n" + tr("Line: %1").arg(_poi->errorLine()));
|
|
|
|
QMessageBox::critical(this, APP_NAME, error);
|
2016-03-22 19:47:11 +01:00
|
|
|
|
|
|
|
return false;
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-06 01:48:26 +01:00
|
|
|
void GUI::openOptions()
|
|
|
|
{
|
2017-09-15 00:07:09 +02:00
|
|
|
#define SET_VIEW_OPTION(option, action) \
|
|
|
|
if (options.option != _options.option) \
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->action(options.option)
|
2017-09-15 00:07:09 +02:00
|
|
|
#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; \
|
|
|
|
}
|
2020-03-25 23:08:26 +01:00
|
|
|
#define SET_ROUTE_OPTION(option, action) \
|
2019-01-17 00:47:44 +01:00
|
|
|
if (options.option != _options.option) { \
|
2020-03-25 23:08:26 +01:00
|
|
|
Route::action(options.option); \
|
|
|
|
reload = true; \
|
|
|
|
}
|
|
|
|
#define SET_WAYPOINT_OPTION(option, action) \
|
|
|
|
if (options.option != _options.option) { \
|
|
|
|
Waypoint::action(options.option); \
|
2019-01-17 00:47:44 +01:00
|
|
|
reload = true; \
|
|
|
|
}
|
2017-09-15 00:07:09 +02:00
|
|
|
|
2016-12-06 01:48:26 +01:00
|
|
|
Options options(_options);
|
2017-05-22 14:54:22 +02:00
|
|
|
bool reload = false;
|
2016-12-06 01:48:26 +01:00
|
|
|
|
2020-09-27 00:34:38 +02:00
|
|
|
OptionsDialog dialog(options, _units, this);
|
2016-12-06 01:48:26 +01:00
|
|
|
if (dialog.exec() != QDialog::Accepted)
|
|
|
|
return;
|
|
|
|
|
2017-09-15 00:07:09 +02:00
|
|
|
SET_VIEW_OPTION(palette, setPalette);
|
|
|
|
SET_VIEW_OPTION(mapOpacity, setMapOpacity);
|
|
|
|
SET_VIEW_OPTION(backgroundColor, setBackgroundColor);
|
|
|
|
SET_VIEW_OPTION(trackWidth, setTrackWidth);
|
|
|
|
SET_VIEW_OPTION(routeWidth, setRouteWidth);
|
2019-01-31 01:46:53 +01:00
|
|
|
SET_VIEW_OPTION(areaWidth, setAreaWidth);
|
2017-09-15 00:07:09 +02:00
|
|
|
SET_VIEW_OPTION(trackStyle, setTrackStyle);
|
|
|
|
SET_VIEW_OPTION(routeStyle, setRouteStyle);
|
2019-01-31 01:46:53 +01:00
|
|
|
SET_VIEW_OPTION(areaStyle, setAreaStyle);
|
|
|
|
SET_VIEW_OPTION(areaOpacity, setAreaOpacity);
|
2017-09-15 00:07:09 +02:00
|
|
|
SET_VIEW_OPTION(waypointSize, setWaypointSize);
|
|
|
|
SET_VIEW_OPTION(waypointColor, setWaypointColor);
|
|
|
|
SET_VIEW_OPTION(poiSize, setPOISize);
|
|
|
|
SET_VIEW_OPTION(poiColor, setPOIColor);
|
|
|
|
SET_VIEW_OPTION(pathAntiAliasing, useAntiAliasing);
|
|
|
|
SET_VIEW_OPTION(useOpenGL, useOpenGL);
|
2017-12-03 00:36:52 +01:00
|
|
|
SET_VIEW_OPTION(sliderColor, setMarkerColor);
|
2021-06-17 21:58:25 +02:00
|
|
|
|
|
|
|
if (options.hidpiMap != _options.hidpiMap)
|
|
|
|
_mapView->setDevicePixelRatio(devicePixelRatioF(),
|
|
|
|
options.hidpiMap ? devicePixelRatioF() : 1.0);
|
|
|
|
if (options.outputProjection != _options.outputProjection)
|
|
|
|
_mapView->setOutputProjection(CRS::projection(options.outputProjection));
|
|
|
|
if (options.inputProjection != _options.inputProjection)
|
|
|
|
_mapView->setInputProjection(CRS::projection(options.inputProjection));
|
|
|
|
if (options.timeZone != _options.timeZone) {
|
|
|
|
_mapView->setTimeZone(options.timeZone.zone());
|
|
|
|
_dateRange.first = _dateRange.first.toTimeZone(options.timeZone.zone());
|
|
|
|
_dateRange.second = _dateRange.second.toTimeZone(options.timeZone.zone());
|
|
|
|
}
|
2017-09-15 00:07:09 +02:00
|
|
|
|
|
|
|
SET_TAB_OPTION(palette, setPalette);
|
|
|
|
SET_TAB_OPTION(graphWidth, setGraphWidth);
|
|
|
|
SET_TAB_OPTION(graphAntiAliasing, useAntiAliasing);
|
|
|
|
SET_TAB_OPTION(useOpenGL, useOpenGL);
|
2017-12-03 00:36:52 +01:00
|
|
|
SET_TAB_OPTION(sliderColor, setSliderColor);
|
2017-09-15 00:07:09 +02:00
|
|
|
|
|
|
|
SET_TRACK_OPTION(elevationFilter, setElevationFilter);
|
|
|
|
SET_TRACK_OPTION(speedFilter, setSpeedFilter);
|
|
|
|
SET_TRACK_OPTION(heartRateFilter, setHeartRateFilter);
|
|
|
|
SET_TRACK_OPTION(cadenceFilter, setCadenceFilter);
|
|
|
|
SET_TRACK_OPTION(powerFilter, setPowerFilter);
|
|
|
|
SET_TRACK_OPTION(outlierEliminate, setOutlierElimination);
|
2019-11-13 08:27:54 +01:00
|
|
|
SET_TRACK_OPTION(automaticPause, setAutomaticPause);
|
2017-09-15 00:07:09 +02:00
|
|
|
SET_TRACK_OPTION(pauseSpeed, setPauseSpeed);
|
|
|
|
SET_TRACK_OPTION(pauseInterval, setPauseInterval);
|
2018-06-21 20:54:24 +02:00
|
|
|
SET_TRACK_OPTION(useReportedSpeed, useReportedSpeed);
|
2020-03-25 23:08:26 +01:00
|
|
|
SET_TRACK_OPTION(dataUseDEM, useDEM);
|
|
|
|
SET_TRACK_OPTION(showSecondaryElevation, showSecondaryElevation);
|
|
|
|
SET_TRACK_OPTION(showSecondarySpeed, showSecondarySpeed);
|
2020-09-20 22:18:35 +02:00
|
|
|
SET_TRACK_OPTION(useSegments, useSegments);
|
2020-03-25 23:08:26 +01:00
|
|
|
|
|
|
|
SET_ROUTE_OPTION(dataUseDEM, useDEM);
|
|
|
|
SET_ROUTE_OPTION(showSecondaryElevation, showSecondaryElevation);
|
2019-01-22 23:01:40 +01:00
|
|
|
|
2020-03-25 23:08:26 +01:00
|
|
|
SET_WAYPOINT_OPTION(dataUseDEM, useDEM);
|
|
|
|
SET_WAYPOINT_OPTION(showSecondaryElevation, showSecondaryElevation);
|
2017-05-22 14:54:22 +02:00
|
|
|
|
2016-12-06 01:48:26 +01:00
|
|
|
if (options.poiRadius != _options.poiRadius)
|
|
|
|
_poi->setRadius(options.poiRadius);
|
2019-01-22 23:01:40 +01:00
|
|
|
|
2017-05-03 23:55:16 +02:00
|
|
|
if (options.pixmapCache != _options.pixmapCache)
|
2017-05-04 00:04:28 +02:00
|
|
|
QPixmapCache::setCacheLimit(options.pixmapCache * 1024);
|
2019-01-22 23:01:40 +01:00
|
|
|
|
2018-04-27 19:31:27 +02:00
|
|
|
if (options.connectionTimeout != _options.connectionTimeout)
|
|
|
|
Downloader::setTimeout(options.connectionTimeout);
|
2018-07-23 23:53:58 +02:00
|
|
|
if (options.enableHTTP2 != _options.enableHTTP2)
|
|
|
|
Downloader::enableHTTP2(options.enableHTTP2);
|
2019-01-22 23:01:40 +01:00
|
|
|
|
2021-07-13 08:52:41 +02:00
|
|
|
if (options.dataPath != _options.dataPath)
|
|
|
|
_dataDir = options.dataPath;
|
|
|
|
if (options.mapsPath != _options.mapsPath)
|
|
|
|
_mapDir = options.mapsPath;
|
|
|
|
if (options.poiPath != _options.poiPath)
|
|
|
|
_poiDir = options.poiPath;
|
|
|
|
|
2017-05-22 14:54:22 +02:00
|
|
|
if (reload)
|
2020-05-20 21:00:36 +02:00
|
|
|
reloadFiles();
|
2017-05-22 14:54:22 +02:00
|
|
|
|
2016-12-06 01:48:26 +01:00
|
|
|
_options = options;
|
|
|
|
}
|
|
|
|
|
2017-08-28 15:25:45 +02:00
|
|
|
void GUI::printFile()
|
|
|
|
{
|
|
|
|
QPrinter printer(QPrinter::HighResolution);
|
|
|
|
QPrintDialog dialog(&printer, this);
|
|
|
|
|
|
|
|
if (dialog.exec() == QDialog::Accepted)
|
|
|
|
plot(&printer);
|
|
|
|
}
|
|
|
|
|
2020-09-27 00:34:38 +02:00
|
|
|
void GUI::exportPDFFile()
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2020-09-27 00:34:38 +02:00
|
|
|
PDFExportDialog dialog(_pdfExport, _units, this);
|
2016-12-06 01:48:26 +01:00
|
|
|
if (dialog.exec() != QDialog::Accepted)
|
|
|
|
return;
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
QPrinter printer(QPrinter::HighResolution);
|
2016-12-06 01:48:26 +01:00
|
|
|
printer.setOutputFormat(QPrinter::PdfFormat);
|
|
|
|
printer.setCreator(QString(APP_NAME) + QString(" ")
|
|
|
|
+ QString(APP_VERSION));
|
2020-09-27 00:34:38 +02:00
|
|
|
printer.setResolution(_pdfExport.resolution);
|
2020-12-22 22:09:09 +01:00
|
|
|
printer.setPageLayout(QPageLayout(QPageSize(_pdfExport.paperSize),
|
|
|
|
_pdfExport.orientation, _pdfExport.margins, QPageLayout::Millimeter));
|
2020-09-27 00:34:38 +02:00
|
|
|
printer.setOutputFileName(_pdfExport.fileName);
|
2016-12-06 01:48:26 +01:00
|
|
|
|
|
|
|
plot(&printer);
|
2016-05-15 22:38:15 +02:00
|
|
|
}
|
|
|
|
|
2020-09-27 00:34:38 +02:00
|
|
|
void GUI::exportPNGFile()
|
|
|
|
{
|
|
|
|
PNGExportDialog dialog(_pngExport, this);
|
|
|
|
if (dialog.exec() != QDialog::Accepted)
|
|
|
|
return;
|
|
|
|
|
|
|
|
QImage img(_pngExport.size, QImage::Format_ARGB32_Premultiplied);
|
|
|
|
QPainter p(&img);
|
|
|
|
QRectF rect(0, 0, img.width(), img.height());
|
|
|
|
QRectF contentRect(rect.adjusted(_pngExport.margins.left(),
|
|
|
|
_pngExport.margins.top(), -_pngExport.margins.right(),
|
|
|
|
-_pngExport.margins.bottom()));
|
|
|
|
|
|
|
|
if (_pngExport.antialiasing)
|
|
|
|
p.setRenderHint(QPainter::Antialiasing);
|
|
|
|
p.fillRect(rect, Qt::white);
|
|
|
|
plotMainPage(&p, contentRect, 1.0, true);
|
2020-11-23 22:26:15 +01:00
|
|
|
img.save(_pngExport.fileName, "png");
|
2020-09-27 00:34:38 +02:00
|
|
|
|
|
|
|
if (!_tabs.isEmpty() && _options.separateGraphPage) {
|
2020-09-29 19:49:33 +02:00
|
|
|
QImage img2(_pngExport.size.width(), (int)graphPlotHeight(rect, 1)
|
|
|
|
+ _pngExport.margins.bottom(), QImage::Format_ARGB32_Premultiplied);
|
2020-09-27 00:34:38 +02:00
|
|
|
QPainter p2(&img2);
|
|
|
|
QRectF rect2(0, 0, img2.width(), img2.height());
|
|
|
|
|
|
|
|
if (_pngExport.antialiasing)
|
|
|
|
p2.setRenderHint(QPainter::Antialiasing);
|
|
|
|
p2.fillRect(rect2, Qt::white);
|
|
|
|
plotGraphsPage(&p2, contentRect, 1);
|
|
|
|
|
|
|
|
QFileInfo fi(_pngExport.fileName);
|
|
|
|
img2.save(fi.absolutePath() + "/" + fi.baseName() + "-graphs."
|
2020-11-23 22:26:15 +01:00
|
|
|
+ fi.suffix(), "png");
|
2020-09-27 00:34:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-21 16:13:18 +02:00
|
|
|
void GUI::statistics()
|
|
|
|
{
|
2018-09-09 18:46:43 +02:00
|
|
|
QLocale l(QLocale::system());
|
|
|
|
|
2018-07-21 18:11:19 +02:00
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
QString text = "<style>td {white-space: pre; padding-right: 4em;}"
|
|
|
|
"th {text-align: left; padding-top: 0.5em;}</style><table>";
|
|
|
|
#else // Q_OS_WIN32
|
|
|
|
QString text = "<style>td {white-space: pre; padding-right: 2em;}"
|
2018-07-21 16:13:18 +02:00
|
|
|
"th {text-align: left; padding-top: 0.5em;}</style><table>";
|
2018-07-21 18:11:19 +02:00
|
|
|
#endif // Q_OS_WIN32
|
2018-07-21 16:13:18 +02:00
|
|
|
|
|
|
|
if (_showTracksAction->isChecked() && _trackCount > 1)
|
|
|
|
text.append("<tr><td>" + tr("Tracks") + ":</td><td>"
|
2018-09-09 18:46:43 +02:00
|
|
|
+ l.toString(_trackCount) + "</td></tr>");
|
2018-07-21 16:13:18 +02:00
|
|
|
if (_showRoutesAction->isChecked() && _routeCount > 1)
|
|
|
|
text.append("<tr><td>" + tr("Routes") + ":</td><td>"
|
2018-09-09 18:46:43 +02:00
|
|
|
+ l.toString(_routeCount) + "</td></tr>");
|
2018-07-21 16:13:18 +02:00
|
|
|
if (_showWaypointsAction->isChecked() && _waypointCount > 1)
|
|
|
|
text.append("<tr><td>" + tr("Waypoints") + ":</td><td>"
|
2018-09-09 18:46:43 +02:00
|
|
|
+ l.toString(_waypointCount) + "</td></tr>");
|
2019-01-31 01:46:53 +01:00
|
|
|
if (_showAreasAction->isChecked() && _areaCount > 1)
|
|
|
|
text.append("<tr><td>" + tr("Areas") + ":</td><td>"
|
|
|
|
+ l.toString(_areaCount) + "</td></tr>");
|
2018-07-21 16:13:18 +02:00
|
|
|
|
|
|
|
if (_dateRange.first.isValid()) {
|
|
|
|
if (_dateRange.first == _dateRange.second) {
|
2018-09-09 18:46:43 +02:00
|
|
|
QString format = l.dateFormat(QLocale::LongFormat);
|
2018-07-21 16:13:18 +02:00
|
|
|
text.append("<tr><td>" + tr("Date") + ":</td><td>"
|
|
|
|
+ _dateRange.first.toString(format) + "</td></tr>");
|
|
|
|
} else {
|
2018-09-09 18:46:43 +02:00
|
|
|
QString format = l.dateFormat(QLocale::ShortFormat);
|
2018-07-21 16:13:18 +02:00
|
|
|
text.append("<tr><td>" + tr("Date") + ":</td><td>"
|
|
|
|
+ QString("%1 - %2").arg(_dateRange.first.toString(format),
|
|
|
|
_dateRange.second.toString(format)) + "</td></tr>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (distance() > 0)
|
|
|
|
text.append("<tr><td>" + tr("Distance") + ":</td><td>"
|
|
|
|
+ Format::distance(distance(), units()) + "</td></tr>");
|
|
|
|
if (time() > 0) {
|
|
|
|
text.append("<tr><td>" + tr("Time") + ":</td><td>"
|
|
|
|
+ Format::timeSpan(time()) + "</td></tr>");
|
|
|
|
text.append("<tr><td>" + tr("Moving time") + ":</td><td>"
|
|
|
|
+ Format::timeSpan(movingTime()) + "</td></tr>");
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < _tabs.count(); i++) {
|
|
|
|
const GraphTab *tab = _tabs.at(i);
|
|
|
|
if (tab->isEmpty())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
text.append("<tr><th colspan=\"2\">" + tab->label() + "</th></tr>");
|
|
|
|
for (int j = 0; j < tab->info().size(); j++) {
|
2019-08-01 08:36:58 +02:00
|
|
|
const KV<QString, QString> &kv = tab->info().at(j);
|
2018-07-21 16:13:18 +02:00
|
|
|
text.append("<tr><td>" + kv.key() + ":</td><td>" + kv.value()
|
|
|
|
+ "</td></tr>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
text.append("</table>");
|
|
|
|
|
|
|
|
|
|
|
|
QMessageBox msgBox(this);
|
|
|
|
msgBox.setWindowTitle(tr("Statistics"));
|
|
|
|
msgBox.setText("<h3>" + tr("Statistics") + "</h3>");
|
|
|
|
msgBox.setInformativeText(text);
|
|
|
|
msgBox.exec();
|
|
|
|
}
|
|
|
|
|
2020-09-27 00:34:38 +02:00
|
|
|
void GUI::plotMainPage(QPainter *painter, const QRectF &rect, qreal ratio,
|
|
|
|
bool expand)
|
2016-05-15 22:38:15 +02:00
|
|
|
{
|
2018-09-09 18:46:43 +02:00
|
|
|
QLocale l(QLocale::system());
|
2016-05-12 09:03:05 +02:00
|
|
|
TrackInfo info;
|
2020-09-27 00:34:38 +02:00
|
|
|
qreal ih, gh, mh;
|
2020-09-27 22:36:08 +02:00
|
|
|
int sc;
|
2018-07-21 21:11:37 +02:00
|
|
|
|
2016-05-15 22:38:15 +02:00
|
|
|
|
2016-12-16 02:30:58 +01:00
|
|
|
if (!_pathName.isNull() && _options.printName)
|
|
|
|
info.insert(tr("Name"), _pathName);
|
|
|
|
|
|
|
|
if (_options.printItemCount) {
|
2017-12-01 00:22:16 +01:00
|
|
|
if (_showTracksAction->isChecked() && _trackCount > 1)
|
2018-09-09 18:46:43 +02:00
|
|
|
info.insert(tr("Tracks"), l.toString(_trackCount));
|
2017-12-01 00:22:16 +01:00
|
|
|
if (_showRoutesAction->isChecked() && _routeCount > 1)
|
2018-09-09 18:46:43 +02:00
|
|
|
info.insert(tr("Routes"), l.toString(_routeCount));
|
2018-07-21 16:13:18 +02:00
|
|
|
if (_showWaypointsAction->isChecked() && _waypointCount > 1)
|
2018-09-09 18:46:43 +02:00
|
|
|
info.insert(tr("Waypoints"), l.toString(_waypointCount));
|
2019-01-31 01:46:53 +01:00
|
|
|
if (_showAreasAction->isChecked() && _areaCount > 1)
|
|
|
|
info.insert(tr("Areas"), l.toString(_areaCount));
|
2016-12-16 02:30:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_dateRange.first.isValid() && _options.printDate) {
|
2016-05-21 16:10:24 +02:00
|
|
|
if (_dateRange.first == _dateRange.second) {
|
2018-09-09 18:46:43 +02:00
|
|
|
QString format = l.dateFormat(QLocale::LongFormat);
|
2016-05-21 16:10:24 +02:00
|
|
|
info.insert(tr("Date"), _dateRange.first.toString(format));
|
|
|
|
} else {
|
2018-09-09 18:46:43 +02:00
|
|
|
QString format = l.dateFormat(QLocale::ShortFormat);
|
2016-05-21 16:10:24 +02:00
|
|
|
info.insert(tr("Date"), QString("%1 - %2")
|
|
|
|
.arg(_dateRange.first.toString(format),
|
|
|
|
_dateRange.second.toString(format)));
|
|
|
|
}
|
|
|
|
}
|
2016-08-09 23:08:49 +02:00
|
|
|
|
2018-07-21 21:11:37 +02:00
|
|
|
if (distance() > 0 && _options.printDistance)
|
|
|
|
info.insert(tr("Distance"), Format::distance(distance(), units()));
|
|
|
|
if (time() > 0 && _options.printTime)
|
|
|
|
info.insert(tr("Time"), Format::timeSpan(time()));
|
|
|
|
if (movingTime() > 0 && _options.printMovingTime)
|
|
|
|
info.insert(tr("Moving time"), Format::timeSpan(movingTime()));
|
2016-05-21 16:10:24 +02:00
|
|
|
|
|
|
|
if (info.isEmpty()) {
|
2016-05-24 03:01:22 +02:00
|
|
|
ih = 0;
|
|
|
|
mh = 0;
|
2016-05-21 00:28:06 +02:00
|
|
|
} else {
|
2016-05-25 23:27:07 +02:00
|
|
|
ih = info.contentSize().height() * ratio;
|
2016-05-24 03:01:22 +02:00
|
|
|
mh = ih / 2;
|
2020-09-27 00:34:38 +02:00
|
|
|
info.plot(painter, QRectF(rect.x(), rect.y(), rect.width(), ih), ratio);
|
2016-05-21 16:10:24 +02:00
|
|
|
}
|
2016-12-16 02:30:58 +01:00
|
|
|
if (_graphTabWidget->isVisible() && !_options.separateGraphPage) {
|
2020-09-27 00:34:38 +02:00
|
|
|
qreal r = rect.width() / rect.height();
|
|
|
|
gh = (rect.width() > rect.height())
|
|
|
|
? 0.15 * r * (rect.height() - ih - 2*mh)
|
|
|
|
: 0.15 * (rect.height() - ih - 2*mh);
|
2020-09-27 22:36:08 +02:00
|
|
|
if (gh < 150)
|
|
|
|
gh = 150;
|
|
|
|
sc = 2;
|
2016-09-27 01:27:38 +02:00
|
|
|
GraphTab *gt = static_cast<GraphTab*>(_graphTabWidget->currentWidget());
|
2020-09-27 00:34:38 +02:00
|
|
|
gt->plot(painter, QRectF(rect.x(), rect.y() + rect.height() - gh,
|
|
|
|
rect.width(), gh), ratio);
|
|
|
|
} else {
|
2016-05-24 03:01:22 +02:00
|
|
|
gh = 0;
|
2020-09-27 22:36:08 +02:00
|
|
|
sc = 1;
|
2020-09-27 00:34:38 +02:00
|
|
|
}
|
2016-12-16 02:30:58 +01:00
|
|
|
|
2020-12-08 00:58:01 +01:00
|
|
|
MapView::PlotFlags flags;
|
2020-09-27 00:34:38 +02:00
|
|
|
if (_options.hiresPrint)
|
|
|
|
flags |= MapView::HiRes;
|
|
|
|
if (expand)
|
|
|
|
flags |= MapView::Expand;
|
2016-12-16 02:30:58 +01:00
|
|
|
|
2020-09-27 00:34:38 +02:00
|
|
|
_mapView->plot(painter, QRectF(rect.x(), rect.y() + ih + mh, rect.width(),
|
2020-09-27 22:36:08 +02:00
|
|
|
rect.height() - (ih + sc*mh + gh)), ratio, flags);
|
2020-09-27 00:34:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::plotGraphsPage(QPainter *painter, const QRectF &rect, qreal ratio)
|
|
|
|
{
|
|
|
|
int cnt = 0;
|
|
|
|
for (int i = 0; i < _tabs.size(); i++)
|
|
|
|
if (!_tabs.at(i)->isEmpty())
|
|
|
|
cnt++;
|
|
|
|
|
|
|
|
qreal sp = ratio * 20;
|
|
|
|
qreal gh = qMin((rect.height() - ((cnt - 1) * sp))/(qreal)cnt,
|
|
|
|
0.20 * rect.height());
|
|
|
|
|
|
|
|
qreal y = 0;
|
|
|
|
for (int i = 0; i < _tabs.size(); i++) {
|
|
|
|
if (!_tabs.at(i)->isEmpty()) {
|
|
|
|
_tabs.at(i)->plot(painter, QRectF(rect.x(), rect.y() + y,
|
|
|
|
rect.width(), gh), ratio);
|
|
|
|
y += gh + sp;
|
2016-12-16 02:30:58 +01:00
|
|
|
}
|
|
|
|
}
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2020-09-27 00:34:38 +02:00
|
|
|
qreal GUI::graphPlotHeight(const QRectF &rect, qreal ratio)
|
|
|
|
{
|
|
|
|
int cnt = 0;
|
|
|
|
for (int i = 0; i < _tabs.size(); i++)
|
|
|
|
if (!_tabs.at(i)->isEmpty())
|
|
|
|
cnt++;
|
|
|
|
|
|
|
|
qreal sp = ratio * 20;
|
|
|
|
qreal gh = qMin((rect.height() - ((cnt - 1) * sp))/(qreal)cnt,
|
|
|
|
0.20 * rect.height());
|
|
|
|
|
|
|
|
return cnt * gh + (cnt - 1) * sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::plot(QPrinter *printer)
|
|
|
|
{
|
|
|
|
QPainter p(printer);
|
|
|
|
qreal fsr = 1085.0 / (qMax(printer->width(), printer->height())
|
|
|
|
/ (qreal)printer->resolution());
|
|
|
|
qreal ratio = p.paintEngine()->paintDevice()->logicalDpiX() / fsr;
|
|
|
|
QRectF rect(0, 0, printer->width(), printer->height());
|
|
|
|
|
|
|
|
plotMainPage(&p, rect, ratio);
|
|
|
|
|
|
|
|
if (!_tabs.isEmpty() && _options.separateGraphPage) {
|
|
|
|
printer->newPage();
|
|
|
|
plotGraphsPage(&p, rect, ratio);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-20 21:00:36 +02:00
|
|
|
void GUI::reloadFiles()
|
2015-10-20 22:18:41 +02:00
|
|
|
{
|
2016-02-29 09:04:36 +01:00
|
|
|
_trackCount = 0;
|
2016-08-09 23:08:49 +02:00
|
|
|
_routeCount = 0;
|
|
|
|
_waypointCount = 0;
|
2019-01-31 01:46:53 +01:00
|
|
|
_areaCount = 0;
|
2016-08-10 20:36:09 +02:00
|
|
|
_trackDistance = 0;
|
|
|
|
_routeDistance = 0;
|
|
|
|
_time = 0;
|
2017-01-31 09:37:01 +01:00
|
|
|
_movingTime = 0;
|
2020-05-20 21:00:36 +02:00
|
|
|
_dateRange = DateTimeRange(QDateTime(), QDateTime());
|
2016-12-16 02:30:58 +01:00
|
|
|
_pathName = QString();
|
2015-10-20 22:18:41 +02:00
|
|
|
|
2016-06-24 00:55:44 +02:00
|
|
|
for (int i = 0; i < _tabs.count(); i++)
|
|
|
|
_tabs.at(i)->clear();
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->clear();
|
2015-10-20 22:18:41 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < _files.size(); i++) {
|
|
|
|
if (!loadFile(_files.at(i))) {
|
|
|
|
_files.removeAt(i);
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateStatusBarInfo();
|
2016-04-19 08:51:11 +02:00
|
|
|
updateWindowTitle();
|
2015-10-20 22:18:41 +02:00
|
|
|
if (_files.isEmpty())
|
|
|
|
_fileActionGroup->setEnabled(false);
|
|
|
|
else
|
|
|
|
_browser->setCurrent(_files.last());
|
|
|
|
}
|
|
|
|
|
2016-03-23 20:56:39 +01:00
|
|
|
void GUI::closeFiles()
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2016-02-08 17:53:09 +01:00
|
|
|
_trackCount = 0;
|
2016-08-09 23:08:49 +02:00
|
|
|
_routeCount = 0;
|
|
|
|
_waypointCount = 0;
|
2019-01-31 01:46:53 +01:00
|
|
|
_areaCount = 0;
|
2016-08-10 20:36:09 +02:00
|
|
|
_trackDistance = 0;
|
|
|
|
_routeDistance = 0;
|
|
|
|
_time = 0;
|
2017-01-31 09:37:01 +01:00
|
|
|
_movingTime = 0;
|
2020-05-20 21:00:36 +02:00
|
|
|
_dateRange = DateTimeRange(QDateTime(), QDateTime());
|
2016-12-16 02:30:58 +01:00
|
|
|
_pathName = QString();
|
2015-10-12 01:12:12 +02:00
|
|
|
|
2016-06-24 00:55:44 +02:00
|
|
|
for (int i = 0; i < _tabs.count(); i++)
|
|
|
|
_tabs.at(i)->clear();
|
2021-03-06 12:19:18 +01:00
|
|
|
_lastTab = 0;
|
|
|
|
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->clear();
|
2015-10-20 22:18:41 +02:00
|
|
|
|
|
|
|
_files.clear();
|
2016-03-23 20:56:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::closeAll()
|
|
|
|
{
|
|
|
|
closeFiles();
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
_fileActionGroup->setEnabled(false);
|
2015-10-20 22:18:41 +02:00
|
|
|
updateStatusBarInfo();
|
2016-04-19 08:51:11 +02:00
|
|
|
updateWindowTitle();
|
2016-03-23 09:38:22 +01:00
|
|
|
updateGraphTabs();
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2016-10-17 23:14:07 +02:00
|
|
|
void GUI::showGraphs(bool show)
|
2015-11-24 00:24:26 +01:00
|
|
|
{
|
2016-10-17 23:14:07 +02:00
|
|
|
_graphTabWidget->setHidden(!show);
|
2015-11-24 00:24:26 +01:00
|
|
|
}
|
|
|
|
|
2016-10-17 23:14:07 +02:00
|
|
|
void GUI::showToolbars(bool show)
|
2015-11-24 00:24:26 +01:00
|
|
|
{
|
2016-10-17 23:14:07 +02:00
|
|
|
if (show) {
|
2019-02-18 22:33:18 +01:00
|
|
|
Q_ASSERT(!_windowStates.isEmpty());
|
|
|
|
restoreState(_windowStates.last());
|
2021-02-19 19:31:54 +01:00
|
|
|
_windowStates.removeLast();
|
2015-11-24 00:24:26 +01:00
|
|
|
} else {
|
2019-02-18 22:33:18 +01:00
|
|
|
_windowStates.append(saveState());
|
2015-11-24 00:24:26 +01:00
|
|
|
removeToolBar(_fileToolBar);
|
|
|
|
removeToolBar(_showToolBar);
|
2015-12-18 22:21:11 +01:00
|
|
|
removeToolBar(_navigationToolBar);
|
2015-11-24 00:24:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-17 23:14:07 +02:00
|
|
|
void GUI::showFullscreen(bool show)
|
2016-04-05 09:10:19 +02:00
|
|
|
{
|
2016-10-17 23:14:07 +02:00
|
|
|
if (show) {
|
2021-02-19 19:31:54 +01:00
|
|
|
_windowGeometries.append(saveGeometry());
|
2017-12-01 00:22:16 +01:00
|
|
|
_frameStyle = _mapView->frameStyle();
|
2016-04-05 09:10:19 +02:00
|
|
|
statusBar()->hide();
|
|
|
|
menuBar()->hide();
|
|
|
|
showToolbars(false);
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->setFrameStyle(QFrame::NoFrame);
|
2021-02-19 19:36:26 +01:00
|
|
|
_graphTabWidget->tabBar()->hide();
|
2021-02-21 10:00:42 +01:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
_graphTabWidget->setDocumentMode(true);
|
|
|
|
#endif // Q_OS_MAC
|
2016-04-05 09:10:19 +02:00
|
|
|
showFullScreen();
|
|
|
|
} else {
|
2021-02-19 19:31:54 +01:00
|
|
|
Q_ASSERT(!_windowGeometries.isEmpty());
|
|
|
|
_windowGeometries.removeLast();
|
2016-04-05 09:10:19 +02:00
|
|
|
statusBar()->show();
|
|
|
|
menuBar()->show();
|
2019-02-18 22:33:18 +01:00
|
|
|
showToolbars(true);
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->setFrameStyle(_frameStyle);
|
2021-02-19 19:36:26 +01:00
|
|
|
_graphTabWidget->tabBar()->show();
|
2021-02-21 10:00:42 +01:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
_graphTabWidget->setDocumentMode(false);
|
|
|
|
#endif // Q_OS_MAC
|
2016-04-05 09:10:19 +02:00
|
|
|
showNormal();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-10 20:36:09 +02:00
|
|
|
void GUI::showTracks(bool show)
|
2016-08-09 01:16:19 +02:00
|
|
|
{
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->showTracks(show);
|
2016-08-16 00:27:54 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < _tabs.size(); i++)
|
|
|
|
_tabs.at(i)->showTracks(show);
|
|
|
|
|
2016-08-10 20:36:09 +02:00
|
|
|
updateStatusBarInfo();
|
2017-12-01 00:22:16 +01:00
|
|
|
updateGraphTabs();
|
2016-08-10 20:36:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::showRoutes(bool show)
|
|
|
|
{
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->showRoutes(show);
|
2016-08-16 00:27:54 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < _tabs.size(); i++)
|
|
|
|
_tabs.at(i)->showRoutes(show);
|
|
|
|
|
2016-08-10 20:36:09 +02:00
|
|
|
updateStatusBarInfo();
|
2017-12-01 00:22:16 +01:00
|
|
|
updateGraphTabs();
|
2016-08-09 01:16:19 +02:00
|
|
|
}
|
|
|
|
|
2016-10-17 23:14:07 +02:00
|
|
|
void GUI::showGraphGrids(bool show)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < _tabs.size(); i++)
|
|
|
|
_tabs.at(i)->showGrid(show);
|
|
|
|
}
|
|
|
|
|
2017-09-29 11:43:09 +02:00
|
|
|
void GUI::showGraphSliderInfo(bool show)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < _tabs.size(); i++)
|
|
|
|
_tabs.at(i)->showSliderInfo(show);
|
|
|
|
}
|
|
|
|
|
2021-02-12 22:41:38 +01:00
|
|
|
void GUI::showPathMarkerInfo(QAction *action)
|
|
|
|
{
|
|
|
|
if (action == _showMarkersAction) {
|
|
|
|
_mapView->showMarkers(true);
|
|
|
|
_mapView->showMarkerInfo(MarkerInfoItem::None);
|
|
|
|
} else if (action == _showMarkerDateAction) {
|
|
|
|
_mapView->showMarkers(true);
|
|
|
|
_mapView->showMarkerInfo(MarkerInfoItem::Date);
|
|
|
|
} else if (action == _showMarkerCoordinatesAction) {
|
|
|
|
_mapView->showMarkers(true);
|
|
|
|
_mapView->showMarkerInfo(MarkerInfoItem::Position);
|
|
|
|
} else {
|
|
|
|
_mapView->showMarkers(false);
|
|
|
|
_mapView->showMarkerInfo(MarkerInfoItem::None);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-21 21:15:58 +02:00
|
|
|
void GUI::loadMap()
|
|
|
|
{
|
2020-12-06 13:03:32 +01:00
|
|
|
QStringList files(QFileDialog::getOpenFileNames(this, tr("Open map file"),
|
|
|
|
_mapDir, MapList::formats()));
|
2020-12-06 19:17:09 +01:00
|
|
|
MapAction *a, *lastReady = 0;
|
2017-04-21 21:15:58 +02:00
|
|
|
|
2020-12-06 13:03:32 +01:00
|
|
|
for (int i = 0; i < files.size(); i++) {
|
2020-12-06 19:17:09 +01:00
|
|
|
if (loadMap(files.at(i), a) && a)
|
2020-12-06 12:53:39 +01:00
|
|
|
lastReady = a;
|
|
|
|
}
|
2020-12-06 13:03:32 +01:00
|
|
|
if (!files.isEmpty())
|
|
|
|
_mapDir = QFileInfo(files.last()).path();
|
2020-12-06 12:53:39 +01:00
|
|
|
if (lastReady)
|
|
|
|
lastReady->trigger();
|
2018-01-29 22:43:55 +01:00
|
|
|
}
|
|
|
|
|
2020-12-08 21:29:20 +01:00
|
|
|
static MapAction *findMapAction(const QList<QAction*> &mapActions,
|
|
|
|
const Map *map)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < mapActions.count(); i++) {
|
|
|
|
const Map *m = mapActions.at(i)->data().value<Map*>();
|
|
|
|
if (map->path() == m->path())
|
|
|
|
return static_cast<MapAction*>(mapActions.at(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-03-20 09:59:03 +01:00
|
|
|
bool GUI::loadMapNode(const TreeNode<Map*> &node, MapAction *&action,
|
|
|
|
bool silent, const QList<QAction*> &existingActions)
|
2018-01-29 22:43:55 +01:00
|
|
|
{
|
2020-12-09 23:07:05 +01:00
|
|
|
bool valid = false;
|
2020-12-08 21:29:20 +01:00
|
|
|
|
2021-03-20 09:59:03 +01:00
|
|
|
action = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < node.childs().size(); i++)
|
|
|
|
valid = loadMapNode(node.childs().at(i), action, silent, existingActions);
|
|
|
|
|
|
|
|
for (int i = 0; i < node.items().size(); i++) {
|
|
|
|
Map *map = node.items().at(i);
|
2020-12-08 21:29:20 +01:00
|
|
|
MapAction *a;
|
|
|
|
|
2020-12-09 23:07:05 +01:00
|
|
|
if (!(a = findMapAction(existingActions, map))) {
|
|
|
|
if (!map->isValid()) {
|
|
|
|
if (!silent)
|
|
|
|
QMessageBox::critical(this, APP_NAME,
|
|
|
|
tr("Error loading map:") + "\n\n" + map->path() + "\n\n"
|
|
|
|
+ map->errorString());
|
|
|
|
delete map;
|
|
|
|
} else {
|
|
|
|
valid = true;
|
2021-03-21 20:23:20 +01:00
|
|
|
a = new MapAction(map, _mapsActionGroup);
|
2020-12-09 23:07:05 +01:00
|
|
|
_mapMenu->insertAction(_mapsEnd, a);
|
|
|
|
|
|
|
|
if (map->isReady()) {
|
2021-03-20 09:59:03 +01:00
|
|
|
action = a;
|
2020-12-09 23:07:05 +01:00
|
|
|
_showMapAction->setEnabled(true);
|
|
|
|
_clearMapCacheAction->setEnabled(true);
|
|
|
|
} else
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(a, &MapAction::loaded, this, &GUI::mapLoaded);
|
2020-12-09 23:07:05 +01:00
|
|
|
}
|
2020-12-08 21:29:20 +01:00
|
|
|
} else {
|
2020-12-09 23:07:05 +01:00
|
|
|
valid = true;
|
2020-12-08 21:29:20 +01:00
|
|
|
map = a->data().value<Map*>();
|
|
|
|
if (map->isReady())
|
2021-03-20 09:59:03 +01:00
|
|
|
action = a;
|
2020-12-08 21:29:20 +01:00
|
|
|
}
|
2020-03-17 21:06:51 +01:00
|
|
|
}
|
|
|
|
|
2020-12-09 23:07:05 +01:00
|
|
|
return valid;
|
2020-03-17 21:06:51 +01:00
|
|
|
}
|
|
|
|
|
2021-03-20 09:59:03 +01:00
|
|
|
bool GUI::loadMap(const QString &fileName, MapAction *&action, bool silent)
|
|
|
|
{
|
2021-06-17 21:58:25 +02:00
|
|
|
TreeNode<Map*> maps(MapList::loadMaps(fileName,
|
|
|
|
CRS::projection(_options.inputProjection)));
|
2021-03-20 09:59:03 +01:00
|
|
|
QList<QAction*> existingActions(_mapsActionGroup->actions());
|
|
|
|
|
|
|
|
return loadMapNode(maps, action, silent, existingActions);
|
|
|
|
}
|
|
|
|
|
2020-03-17 21:06:51 +01:00
|
|
|
void GUI::mapLoaded()
|
|
|
|
{
|
|
|
|
MapAction *action = static_cast<MapAction*>(QObject::sender());
|
|
|
|
Map *map = action->data().value<Map*>();
|
|
|
|
|
|
|
|
if (map->isValid()) {
|
|
|
|
action->trigger();
|
2017-04-21 21:15:58 +02:00
|
|
|
_showMapAction->setEnabled(true);
|
|
|
|
_clearMapCacheAction->setEnabled(true);
|
|
|
|
} else {
|
2020-12-09 23:07:05 +01:00
|
|
|
QString error = tr("Error loading map:") + "\n\n" + map->path() + "\n\n"
|
|
|
|
+ map->errorString();
|
|
|
|
QMessageBox::critical(this, APP_NAME, error);
|
|
|
|
action->deleteLater();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-10 01:09:23 +01:00
|
|
|
void GUI::mapLoadedDir()
|
2020-12-09 23:07:05 +01:00
|
|
|
{
|
|
|
|
MapAction *action = static_cast<MapAction*>(QObject::sender());
|
|
|
|
Map *map = action->data().value<Map*>();
|
|
|
|
|
|
|
|
if (map->isValid()) {
|
|
|
|
_showMapAction->setEnabled(true);
|
|
|
|
_clearMapCacheAction->setEnabled(true);
|
2020-12-10 01:09:23 +01:00
|
|
|
QList<MapAction*> actions;
|
|
|
|
actions.append(action);
|
|
|
|
_mapView->loadMaps(actions);
|
2020-12-09 23:07:05 +01:00
|
|
|
} else {
|
|
|
|
QString error = tr("Error loading map:") + "\n\n" + map->path() + "\n\n"
|
2020-12-08 00:58:01 +01:00
|
|
|
+ map->errorString();
|
2017-04-21 21:15:58 +02:00
|
|
|
QMessageBox::critical(this, APP_NAME, error);
|
2020-03-17 21:06:51 +01:00
|
|
|
action->deleteLater();
|
2017-04-21 21:15:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-20 09:59:03 +01:00
|
|
|
void GUI::loadMapDirNode(const TreeNode<Map *> &node, QList<MapAction*> &actions,
|
|
|
|
QMenu *menu, const QList<QAction*> &existingActions)
|
2020-12-02 23:58:11 +01:00
|
|
|
{
|
2021-03-20 09:59:03 +01:00
|
|
|
for (int i = 0; i < node.childs().size(); i++) {
|
|
|
|
QMenu *cm = new QMenu(node.childs().at(i).name(), menu);
|
|
|
|
menu->addMenu(cm);
|
|
|
|
loadMapDirNode(node.childs().at(i), actions, cm, existingActions);
|
|
|
|
}
|
2020-12-02 23:58:11 +01:00
|
|
|
|
2021-03-20 09:59:03 +01:00
|
|
|
for (int i = 0; i < node.items().size(); i++) {
|
|
|
|
Map *map = node.items().at(i);
|
2020-12-09 23:07:05 +01:00
|
|
|
MapAction *a;
|
2020-12-08 21:29:20 +01:00
|
|
|
|
2020-12-09 23:07:05 +01:00
|
|
|
if (!(a = findMapAction(existingActions, map))) {
|
|
|
|
if (!map->isValid()) {
|
|
|
|
QMessageBox::critical(this, APP_NAME, tr("Error loading map:")
|
|
|
|
+ "\n\n" + map->path() + "\n\n" + map->errorString());
|
|
|
|
delete map;
|
|
|
|
} else {
|
2021-03-21 20:23:20 +01:00
|
|
|
a = new MapAction(map, _mapsActionGroup);
|
2020-12-09 23:07:05 +01:00
|
|
|
menu->addAction(a);
|
|
|
|
|
|
|
|
if (map->isReady()) {
|
|
|
|
_showMapAction->setEnabled(true);
|
|
|
|
_clearMapCacheAction->setEnabled(true);
|
2020-12-10 01:09:23 +01:00
|
|
|
actions.append(a);
|
2020-12-09 23:07:05 +01:00
|
|
|
} else
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(a, &MapAction::loaded, this, &GUI::mapLoadedDir);
|
2021-03-20 09:59:03 +01:00
|
|
|
|
2021-07-11 12:54:45 +02:00
|
|
|
_areaCount++;
|
|
|
|
}
|
2020-12-10 01:09:23 +01:00
|
|
|
} else {
|
|
|
|
map = a->data().value<Map*>();
|
|
|
|
if (map->isReady())
|
|
|
|
actions.append(a);
|
|
|
|
}
|
2020-12-08 21:29:20 +01:00
|
|
|
}
|
2021-03-20 09:59:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::loadMapDir()
|
|
|
|
{
|
|
|
|
QString dir(QFileDialog::getExistingDirectory(this,
|
|
|
|
tr("Select map directory"), _mapDir, QFileDialog::ShowDirsOnly));
|
|
|
|
if (dir.isEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
QFileInfo fi(dir);
|
2021-06-17 21:58:25 +02:00
|
|
|
TreeNode<Map*> maps(MapList::loadMaps(dir,
|
|
|
|
CRS::projection(_options.inputProjection)));
|
2021-03-20 09:59:03 +01:00
|
|
|
QList<QAction*> existingActions(_mapsActionGroup->actions());
|
|
|
|
QList<MapAction*> actions;
|
|
|
|
QMenu *menu = new QMenu(maps.name());
|
|
|
|
|
|
|
|
loadMapDirNode(maps, actions, menu, existingActions);
|
2020-12-08 21:29:20 +01:00
|
|
|
|
2020-12-09 23:07:05 +01:00
|
|
|
_mapView->loadMaps(actions);
|
|
|
|
|
2020-12-08 21:29:20 +01:00
|
|
|
if (menu->isEmpty())
|
|
|
|
delete menu;
|
2021-03-20 09:59:03 +01:00
|
|
|
else
|
2020-12-08 21:29:20 +01:00
|
|
|
_mapMenu->insertMenu(_mapsEnd, menu);
|
2020-12-02 23:58:11 +01:00
|
|
|
|
|
|
|
_mapDir = fi.absolutePath();
|
|
|
|
_fileActionGroup->setEnabled(true);
|
|
|
|
_reloadFileAction->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::clearMapCache()
|
|
|
|
{
|
|
|
|
if (QMessageBox::question(this, APP_NAME,
|
|
|
|
tr("Clear the map tile cache?")) == QMessageBox::Yes)
|
|
|
|
_mapView->clearMapCache();
|
|
|
|
}
|
|
|
|
|
2015-10-20 22:18:41 +02:00
|
|
|
void GUI::updateStatusBarInfo()
|
2015-10-17 12:08:30 +02:00
|
|
|
{
|
2016-08-10 21:17:12 +02:00
|
|
|
if (_files.count() == 0)
|
2017-01-24 18:23:56 +01:00
|
|
|
_fileNameLabel->setText(tr("No files loaded"));
|
2016-08-10 21:17:12 +02:00
|
|
|
else if (_files.count() == 1)
|
2015-10-20 22:18:41 +02:00
|
|
|
_fileNameLabel->setText(_files.at(0));
|
2015-10-17 12:08:30 +02:00
|
|
|
else
|
2016-10-29 12:22:28 +02:00
|
|
|
_fileNameLabel->setText(tr("%n files", "", _files.count()));
|
2015-10-17 12:08:30 +02:00
|
|
|
|
2017-01-31 09:37:01 +01:00
|
|
|
if (distance() > 0)
|
|
|
|
_distanceLabel->setText(Format::distance(distance(), units()));
|
2016-08-10 21:17:12 +02:00
|
|
|
else
|
|
|
|
_distanceLabel->clear();
|
|
|
|
|
2017-02-05 16:01:54 +01:00
|
|
|
if (time() > 0) {
|
2017-02-12 20:11:36 +01:00
|
|
|
if (_movingTimeAction->isChecked()) {
|
|
|
|
_timeLabel->setText(Format::timeSpan(movingTime())
|
|
|
|
+ "<sub>M</sub>");
|
|
|
|
_timeLabel->setToolTip(Format::timeSpan(time()));
|
|
|
|
} else {
|
2017-02-12 19:57:55 +01:00
|
|
|
_timeLabel->setText(Format::timeSpan(time()));
|
2017-03-18 01:30:31 +01:00
|
|
|
_timeLabel->setToolTip(Format::timeSpan(movingTime())
|
|
|
|
+ "<sub>M</sub>");
|
2017-02-12 20:11:36 +01:00
|
|
|
}
|
|
|
|
} else {
|
2016-08-10 21:17:12 +02:00
|
|
|
_timeLabel->clear();
|
2017-02-12 20:11:36 +01:00
|
|
|
_timeLabel->setToolTip(QString());
|
|
|
|
}
|
2015-10-17 12:08:30 +02:00
|
|
|
}
|
|
|
|
|
2016-04-19 08:51:11 +02:00
|
|
|
void GUI::updateWindowTitle()
|
|
|
|
{
|
|
|
|
if (_files.count() == 1)
|
2017-02-02 20:06:17 +01:00
|
|
|
setWindowTitle(QFileInfo(_files.at(0)).fileName() + " - " + APP_NAME);
|
2016-04-19 08:51:11 +02:00
|
|
|
else
|
|
|
|
setWindowTitle(APP_NAME);
|
|
|
|
}
|
|
|
|
|
2021-03-21 20:23:20 +01:00
|
|
|
void GUI::mapChanged(QAction *action)
|
2015-11-23 02:37:08 +01:00
|
|
|
{
|
2021-03-21 20:23:20 +01:00
|
|
|
_map = action->data().value<Map*>();
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->setMap(_map);
|
2015-11-23 02:37:08 +01:00
|
|
|
}
|
|
|
|
|
2016-04-08 22:33:19 +02:00
|
|
|
void GUI::nextMap()
|
|
|
|
{
|
2020-03-17 21:06:51 +01:00
|
|
|
QAction *checked = _mapsActionGroup->checkedAction();
|
|
|
|
if (!checked)
|
2016-04-08 22:33:19 +02:00
|
|
|
return;
|
2017-03-18 01:30:31 +01:00
|
|
|
|
2020-12-08 00:58:01 +01:00
|
|
|
QList<QAction*> maps(_mapsActionGroup->actions());
|
2020-03-17 21:06:51 +01:00
|
|
|
for (int i = 1; i < maps.size(); i++) {
|
|
|
|
int next = (maps.indexOf(checked) + i) % maps.count();
|
|
|
|
if (maps.at(next)->isEnabled()) {
|
|
|
|
maps.at(next)->trigger();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-04-08 22:33:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::prevMap()
|
|
|
|
{
|
2020-03-17 21:06:51 +01:00
|
|
|
QAction *checked = _mapsActionGroup->checkedAction();
|
|
|
|
if (!checked)
|
2016-04-08 22:33:19 +02:00
|
|
|
return;
|
2017-03-18 01:30:31 +01:00
|
|
|
|
2020-12-08 00:58:01 +01:00
|
|
|
QList<QAction*> maps(_mapsActionGroup->actions());
|
2020-03-17 21:06:51 +01:00
|
|
|
for (int i = 1; i < maps.size(); i++) {
|
|
|
|
int prev = (maps.indexOf(checked) + maps.count() - i) % maps.count();
|
|
|
|
if (maps.at(prev)->isEnabled()) {
|
|
|
|
maps.at(prev)->trigger();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-04-08 22:33:19 +02:00
|
|
|
}
|
|
|
|
|
2021-03-21 20:23:20 +01:00
|
|
|
void GUI::poiFileChecked(QAction *action)
|
2016-03-05 18:01:13 +01:00
|
|
|
{
|
2021-03-21 20:23:20 +01:00
|
|
|
_poi->enableFile(action->data().value<QString>(), action->isChecked());
|
2016-03-05 18:01:13 +01:00
|
|
|
}
|
|
|
|
|
2021-03-21 22:40:39 +01:00
|
|
|
void GUI::selectAllPOIs()
|
|
|
|
{
|
|
|
|
QList<QAction*> actions(_poisActionGroup->actions());
|
|
|
|
for (int i = 0; i < actions.size(); i++) {
|
|
|
|
POIAction *a = static_cast<POIAction*>(actions.at(i));
|
|
|
|
if (_poi->enableFile(a->data().toString(), true))
|
|
|
|
a->setChecked(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::unselectAllPOIs()
|
|
|
|
{
|
|
|
|
QList<QAction*> actions(_poisActionGroup->actions());
|
|
|
|
for (int i = 0; i < actions.size(); i++) {
|
|
|
|
POIAction *a = static_cast<POIAction*>(actions.at(i));
|
|
|
|
if (_poi->enableFile(a->data().toString(), false))
|
|
|
|
a->setChecked(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
void GUI::graphChanged(int index)
|
|
|
|
{
|
2016-03-24 20:50:11 +01:00
|
|
|
if (index < 0)
|
|
|
|
return;
|
|
|
|
|
2016-09-27 01:27:38 +02:00
|
|
|
GraphTab *gt = static_cast<GraphTab*>(_graphTabWidget->widget(index));
|
2021-02-23 22:55:22 +01:00
|
|
|
|
2021-02-23 23:12:14 +01:00
|
|
|
_mapView->setGraph(_tabs.indexOf(gt));
|
2021-01-17 16:02:37 +01:00
|
|
|
|
2021-03-06 12:19:18 +01:00
|
|
|
if (_lastTab)
|
|
|
|
gt->setSliderPosition(_lastTab->sliderPosition());
|
|
|
|
_lastTab = gt;
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2015-12-18 22:21:11 +01:00
|
|
|
void GUI::updateNavigationActions()
|
|
|
|
{
|
2021-05-27 22:08:40 +02:00
|
|
|
_lastAction->setEnabled(!_browser->isLast());
|
|
|
|
_nextAction->setEnabled(!_browser->isLast());
|
|
|
|
_firstAction->setEnabled(!_browser->isFirst());
|
|
|
|
_prevAction->setEnabled(!_browser->isFirst());
|
2015-12-18 22:21:11 +01:00
|
|
|
}
|
|
|
|
|
2018-05-04 19:36:37 +02:00
|
|
|
bool GUI::updateGraphTabs()
|
2016-03-23 09:38:22 +01:00
|
|
|
{
|
2016-03-24 20:50:11 +01:00
|
|
|
int index;
|
2016-06-24 00:55:44 +02:00
|
|
|
GraphTab *tab;
|
2018-05-04 19:36:37 +02:00
|
|
|
bool hidden = _graphTabWidget->isHidden();
|
2016-03-24 20:50:11 +01:00
|
|
|
|
2016-05-13 18:48:42 +02:00
|
|
|
for (int i = 0; i < _tabs.size(); i++) {
|
2016-06-24 00:55:44 +02:00
|
|
|
tab = _tabs.at(i);
|
2017-10-04 23:15:39 +02:00
|
|
|
if (tab->isEmpty() && (index = _graphTabWidget->indexOf(tab)) >= 0)
|
2016-09-27 01:27:38 +02:00
|
|
|
_graphTabWidget->removeTab(index);
|
2016-03-23 09:38:22 +01:00
|
|
|
}
|
2016-03-24 20:50:11 +01:00
|
|
|
|
2016-05-13 18:48:42 +02:00
|
|
|
for (int i = 0; i < _tabs.size(); i++) {
|
2016-06-24 00:55:44 +02:00
|
|
|
tab = _tabs.at(i);
|
2017-10-04 23:15:39 +02:00
|
|
|
if (!tab->isEmpty() && _graphTabWidget->indexOf(tab) < 0)
|
2016-09-27 01:27:38 +02:00
|
|
|
_graphTabWidget->insertTab(i, tab, _tabs.at(i)->label());
|
2016-03-24 20:50:11 +01:00
|
|
|
}
|
|
|
|
|
2017-12-01 00:22:16 +01:00
|
|
|
if (_graphTabWidget->count() &&
|
|
|
|
((_showTracksAction->isChecked() && _trackCount)
|
|
|
|
|| (_showRoutesAction->isChecked() && _routeCount))) {
|
2016-04-05 09:10:19 +02:00
|
|
|
if (_showGraphsAction->isChecked())
|
2016-09-27 01:27:38 +02:00
|
|
|
_graphTabWidget->setHidden(false);
|
2016-04-05 09:10:19 +02:00
|
|
|
_showGraphsAction->setEnabled(true);
|
|
|
|
} else {
|
2016-09-27 01:27:38 +02:00
|
|
|
_graphTabWidget->setHidden(true);
|
2016-04-05 09:10:19 +02:00
|
|
|
_showGraphsAction->setEnabled(false);
|
2016-03-24 20:50:11 +01:00
|
|
|
}
|
2018-05-04 19:36:37 +02:00
|
|
|
|
|
|
|
return (hidden != _graphTabWidget->isHidden());
|
2016-03-23 09:38:22 +01:00
|
|
|
}
|
|
|
|
|
2017-02-12 19:57:55 +01:00
|
|
|
void GUI::setTimeType(TimeType type)
|
|
|
|
{
|
|
|
|
for (int i = 0; i <_tabs.count(); i++)
|
|
|
|
_tabs.at(i)->setTimeType(type);
|
|
|
|
|
|
|
|
updateStatusBarInfo();
|
|
|
|
}
|
|
|
|
|
2016-09-21 23:48:11 +02:00
|
|
|
void GUI::setUnits(Units units)
|
2015-12-19 20:23:07 +01:00
|
|
|
{
|
2020-09-27 00:34:38 +02:00
|
|
|
_units = units;
|
2016-12-07 21:38:36 +01:00
|
|
|
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->setUnits(units);
|
2016-06-24 00:55:44 +02:00
|
|
|
for (int i = 0; i <_tabs.count(); i++)
|
2016-09-21 23:48:11 +02:00
|
|
|
_tabs.at(i)->setUnits(units);
|
2015-12-19 20:23:07 +01:00
|
|
|
updateStatusBarInfo();
|
|
|
|
}
|
|
|
|
|
2018-02-11 20:39:39 +01:00
|
|
|
void GUI::setCoordinatesFormat(CoordinatesFormat format)
|
|
|
|
{
|
|
|
|
_mapView->setCoordinatesFormat(format);
|
|
|
|
}
|
|
|
|
|
2016-09-21 23:48:11 +02:00
|
|
|
void GUI::setGraphType(GraphType type)
|
2015-12-19 20:23:07 +01:00
|
|
|
{
|
2021-01-17 16:02:37 +01:00
|
|
|
for (int i = 0; i <_tabs.count(); i++)
|
2016-09-21 23:48:11 +02:00
|
|
|
_tabs.at(i)->setGraphType(type);
|
2016-09-19 00:56:10 +02:00
|
|
|
}
|
|
|
|
|
2015-12-18 22:21:11 +01:00
|
|
|
void GUI::next()
|
|
|
|
{
|
|
|
|
QString file = _browser->next();
|
|
|
|
if (file.isNull())
|
|
|
|
return;
|
|
|
|
|
2016-03-23 20:56:39 +01:00
|
|
|
closeFiles();
|
2015-12-18 22:21:11 +01:00
|
|
|
openFile(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::prev()
|
|
|
|
{
|
|
|
|
QString file = _browser->prev();
|
|
|
|
if (file.isNull())
|
|
|
|
return;
|
|
|
|
|
2016-03-23 20:56:39 +01:00
|
|
|
closeFiles();
|
2015-12-18 22:21:11 +01:00
|
|
|
openFile(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::last()
|
|
|
|
{
|
|
|
|
QString file = _browser->last();
|
|
|
|
if (file.isNull())
|
|
|
|
return;
|
|
|
|
|
2016-03-23 20:56:39 +01:00
|
|
|
closeFiles();
|
2015-12-18 22:21:11 +01:00
|
|
|
openFile(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::first()
|
|
|
|
{
|
|
|
|
QString file = _browser->first();
|
|
|
|
if (file.isNull())
|
|
|
|
return;
|
|
|
|
|
2016-03-23 20:56:39 +01:00
|
|
|
closeFiles();
|
2015-12-18 22:21:11 +01:00
|
|
|
openFile(file);
|
|
|
|
}
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
void GUI::keyPressEvent(QKeyEvent *event)
|
|
|
|
{
|
2015-10-20 22:18:41 +02:00
|
|
|
QString file;
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2015-12-18 22:21:11 +01:00
|
|
|
switch (event->key()) {
|
|
|
|
case PREV_KEY:
|
|
|
|
file = _browser->prev();
|
|
|
|
break;
|
|
|
|
case NEXT_KEY:
|
|
|
|
file = _browser->next();
|
|
|
|
break;
|
|
|
|
case FIRST_KEY:
|
|
|
|
file = _browser->first();
|
|
|
|
break;
|
|
|
|
case LAST_KEY:
|
|
|
|
file = _browser->last();
|
|
|
|
break;
|
2016-04-11 22:08:00 +02:00
|
|
|
|
2017-09-26 07:46:46 +02:00
|
|
|
case TOGGLE_GRAPH_TYPE_KEY:
|
|
|
|
if (_timeGraphAction->isChecked())
|
2018-02-15 01:44:03 +01:00
|
|
|
_distanceGraphAction->trigger();
|
2017-09-26 07:46:46 +02:00
|
|
|
else
|
2018-02-15 01:44:03 +01:00
|
|
|
_timeGraphAction->trigger();
|
2017-09-26 07:46:46 +02:00
|
|
|
break;
|
|
|
|
case TOGGLE_TIME_TYPE_KEY:
|
|
|
|
if (_movingTimeAction->isChecked())
|
2018-02-15 01:44:03 +01:00
|
|
|
_totalTimeAction->trigger();
|
2017-09-26 07:46:46 +02:00
|
|
|
else
|
2018-02-15 01:44:03 +01:00
|
|
|
_movingTimeAction->trigger();
|
2017-09-26 07:46:46 +02:00
|
|
|
break;
|
2021-02-12 22:41:38 +01:00
|
|
|
case TOGGLE_MARKER_INFO_KEY:
|
|
|
|
if (_showMarkerDateAction->isChecked())
|
|
|
|
_showMarkerCoordinatesAction->trigger();
|
|
|
|
else if (_showMarkerCoordinatesAction->isChecked())
|
|
|
|
_showMarkerDateAction->trigger();
|
|
|
|
break;
|
2016-04-11 22:08:00 +02:00
|
|
|
case Qt::Key_Escape:
|
|
|
|
if (_fullscreenAction->isChecked()) {
|
|
|
|
_fullscreenAction->setChecked(false);
|
|
|
|
showFullscreen(false);
|
2017-04-06 19:54:50 +02:00
|
|
|
return;
|
2016-04-11 22:08:00 +02:00
|
|
|
}
|
|
|
|
break;
|
2015-12-18 22:21:11 +01:00
|
|
|
}
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2015-10-20 22:18:41 +02:00
|
|
|
if (!file.isNull()) {
|
|
|
|
if (!(event->modifiers() & MODIFIER))
|
2016-03-23 20:56:39 +01:00
|
|
|
closeFiles();
|
2015-10-20 22:18:41 +02:00
|
|
|
openFile(file);
|
2017-04-06 19:54:50 +02:00
|
|
|
return;
|
2015-10-20 22:18:41 +02:00
|
|
|
}
|
2017-04-05 22:53:25 +02:00
|
|
|
|
|
|
|
QMainWindow::keyPressEvent(event);
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
2016-04-26 09:39:16 +02:00
|
|
|
|
|
|
|
void GUI::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
|
|
|
writeSettings();
|
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
|
2016-10-04 10:16:46 +02:00
|
|
|
void GUI::dragEnterEvent(QDragEnterEvent *event)
|
|
|
|
{
|
|
|
|
if (!event->mimeData()->hasUrls())
|
|
|
|
return;
|
|
|
|
if (event->proposedAction() != Qt::CopyAction)
|
|
|
|
return;
|
|
|
|
|
|
|
|
QList<QUrl> urls = event->mimeData()->urls();
|
|
|
|
for (int i = 0; i < urls.size(); i++)
|
|
|
|
if (!urls.at(i).isLocalFile())
|
|
|
|
return;
|
|
|
|
|
|
|
|
event->acceptProposedAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::dropEvent(QDropEvent *event)
|
|
|
|
{
|
2020-12-08 01:12:39 +01:00
|
|
|
MapAction *lastReady = 0;
|
|
|
|
QList<QUrl> urls(event->mimeData()->urls());
|
|
|
|
|
|
|
|
for (int i = 0; i < urls.size(); i++) {
|
|
|
|
QString file(urls.at(i).toLocalFile());
|
|
|
|
|
|
|
|
if (!openFile(file, true)) {
|
|
|
|
MapAction *a;
|
|
|
|
if (!loadMap(file, a, true))
|
|
|
|
openFile(file, false);
|
|
|
|
else {
|
|
|
|
if (a)
|
|
|
|
lastReady = a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lastReady)
|
|
|
|
lastReady->trigger();
|
2019-02-18 22:33:18 +01:00
|
|
|
|
|
|
|
event->acceptProposedAction();
|
2016-10-04 10:16:46 +02:00
|
|
|
}
|
|
|
|
|
2016-04-26 09:39:16 +02:00
|
|
|
void GUI::writeSettings()
|
|
|
|
{
|
2018-11-02 20:01:19 +01:00
|
|
|
QSettings settings(qApp->applicationName(), qApp->applicationName());
|
2016-12-06 01:48:26 +01:00
|
|
|
settings.clear();
|
2016-04-26 09:39:16 +02:00
|
|
|
|
2016-04-28 08:49:06 +02:00
|
|
|
settings.beginGroup(WINDOW_SETTINGS_GROUP);
|
2021-02-19 19:31:54 +01:00
|
|
|
if (!_windowStates.isEmpty() && !_windowGeometries.isEmpty()) {
|
2019-02-18 22:33:18 +01:00
|
|
|
settings.setValue(WINDOW_STATE_SETTING, _windowStates.first());
|
2021-02-19 19:31:54 +01:00
|
|
|
settings.setValue(WINDOW_GEOMETRY_SETTING, _windowGeometries.first());
|
|
|
|
} else {
|
|
|
|
settings.setValue(WINDOW_STATE_SETTING, saveState());
|
|
|
|
settings.setValue(WINDOW_GEOMETRY_SETTING, saveGeometry());
|
|
|
|
}
|
2016-04-26 09:39:16 +02:00
|
|
|
settings.endGroup();
|
|
|
|
|
2016-04-28 08:49:06 +02:00
|
|
|
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
|
2017-02-12 19:57:55 +01:00
|
|
|
if ((_movingTimeAction->isChecked() ? Moving : Total) !=
|
|
|
|
TIME_TYPE_DEFAULT)
|
|
|
|
settings.setValue(TIME_TYPE_SETTING, _movingTimeAction->isChecked()
|
2018-02-11 20:39:39 +01:00
|
|
|
? Moving : Total);
|
2018-02-11 23:51:57 +01:00
|
|
|
Units units = _imperialUnitsAction->isChecked() ? Imperial
|
|
|
|
: _nauticalUnitsAction->isChecked() ? Nautical : Metric;
|
|
|
|
if (units != UNITS_DEFAULT)
|
|
|
|
settings.setValue(UNITS_SETTING, units);
|
2020-01-23 23:19:32 +01:00
|
|
|
CoordinatesFormat format = _dmsAction->isChecked() ? DMS
|
2018-02-11 20:39:39 +01:00
|
|
|
: _degreesMinutesAction->isChecked() ? DegreesMinutes : DecimalDegrees;
|
2018-02-11 20:49:26 +01:00
|
|
|
if (format != COORDINATES_DEFAULT)
|
|
|
|
settings.setValue(COORDINATES_SETTING, format);
|
2016-12-06 01:48:26 +01:00
|
|
|
if (_showToolbarsAction->isChecked() != SHOW_TOOLBARS_DEFAULT)
|
|
|
|
settings.setValue(SHOW_TOOLBARS_SETTING,
|
|
|
|
_showToolbarsAction->isChecked());
|
2016-04-26 09:39:16 +02:00
|
|
|
settings.endGroup();
|
2016-04-26 20:55:29 +02:00
|
|
|
|
2016-04-28 08:49:06 +02:00
|
|
|
settings.beginGroup(MAP_SETTINGS_GROUP);
|
2017-03-18 01:30:31 +01:00
|
|
|
settings.setValue(CURRENT_MAP_SETTING, _map->name());
|
2016-12-06 01:48:26 +01:00
|
|
|
if (_showMapAction->isChecked() != SHOW_MAP_DEFAULT)
|
|
|
|
settings.setValue(SHOW_MAP_SETTING, _showMapAction->isChecked());
|
2019-02-17 20:20:20 +01:00
|
|
|
if (_showCoordinatesAction->isChecked() != SHOW_COORDINATES_DEFAULT)
|
2019-02-18 22:36:45 +01:00
|
|
|
settings.setValue(SHOW_COORDINATES_SETTING,
|
|
|
|
_showCoordinatesAction->isChecked());
|
2016-04-26 20:55:29 +02:00
|
|
|
settings.endGroup();
|
|
|
|
|
2016-09-19 00:56:10 +02:00
|
|
|
settings.beginGroup(GRAPH_SETTINGS_GROUP);
|
2016-12-06 01:48:26 +01:00
|
|
|
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());
|
2017-09-29 11:43:09 +02:00
|
|
|
if (_showGraphSliderInfoAction->isChecked()
|
|
|
|
!= SHOW_GRAPH_SLIDER_INFO_DEFAULT)
|
|
|
|
settings.setValue(SHOW_GRAPH_SLIDER_INFO_SETTING,
|
|
|
|
_showGraphSliderInfoAction->isChecked());
|
2016-09-19 00:56:10 +02:00
|
|
|
settings.endGroup();
|
|
|
|
|
2016-04-28 08:49:06 +02:00
|
|
|
settings.beginGroup(POI_SETTINGS_GROUP);
|
2016-12-06 01:48:26 +01:00
|
|
|
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());
|
2021-05-09 22:36:37 +02:00
|
|
|
if (_showPOILabelsAction->isChecked() != SHOW_POI_LABELS_DEFAULT)
|
|
|
|
settings.setValue(SHOW_POI_LABELS_SETTING,
|
|
|
|
_showPOILabelsAction->isChecked());
|
2016-04-28 08:49:06 +02:00
|
|
|
|
2016-12-06 21:02:44 +01:00
|
|
|
int j = 0;
|
2021-03-21 20:23:20 +01:00
|
|
|
QList<QAction*> poiActions(_poisActionGroup->actions());
|
|
|
|
for (int i = 0; i < poiActions.count(); i++) {
|
|
|
|
POIAction *a = static_cast<POIAction*>(poiActions.at(i));
|
|
|
|
if (!a->isChecked()) {
|
2016-12-06 21:02:44 +01:00
|
|
|
if (j == 0)
|
|
|
|
settings.beginWriteArray(DISABLED_POI_FILE_SETTINGS_PREFIX);
|
2016-04-28 08:49:06 +02:00
|
|
|
settings.setArrayIndex(j++);
|
2021-03-21 20:23:20 +01:00
|
|
|
settings.setValue(DISABLED_POI_FILE_SETTING, a->data().toString());
|
2016-04-28 08:49:06 +02:00
|
|
|
}
|
|
|
|
}
|
2016-12-06 21:02:44 +01:00
|
|
|
if (j != 0)
|
|
|
|
settings.endArray();
|
2016-04-26 20:55:29 +02:00
|
|
|
settings.endGroup();
|
2016-08-09 01:16:19 +02:00
|
|
|
|
|
|
|
settings.beginGroup(DATA_SETTINGS_GROUP);
|
2016-12-06 01:48:26 +01:00
|
|
|
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());
|
2019-01-31 01:46:53 +01:00
|
|
|
if (_showAreasAction->isChecked() != SHOW_AREAS_DEFAULT)
|
|
|
|
settings.setValue(SHOW_AREAS_SETTING, _showAreasAction->isChecked());
|
2016-12-06 01:48:26 +01:00
|
|
|
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());
|
2019-05-23 08:44:55 +02:00
|
|
|
if (_showTicksAction->isChecked() != SHOW_TICKS_DEFAULT)
|
|
|
|
settings.setValue(SHOW_TICKS_SETTING,
|
|
|
|
_showTicksAction->isChecked());
|
2021-02-12 22:41:38 +01:00
|
|
|
bool sm = _showMarkersAction->isChecked()
|
|
|
|
| _showMarkerDateAction->isChecked()
|
|
|
|
| _showMarkerCoordinatesAction->isChecked();
|
|
|
|
if (sm != SHOW_MARKERS_DEFAULT)
|
|
|
|
settings.setValue(SHOW_MARKERS_SETTING, sm);
|
|
|
|
if (_showMarkerDateAction->isChecked()
|
|
|
|
&& SHOW_MARKER_INFO_DEFAULT != MarkerInfoItem::Date)
|
|
|
|
settings.setValue(SHOW_MARKER_INFO_SETTING, MarkerInfoItem::Date);
|
|
|
|
else if (_showMarkerCoordinatesAction->isChecked()
|
|
|
|
&& SHOW_MARKER_INFO_DEFAULT != MarkerInfoItem::Position)
|
|
|
|
settings.setValue(SHOW_MARKER_INFO_SETTING, MarkerInfoItem::Position);
|
2016-12-06 01:48:26 +01:00
|
|
|
settings.endGroup();
|
|
|
|
|
2020-09-27 00:34:38 +02:00
|
|
|
settings.beginGroup(PDF_EXPORT_SETTINGS_GROUP);
|
|
|
|
if (_pdfExport.orientation != PAPER_ORIENTATION_DEFAULT)
|
|
|
|
settings.setValue(PAPER_ORIENTATION_SETTING, _pdfExport.orientation);
|
|
|
|
if (_pdfExport.resolution != RESOLUTION_DEFAULT)
|
|
|
|
settings.setValue(RESOLUTION_SETTING, _pdfExport.resolution);
|
|
|
|
if (_pdfExport.paperSize != PAPER_SIZE_DEFAULT)
|
|
|
|
settings.setValue(PAPER_SIZE_SETTING, _pdfExport.paperSize);
|
|
|
|
if (_pdfExport.margins.left() != PDF_MARGIN_LEFT_DEFAULT)
|
|
|
|
settings.setValue(PDF_MARGIN_LEFT_SETTING, _pdfExport.margins.left());
|
|
|
|
if (_pdfExport.margins.top() != PDF_MARGIN_TOP_DEFAULT)
|
|
|
|
settings.setValue(PDF_MARGIN_TOP_SETTING, _pdfExport.margins.top());
|
|
|
|
if (_pdfExport.margins.right() != PDF_MARGIN_RIGHT_DEFAULT)
|
|
|
|
settings.setValue(PDF_MARGIN_RIGHT_SETTING, _pdfExport.margins.right());
|
|
|
|
if (_pdfExport.margins.bottom() != PDF_MARGIN_BOTTOM_DEFAULT)
|
|
|
|
settings.setValue(PDF_MARGIN_BOTTOM_SETTING, _pdfExport.margins.bottom());
|
|
|
|
if (_pdfExport.fileName != PDF_FILENAME_DEFAULT)
|
|
|
|
settings.setValue(PDF_FILENAME_SETTING, _pdfExport.fileName);
|
|
|
|
settings.endGroup();
|
|
|
|
|
|
|
|
settings.beginGroup(PNG_EXPORT_SETTINGS_GROUP);
|
|
|
|
if (_pngExport.size.width() != PNG_WIDTH_DEFAULT)
|
|
|
|
settings.setValue(PNG_WIDTH_SETTING, _pngExport.size.width());
|
|
|
|
if (_pngExport.size.height() != PNG_HEIGHT_DEFAULT)
|
|
|
|
settings.setValue(PNG_HEIGHT_SETTING, _pngExport.size.height());
|
|
|
|
if (_pngExport.margins.left() != PNG_MARGIN_LEFT_DEFAULT)
|
|
|
|
settings.setValue(PNG_MARGIN_LEFT_SETTING, _pngExport.margins.left());
|
|
|
|
if (_pngExport.margins.top() != PNG_MARGIN_TOP_DEFAULT)
|
|
|
|
settings.setValue(PNG_MARGIN_TOP_SETTING, _pngExport.margins.top());
|
|
|
|
if (_pngExport.margins.right() != PNG_MARGIN_RIGHT_DEFAULT)
|
|
|
|
settings.setValue(PNG_MARGIN_RIGHT_SETTING, _pngExport.margins.right());
|
|
|
|
if (_pngExport.margins.bottom() != PNG_MARGIN_BOTTOM_DEFAULT)
|
|
|
|
settings.setValue(PNG_MARGIN_BOTTOM_SETTING, _pngExport.margins.bottom());
|
|
|
|
if (_pngExport.antialiasing != PNG_ANTIALIASING_DEFAULT)
|
|
|
|
settings.setValue(PNG_ANTIALIASING_SETTING, _pngExport.antialiasing);
|
|
|
|
if (_pngExport.fileName != PNG_FILENAME_DEFAULT)
|
|
|
|
settings.setValue(PNG_FILENAME_SETTING, _pngExport.fileName);
|
2016-12-06 01:48:26 +01:00
|
|
|
settings.endGroup();
|
2016-08-09 01:16:19 +02:00
|
|
|
|
2016-12-06 01:48:26 +01:00
|
|
|
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());
|
2017-08-24 17:29:59 +02:00
|
|
|
if (_options.mapOpacity != MAP_OPACITY_DEFAULT)
|
|
|
|
settings.setValue(MAP_OPACITY_SETTING, _options.mapOpacity);
|
2017-09-15 00:07:09 +02:00
|
|
|
if (_options.backgroundColor != BACKGROUND_COLOR_DEFAULT)
|
|
|
|
settings.setValue(BACKGROUND_COLOR_SETTING, _options.backgroundColor);
|
2016-12-06 01:48:26 +01:00
|
|
|
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);
|
2019-01-31 01:46:53 +01:00
|
|
|
if (_options.areaWidth != AREA_WIDTH_DEFAULT)
|
|
|
|
settings.setValue(AREA_WIDTH_SETTING, _options.areaWidth);
|
2016-12-06 01:48:26 +01:00
|
|
|
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);
|
2019-01-31 01:46:53 +01:00
|
|
|
if (_options.areaStyle != AREA_STYLE_DEFAULT)
|
|
|
|
settings.setValue(AREA_STYLE_SETTING, (int)_options.areaStyle);
|
|
|
|
if (_options.areaOpacity != AREA_OPACITY_DEFAULT)
|
|
|
|
settings.setValue(AREA_OPACITY_SETTING, (int)_options.areaOpacity);
|
2017-09-10 12:42:49 +02:00
|
|
|
if (_options.waypointSize != WAYPOINT_SIZE_DEFAULT)
|
|
|
|
settings.setValue(WAYPOINT_SIZE_SETTING, _options.waypointSize);
|
|
|
|
if (_options.waypointColor != WAYPOINT_COLOR_DEFAULT)
|
|
|
|
settings.setValue(WAYPOINT_COLOR_SETTING, _options.waypointColor);
|
|
|
|
if (_options.poiSize != POI_SIZE_DEFAULT)
|
|
|
|
settings.setValue(POI_SIZE_SETTING, _options.poiSize);
|
|
|
|
if (_options.poiColor != POI_COLOR_DEFAULT)
|
|
|
|
settings.setValue(POI_COLOR_SETTING, _options.poiColor);
|
2016-12-06 01:48:26 +01:00
|
|
|
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);
|
2017-05-22 14:54:22 +02:00
|
|
|
if (_options.elevationFilter != ELEVATION_FILTER_DEFAULT)
|
|
|
|
settings.setValue(ELEVATION_FILTER_SETTING, _options.elevationFilter);
|
|
|
|
if (_options.speedFilter != SPEED_FILTER_DEFAULT)
|
|
|
|
settings.setValue(SPEED_FILTER_SETTING, _options.speedFilter);
|
|
|
|
if (_options.heartRateFilter != HEARTRATE_FILTER_DEFAULT)
|
|
|
|
settings.setValue(HEARTRATE_FILTER_SETTING, _options.heartRateFilter);
|
|
|
|
if (_options.cadenceFilter != CADENCE_FILTER_DEFAULT)
|
|
|
|
settings.setValue(CADENCE_FILTER_SETTING, _options.cadenceFilter);
|
|
|
|
if (_options.powerFilter != POWER_FILTER_DEFAULT)
|
|
|
|
settings.setValue(POWER_FILTER_SETTING, _options.powerFilter);
|
|
|
|
if (_options.outlierEliminate != OUTLIER_ELIMINATE_DEFAULT)
|
|
|
|
settings.setValue(OUTLIER_ELIMINATE_SETTING, _options.outlierEliminate);
|
2019-11-13 08:27:54 +01:00
|
|
|
if (_options.automaticPause != AUTOMATIC_PAUSE_DEFAULT)
|
|
|
|
settings.setValue(AUTOMATIC_PAUSE_SETTING, _options.automaticPause);
|
2017-05-22 14:54:22 +02:00
|
|
|
if (_options.pauseSpeed != PAUSE_SPEED_DEFAULT)
|
|
|
|
settings.setValue(PAUSE_SPEED_SETTING, _options.pauseSpeed);
|
|
|
|
if (_options.pauseInterval != PAUSE_INTERVAL_DEFAULT)
|
|
|
|
settings.setValue(PAUSE_INTERVAL_SETTING, _options.pauseInterval);
|
2018-06-21 20:54:24 +02:00
|
|
|
if (_options.useReportedSpeed != USE_REPORTED_SPEED_DEFAULT)
|
|
|
|
settings.setValue(USE_REPORTED_SPEED_SETTING, _options.useReportedSpeed);
|
2019-01-22 23:01:40 +01:00
|
|
|
if (_options.dataUseDEM != DATA_USE_DEM_DEFAULT)
|
|
|
|
settings.setValue(DATA_USE_DEM_SETTING, _options.dataUseDEM);
|
2020-03-25 23:08:26 +01:00
|
|
|
if (_options.showSecondaryElevation != SHOW_SECONDARY_ELEVATION_DEFAULT)
|
|
|
|
settings.setValue(SHOW_SECONDARY_ELEVATION_SETTING,
|
|
|
|
_options.showSecondaryElevation);
|
|
|
|
if (_options.showSecondarySpeed != SHOW_SECONDARY_SPEED_DEFAULT)
|
|
|
|
settings.setValue(SHOW_SECONDARY_SPEED_SETTING,
|
|
|
|
_options.showSecondarySpeed);
|
2020-05-20 21:00:36 +02:00
|
|
|
if (_options.timeZone != TimeZoneInfo())
|
|
|
|
settings.setValue(TIME_ZONE_SETTING, QVariant::fromValue(
|
|
|
|
_options.timeZone));
|
2020-09-20 22:18:35 +02:00
|
|
|
if (_options.useSegments != USE_SEGMENTS_DEFAULT)
|
|
|
|
settings.setValue(USE_SEGMENTS_SETTING, _options.useSegments);
|
2016-12-06 01:48:26 +01:00
|
|
|
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);
|
2018-07-23 23:53:58 +02:00
|
|
|
if (_options.enableHTTP2 != ENABLE_HTTP2_DEFAULT)
|
|
|
|
settings.setValue(ENABLE_HTTP2_SETTING, _options.enableHTTP2);
|
2017-05-03 23:55:16 +02:00
|
|
|
if (_options.pixmapCache != PIXMAP_CACHE_DEFAULT)
|
|
|
|
settings.setValue(PIXMAP_CACHE_SETTING, _options.pixmapCache);
|
2018-04-27 19:31:27 +02:00
|
|
|
if (_options.connectionTimeout != CONNECTION_TIMEOUT_DEFAULT)
|
|
|
|
settings.setValue(CONNECTION_TIMEOUT_SETTING, _options.connectionTimeout);
|
2017-08-28 15:25:45 +02:00
|
|
|
if (_options.hiresPrint != HIRES_PRINT_DEFAULT)
|
|
|
|
settings.setValue(HIRES_PRINT_SETTING, _options.hiresPrint);
|
2016-12-16 02:30:58 +01:00
|
|
|
if (_options.printName != PRINT_NAME_DEFAULT)
|
|
|
|
settings.setValue(PRINT_NAME_SETTING, _options.printName);
|
|
|
|
if (_options.printDate != PRINT_DATE_DEFAULT)
|
|
|
|
settings.setValue(PRINT_DATE_SETTING, _options.printDate);
|
|
|
|
if (_options.printDistance != PRINT_DISTANCE_DEFAULT)
|
|
|
|
settings.setValue(PRINT_DISTANCE_SETTING, _options.printDistance);
|
|
|
|
if (_options.printTime != PRINT_TIME_DEFAULT)
|
|
|
|
settings.setValue(PRINT_TIME_SETTING, _options.printTime);
|
2017-01-31 09:37:01 +01:00
|
|
|
if (_options.printMovingTime != PRINT_MOVING_TIME_DEFAULT)
|
|
|
|
settings.setValue(PRINT_MOVING_TIME_SETTING, _options.printMovingTime);
|
2016-12-16 02:30:58 +01:00
|
|
|
if (_options.printItemCount != PRINT_ITEM_COUNT_DEFAULT)
|
|
|
|
settings.setValue(PRINT_ITEM_COUNT_SETTING, _options.printItemCount);
|
|
|
|
if (_options.separateGraphPage != SEPARATE_GRAPH_PAGE_DEFAULT)
|
|
|
|
settings.setValue(SEPARATE_GRAPH_PAGE_SETTING,
|
|
|
|
_options.separateGraphPage);
|
2017-12-03 00:36:52 +01:00
|
|
|
if (_options.sliderColor != SLIDER_COLOR_DEFAULT)
|
|
|
|
settings.setValue(SLIDER_COLOR_SETTING, _options.sliderColor);
|
2020-12-24 16:33:17 +01:00
|
|
|
if (_options.outputProjection != OUTPUT_PROJECTION_DEFAULT)
|
|
|
|
settings.setValue(OUTPUT_PROJECTION_SETTING, _options.outputProjection);
|
|
|
|
if (_options.inputProjection != INPUT_PROJECTION_DEFAULT)
|
2021-04-05 11:40:17 +02:00
|
|
|
settings.setValue(INPUT_PROJECTION_SETTING, _options.inputProjection);
|
2018-09-11 00:33:20 +02:00
|
|
|
if (_options.hidpiMap != HIDPI_MAP_DEFAULT)
|
|
|
|
settings.setValue(HIDPI_MAP_SETTING, _options.hidpiMap);
|
2021-07-12 00:21:21 +02:00
|
|
|
if (_options.dataPath != DATA_PATH_DEFAULT)
|
|
|
|
settings.setValue(DATA_PATH_SETTING, _options.dataPath);
|
|
|
|
if (_options.mapsPath != MAPS_PATH_DEFAULT)
|
|
|
|
settings.setValue(MAPS_PATH_SETTING, _options.mapsPath);
|
|
|
|
if (_options.poiPath != POI_PATH_DEFAULT)
|
|
|
|
settings.setValue(POI_PATH_SETTING, _options.poiPath);
|
|
|
|
|
2016-08-09 01:16:19 +02:00
|
|
|
settings.endGroup();
|
2016-04-26 09:39:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::readSettings()
|
|
|
|
{
|
2018-02-11 23:51:57 +01:00
|
|
|
int value;
|
2018-11-02 20:01:19 +01:00
|
|
|
QSettings settings(qApp->applicationName(), qApp->applicationName());
|
2016-04-26 09:39:16 +02:00
|
|
|
|
2016-04-28 08:49:06 +02:00
|
|
|
settings.beginGroup(WINDOW_SETTINGS_GROUP);
|
2021-02-19 19:31:54 +01:00
|
|
|
restoreGeometry(settings.value(WINDOW_GEOMETRY_SETTING).toByteArray());
|
2019-02-18 22:33:18 +01:00
|
|
|
restoreState(settings.value(WINDOW_STATE_SETTING).toByteArray());
|
2016-04-26 09:39:16 +02:00
|
|
|
settings.endGroup();
|
|
|
|
|
2016-04-28 08:49:06 +02:00
|
|
|
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
|
2021-02-19 19:31:54 +01:00
|
|
|
if (settings.value(TIME_TYPE_SETTING, TIME_TYPE_DEFAULT).toInt() == Moving)
|
2018-02-15 01:44:03 +01:00
|
|
|
_movingTimeAction->trigger();
|
2018-02-11 20:39:39 +01:00
|
|
|
else
|
2018-02-15 01:44:03 +01:00
|
|
|
_totalTimeAction->trigger();
|
2018-02-11 20:39:39 +01:00
|
|
|
|
2018-02-11 23:51:57 +01:00
|
|
|
value = settings.value(UNITS_SETTING, UNITS_DEFAULT).toInt();
|
|
|
|
if (value == Imperial)
|
2018-02-15 01:44:03 +01:00
|
|
|
_imperialUnitsAction->trigger();
|
2018-02-11 23:51:57 +01:00
|
|
|
else if (value == Nautical)
|
2018-02-15 01:44:03 +01:00
|
|
|
_nauticalUnitsAction->trigger();
|
2018-02-11 20:39:39 +01:00
|
|
|
else
|
2018-02-15 01:44:03 +01:00
|
|
|
_metricUnitsAction->trigger();
|
2018-02-11 20:39:39 +01:00
|
|
|
|
2018-02-11 23:51:57 +01:00
|
|
|
value = settings.value(COORDINATES_SETTING, COORDINATES_DEFAULT).toInt();
|
|
|
|
if (value == DMS)
|
2020-01-23 23:19:32 +01:00
|
|
|
_dmsAction->trigger();
|
2018-02-11 23:51:57 +01:00
|
|
|
else if (value == DegreesMinutes)
|
2018-02-15 01:44:03 +01:00
|
|
|
_degreesMinutesAction->trigger();
|
2018-02-11 20:39:39 +01:00
|
|
|
else
|
2018-02-15 01:44:03 +01:00
|
|
|
_decimalDegreesAction->trigger();
|
2018-02-11 20:39:39 +01:00
|
|
|
|
2016-12-06 01:48:26 +01:00
|
|
|
if (!settings.value(SHOW_TOOLBARS_SETTING, SHOW_TOOLBARS_DEFAULT).toBool())
|
2016-04-26 09:39:16 +02:00
|
|
|
showToolbars(false);
|
2016-08-09 01:16:19 +02:00
|
|
|
else
|
2016-04-26 09:39:16 +02:00
|
|
|
_showToolbarsAction->setChecked(true);
|
|
|
|
settings.endGroup();
|
2016-04-26 20:55:29 +02:00
|
|
|
|
2016-04-28 08:49:06 +02:00
|
|
|
settings.beginGroup(MAP_SETTINGS_GROUP);
|
2016-12-06 01:48:26 +01:00
|
|
|
if (settings.value(SHOW_MAP_SETTING, SHOW_MAP_DEFAULT).toBool())
|
2016-04-26 20:55:29 +02:00
|
|
|
_showMapAction->setChecked(true);
|
2018-02-15 01:44:03 +01:00
|
|
|
else
|
|
|
|
_mapView->showMap(false);
|
2020-03-17 21:06:51 +01:00
|
|
|
QAction *ma = mapAction(settings.value(CURRENT_MAP_SETTING).toString());
|
|
|
|
if (ma) {
|
|
|
|
ma->trigger();
|
|
|
|
_showMapAction->setEnabled(true);
|
|
|
|
_clearMapCacheAction->setEnabled(true);
|
2017-03-18 01:30:31 +01:00
|
|
|
}
|
2019-02-17 20:20:20 +01:00
|
|
|
if (settings.value(SHOW_COORDINATES_SETTING, SHOW_COORDINATES_DEFAULT)
|
|
|
|
.toBool()) {
|
|
|
|
_showCoordinatesAction->setChecked(true);
|
|
|
|
_mapView->showCoordinates(true);
|
|
|
|
}
|
2016-04-26 20:55:29 +02:00
|
|
|
settings.endGroup();
|
|
|
|
|
2016-09-19 00:56:10 +02:00
|
|
|
settings.beginGroup(GRAPH_SETTINGS_GROUP);
|
2016-12-06 01:48:26 +01:00
|
|
|
if (!settings.value(SHOW_GRAPHS_SETTING, SHOW_GRAPHS_DEFAULT).toBool())
|
2016-09-19 00:56:10 +02:00
|
|
|
showGraphs(false);
|
|
|
|
else
|
|
|
|
_showGraphsAction->setChecked(true);
|
2016-12-06 01:48:26 +01:00
|
|
|
if (settings.value(GRAPH_TYPE_SETTING, GRAPH_TYPE_DEFAULT).toInt()
|
|
|
|
== Time) {
|
2016-09-19 00:56:10 +02:00
|
|
|
setTimeGraph();
|
|
|
|
_timeGraphAction->setChecked(true);
|
|
|
|
} else
|
|
|
|
_distanceGraphAction->setChecked(true);
|
2016-12-06 01:48:26 +01:00
|
|
|
if (!settings.value(SHOW_GRAPH_GRIDS_SETTING, SHOW_GRAPH_GRIDS_DEFAULT)
|
|
|
|
.toBool())
|
2016-10-17 23:14:07 +02:00
|
|
|
showGraphGrids(false);
|
|
|
|
else
|
|
|
|
_showGraphGridAction->setChecked(true);
|
2017-09-29 11:43:09 +02:00
|
|
|
if (!settings.value(SHOW_GRAPH_SLIDER_INFO_SETTING,
|
|
|
|
SHOW_GRAPH_SLIDER_INFO_DEFAULT).toBool())
|
|
|
|
showGraphSliderInfo(false);
|
|
|
|
else
|
|
|
|
_showGraphSliderInfoAction->setChecked(true);
|
2016-09-19 00:56:10 +02:00
|
|
|
settings.endGroup();
|
|
|
|
|
2016-04-28 08:49:06 +02:00
|
|
|
settings.beginGroup(POI_SETTINGS_GROUP);
|
2016-12-06 01:48:26 +01:00
|
|
|
if (!settings.value(OVERLAP_POI_SETTING, OVERLAP_POI_DEFAULT).toBool())
|
2021-01-17 16:02:37 +01:00
|
|
|
_mapView->showOverlappedPOIs(false);
|
2016-08-09 01:16:19 +02:00
|
|
|
else
|
2016-08-02 20:46:22 +02:00
|
|
|
_overlapPOIAction->setChecked(true);
|
2021-05-09 22:36:37 +02:00
|
|
|
if (!settings.value(SHOW_POI_LABELS_SETTING, SHOW_POI_LABELS_DEFAULT)
|
|
|
|
.toBool())
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->showPOILabels(false);
|
2016-08-09 01:16:19 +02:00
|
|
|
else
|
|
|
|
_showPOILabelsAction->setChecked(true);
|
2016-12-06 01:48:26 +01:00
|
|
|
if (settings.value(SHOW_POI_SETTING, SHOW_POI_DEFAULT).toBool())
|
2016-04-26 20:55:29 +02:00
|
|
|
_showPOIAction->setChecked(true);
|
2016-10-08 14:53:10 +02:00
|
|
|
else
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->showPOI(false);
|
2021-03-21 20:23:20 +01:00
|
|
|
QList<QAction*> poiActions(_poisActionGroup->actions());
|
|
|
|
for (int i = 0; i < poiActions.count(); i++)
|
|
|
|
poiActions.at(i)->setChecked(true);
|
2016-04-28 08:49:06 +02:00
|
|
|
int size = settings.beginReadArray(DISABLED_POI_FILE_SETTINGS_PREFIX);
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
settings.setArrayIndex(i);
|
2021-03-21 20:23:20 +01:00
|
|
|
QString file(settings.value(DISABLED_POI_FILE_SETTING).toString());
|
|
|
|
if (_poi->enableFile(file, false)) {
|
|
|
|
for (int j = 0; j < poiActions.size(); j++)
|
|
|
|
if (poiActions.at(j)->data().toString() == file)
|
|
|
|
poiActions.at(j)->setChecked(false);
|
2016-04-28 08:49:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
settings.endArray();
|
2016-04-26 20:55:29 +02:00
|
|
|
settings.endGroup();
|
2016-08-09 01:16:19 +02:00
|
|
|
|
|
|
|
settings.beginGroup(DATA_SETTINGS_GROUP);
|
2016-12-06 01:48:26 +01:00
|
|
|
if (!settings.value(SHOW_TRACKS_SETTING, SHOW_TRACKS_DEFAULT).toBool()) {
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->showTracks(false);
|
2016-08-16 00:27:54 +02:00
|
|
|
for (int i = 0; i < _tabs.count(); i++)
|
|
|
|
_tabs.at(i)->showTracks(false);
|
|
|
|
} else
|
2016-08-09 01:16:19 +02:00
|
|
|
_showTracksAction->setChecked(true);
|
2016-12-06 01:48:26 +01:00
|
|
|
if (!settings.value(SHOW_ROUTES_SETTING, SHOW_ROUTES_DEFAULT).toBool()) {
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->showRoutes(false);
|
2016-08-16 00:27:54 +02:00
|
|
|
for (int i = 0; i < _tabs.count(); i++)
|
|
|
|
_tabs.at(i)->showRoutes(false);
|
|
|
|
} else
|
2016-08-09 01:16:19 +02:00
|
|
|
_showRoutesAction->setChecked(true);
|
2016-12-06 01:48:26 +01:00
|
|
|
if (!settings.value(SHOW_WAYPOINTS_SETTING, SHOW_WAYPOINTS_DEFAULT)
|
|
|
|
.toBool())
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->showWaypoints(false);
|
2016-08-09 01:16:19 +02:00
|
|
|
else
|
|
|
|
_showWaypointsAction->setChecked(true);
|
2019-01-31 01:46:53 +01:00
|
|
|
if (!settings.value(SHOW_AREAS_SETTING, SHOW_AREAS_DEFAULT).toBool())
|
|
|
|
_mapView->showAreas(false);
|
|
|
|
else
|
|
|
|
_showAreasAction->setChecked(true);
|
2016-12-06 01:48:26 +01:00
|
|
|
if (!settings.value(SHOW_WAYPOINT_LABELS_SETTING,
|
|
|
|
SHOW_WAYPOINT_LABELS_DEFAULT).toBool())
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->showWaypointLabels(false);
|
2016-08-09 01:16:19 +02:00
|
|
|
else
|
|
|
|
_showWaypointLabelsAction->setChecked(true);
|
2016-12-06 01:48:26 +01:00
|
|
|
if (!settings.value(SHOW_ROUTE_WAYPOINTS_SETTING,
|
|
|
|
SHOW_ROUTE_WAYPOINTS_SETTING).toBool())
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->showRouteWaypoints(false);
|
2016-08-09 10:47:49 +02:00
|
|
|
else
|
|
|
|
_showRouteWaypointsAction->setChecked(true);
|
2019-05-23 08:44:55 +02:00
|
|
|
if (settings.value(SHOW_TICKS_SETTING, SHOW_TICKS_DEFAULT).toBool()) {
|
|
|
|
_mapView->showTicks(true);
|
|
|
|
_showTicksAction->setChecked(true);
|
|
|
|
}
|
2021-02-12 22:41:38 +01:00
|
|
|
if (settings.value(SHOW_MARKERS_SETTING, SHOW_MARKERS_DEFAULT).toBool()) {
|
|
|
|
MarkerInfoItem::Type mt = static_cast<MarkerInfoItem::Type>
|
|
|
|
(settings.value(SHOW_MARKER_INFO_SETTING,
|
|
|
|
SHOW_MARKER_INFO_DEFAULT).toInt());
|
|
|
|
if (mt == MarkerInfoItem::Position)
|
|
|
|
_showMarkerCoordinatesAction->trigger();
|
|
|
|
else if (mt == MarkerInfoItem::Date)
|
|
|
|
_showMarkerDateAction->trigger();
|
|
|
|
else
|
|
|
|
_showMarkersAction->trigger();
|
|
|
|
} else
|
|
|
|
_hideMarkersAction->trigger();
|
2016-08-09 01:16:19 +02:00
|
|
|
settings.endGroup();
|
2016-12-06 01:48:26 +01:00
|
|
|
|
2020-09-27 00:34:38 +02:00
|
|
|
settings.beginGroup(PDF_EXPORT_SETTINGS_GROUP);
|
2020-12-22 22:09:09 +01:00
|
|
|
_pdfExport.orientation = (QPageLayout::Orientation) settings.value(
|
2016-12-06 01:48:26 +01:00
|
|
|
PAPER_ORIENTATION_SETTING, PAPER_ORIENTATION_DEFAULT).toInt();
|
2020-09-27 00:34:38 +02:00
|
|
|
_pdfExport.resolution = settings.value(RESOLUTION_SETTING,
|
|
|
|
RESOLUTION_DEFAULT).toInt();
|
2020-12-22 22:09:09 +01:00
|
|
|
_pdfExport.paperSize = (QPageSize::PageSizeId) settings.value(
|
2020-09-27 00:34:38 +02:00
|
|
|
PAPER_SIZE_SETTING, PAPER_SIZE_DEFAULT).toInt();
|
|
|
|
qreal ml = settings.value(PDF_MARGIN_LEFT_SETTING, PDF_MARGIN_LEFT_DEFAULT)
|
2016-12-06 01:48:26 +01:00
|
|
|
.toReal();
|
2020-09-27 00:34:38 +02:00
|
|
|
qreal mt = settings.value(PDF_MARGIN_TOP_SETTING, PDF_MARGIN_TOP_DEFAULT)
|
2016-12-06 01:48:26 +01:00
|
|
|
.toReal();
|
2020-09-27 00:34:38 +02:00
|
|
|
qreal mr = settings.value(PDF_MARGIN_RIGHT_SETTING,
|
|
|
|
PDF_MARGIN_RIGHT_DEFAULT).toReal();
|
|
|
|
qreal mb = settings.value(PDF_MARGIN_BOTTOM_SETTING,
|
|
|
|
PDF_MARGIN_BOTTOM_DEFAULT).toReal();
|
2020-12-22 22:09:09 +01:00
|
|
|
_pdfExport.margins = QMarginsF(ml, mt, mr, mb);
|
2020-09-27 00:34:38 +02:00
|
|
|
_pdfExport.fileName = settings.value(PDF_FILENAME_SETTING,
|
|
|
|
PDF_FILENAME_DEFAULT).toString();
|
|
|
|
settings.endGroup();
|
|
|
|
|
|
|
|
settings.beginGroup(PNG_EXPORT_SETTINGS_GROUP);
|
|
|
|
_pngExport.size = QSize(settings.value(PNG_WIDTH_SETTING, PNG_WIDTH_DEFAULT)
|
|
|
|
.toInt(), settings.value(PNG_HEIGHT_SETTING, PNG_HEIGHT_DEFAULT).toInt());
|
|
|
|
int mli = settings.value(PNG_MARGIN_LEFT_SETTING, PNG_MARGIN_LEFT_DEFAULT)
|
|
|
|
.toInt();
|
|
|
|
int mti = settings.value(PNG_MARGIN_TOP_SETTING, PNG_MARGIN_TOP_DEFAULT)
|
|
|
|
.toInt();
|
|
|
|
int mri = settings.value(PNG_MARGIN_RIGHT_SETTING, PNG_MARGIN_RIGHT_DEFAULT)
|
|
|
|
.toInt();
|
2021-02-19 19:31:54 +01:00
|
|
|
int mbi = settings.value(PNG_MARGIN_BOTTOM_SETTING,
|
|
|
|
PNG_MARGIN_BOTTOM_DEFAULT).toInt();
|
2020-10-06 21:41:23 +02:00
|
|
|
_pngExport.margins = QMargins(mli, mti, mri, mbi);
|
2020-09-27 00:34:38 +02:00
|
|
|
_pngExport.antialiasing = settings.value(PNG_ANTIALIASING_SETTING,
|
|
|
|
PNG_ANTIALIASING_DEFAULT).toBool();
|
|
|
|
_pngExport.fileName = settings.value(PNG_FILENAME_SETTING,
|
|
|
|
PNG_FILENAME_DEFAULT).toString();
|
2016-12-06 01:48:26 +01:00
|
|
|
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);
|
2017-08-24 17:29:59 +02:00
|
|
|
_options.mapOpacity = settings.value(MAP_OPACITY_SETTING,
|
|
|
|
MAP_OPACITY_DEFAULT).toInt();
|
2017-09-15 00:07:09 +02:00
|
|
|
_options.backgroundColor = settings.value(BACKGROUND_COLOR_SETTING,
|
|
|
|
BACKGROUND_COLOR_DEFAULT).value<QColor>();
|
2016-12-06 01:48:26 +01:00
|
|
|
_options.trackWidth = settings.value(TRACK_WIDTH_SETTING,
|
|
|
|
TRACK_WIDTH_DEFAULT).toInt();
|
|
|
|
_options.routeWidth = settings.value(ROUTE_WIDTH_SETTING,
|
|
|
|
ROUTE_WIDTH_DEFAULT).toInt();
|
2019-01-31 01:46:53 +01:00
|
|
|
_options.areaWidth = settings.value(AREA_WIDTH_SETTING,
|
|
|
|
AREA_WIDTH_DEFAULT).toInt();
|
2016-12-06 01:48:26 +01:00
|
|
|
_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();
|
2019-01-31 01:46:53 +01:00
|
|
|
_options.areaStyle = (Qt::PenStyle) settings.value(AREA_STYLE_SETTING,
|
|
|
|
(int)AREA_STYLE_DEFAULT).toInt();
|
|
|
|
_options.areaOpacity = settings.value(AREA_OPACITY_SETTING,
|
|
|
|
AREA_OPACITY_DEFAULT).toInt();
|
2016-12-06 01:48:26 +01:00
|
|
|
_options.pathAntiAliasing = settings.value(PATH_AA_SETTING, PATH_AA_DEFAULT)
|
|
|
|
.toBool();
|
2017-09-10 12:42:49 +02:00
|
|
|
_options.waypointSize = settings.value(WAYPOINT_SIZE_SETTING,
|
|
|
|
WAYPOINT_SIZE_DEFAULT).toInt();
|
|
|
|
_options.waypointColor = settings.value(WAYPOINT_COLOR_SETTING,
|
|
|
|
WAYPOINT_COLOR_DEFAULT).value<QColor>();
|
|
|
|
_options.poiSize = settings.value(POI_SIZE_SETTING, POI_SIZE_DEFAULT)
|
|
|
|
.toInt();
|
|
|
|
_options.poiColor = settings.value(POI_COLOR_SETTING, POI_COLOR_DEFAULT)
|
|
|
|
.value<QColor>();
|
2016-12-06 21:02:44 +01:00
|
|
|
_options.graphWidth = settings.value(GRAPH_WIDTH_SETTING,
|
|
|
|
GRAPH_WIDTH_DEFAULT).toInt();
|
2016-12-06 01:48:26 +01:00
|
|
|
_options.graphAntiAliasing = settings.value(GRAPH_AA_SETTING,
|
|
|
|
GRAPH_AA_DEFAULT).toBool();
|
2017-05-22 14:54:22 +02:00
|
|
|
_options.elevationFilter = settings.value(ELEVATION_FILTER_SETTING,
|
|
|
|
ELEVATION_FILTER_DEFAULT).toInt();
|
|
|
|
_options.speedFilter = settings.value(SPEED_FILTER_SETTING,
|
|
|
|
SPEED_FILTER_DEFAULT).toInt();
|
|
|
|
_options.heartRateFilter = settings.value(HEARTRATE_FILTER_SETTING,
|
|
|
|
HEARTRATE_FILTER_DEFAULT).toInt();
|
|
|
|
_options.cadenceFilter = settings.value(CADENCE_FILTER_SETTING,
|
|
|
|
CADENCE_FILTER_DEFAULT).toInt();
|
|
|
|
_options.powerFilter = settings.value(POWER_FILTER_SETTING,
|
|
|
|
POWER_FILTER_DEFAULT).toInt();
|
|
|
|
_options.outlierEliminate = settings.value(OUTLIER_ELIMINATE_SETTING,
|
|
|
|
OUTLIER_ELIMINATE_DEFAULT).toBool();
|
|
|
|
_options.pauseSpeed = settings.value(PAUSE_SPEED_SETTING,
|
|
|
|
PAUSE_SPEED_DEFAULT).toFloat();
|
2018-06-21 20:54:24 +02:00
|
|
|
_options.useReportedSpeed = settings.value(USE_REPORTED_SPEED_SETTING,
|
|
|
|
USE_REPORTED_SPEED_DEFAULT).toBool();
|
2019-01-22 23:01:40 +01:00
|
|
|
_options.dataUseDEM = settings.value(DATA_USE_DEM_SETTING,
|
|
|
|
DATA_USE_DEM_DEFAULT).toBool();
|
2020-03-25 23:08:26 +01:00
|
|
|
_options.showSecondaryElevation = settings.value(
|
|
|
|
SHOW_SECONDARY_ELEVATION_SETTING,
|
|
|
|
SHOW_SECONDARY_ELEVATION_DEFAULT).toBool();
|
|
|
|
_options.showSecondarySpeed = settings.value(
|
|
|
|
SHOW_SECONDARY_SPEED_SETTING,
|
|
|
|
SHOW_SECONDARY_SPEED_DEFAULT).toBool();
|
2020-05-20 21:00:36 +02:00
|
|
|
_options.timeZone = settings.value(TIME_ZONE_SETTING).value<TimeZoneInfo>();
|
2020-09-20 22:18:35 +02:00
|
|
|
_options.useSegments = settings.value(USE_SEGMENTS_SETTING,
|
|
|
|
USE_SEGMENTS_DEFAULT).toBool();
|
2019-11-13 08:27:54 +01:00
|
|
|
_options.automaticPause = settings.value(AUTOMATIC_PAUSE_SETTING,
|
|
|
|
AUTOMATIC_PAUSE_DEFAULT).toBool();
|
2017-05-22 14:54:22 +02:00
|
|
|
_options.pauseInterval = settings.value(PAUSE_INTERVAL_SETTING,
|
|
|
|
PAUSE_INTERVAL_DEFAULT).toInt();
|
2016-12-06 01:48:26 +01:00
|
|
|
_options.poiRadius = settings.value(POI_RADIUS_SETTING, POI_RADIUS_DEFAULT)
|
|
|
|
.toInt();
|
|
|
|
_options.useOpenGL = settings.value(USE_OPENGL_SETTING, USE_OPENGL_DEFAULT)
|
|
|
|
.toBool();
|
2018-07-23 23:53:58 +02:00
|
|
|
_options.enableHTTP2 = settings.value(ENABLE_HTTP2_SETTING,
|
|
|
|
ENABLE_HTTP2_DEFAULT).toBool();
|
2017-05-03 23:55:16 +02:00
|
|
|
_options.pixmapCache = settings.value(PIXMAP_CACHE_SETTING,
|
|
|
|
PIXMAP_CACHE_DEFAULT).toInt();
|
2018-04-27 19:31:27 +02:00
|
|
|
_options.connectionTimeout = settings.value(CONNECTION_TIMEOUT_SETTING,
|
|
|
|
CONNECTION_TIMEOUT_DEFAULT).toInt();
|
2017-08-28 15:25:45 +02:00
|
|
|
_options.hiresPrint = settings.value(HIRES_PRINT_SETTING,
|
|
|
|
HIRES_PRINT_DEFAULT).toBool();
|
2016-12-16 02:30:58 +01:00
|
|
|
_options.printName = settings.value(PRINT_NAME_SETTING, PRINT_NAME_DEFAULT)
|
|
|
|
.toBool();
|
|
|
|
_options.printDate = settings.value(PRINT_DATE_SETTING, PRINT_DATE_DEFAULT)
|
|
|
|
.toBool();
|
|
|
|
_options.printDistance = settings.value(PRINT_DISTANCE_SETTING,
|
|
|
|
PRINT_DISTANCE_DEFAULT).toBool();
|
|
|
|
_options.printTime = settings.value(PRINT_TIME_SETTING, PRINT_TIME_DEFAULT)
|
|
|
|
.toBool();
|
2017-01-31 09:37:01 +01:00
|
|
|
_options.printMovingTime = settings.value(PRINT_MOVING_TIME_SETTING,
|
|
|
|
PRINT_MOVING_TIME_DEFAULT).toBool();
|
2016-12-16 02:30:58 +01:00
|
|
|
_options.printItemCount = settings.value(PRINT_ITEM_COUNT_SETTING,
|
|
|
|
PRINT_ITEM_COUNT_DEFAULT).toBool();
|
|
|
|
_options.separateGraphPage = settings.value(SEPARATE_GRAPH_PAGE_SETTING,
|
|
|
|
SEPARATE_GRAPH_PAGE_DEFAULT).toBool();
|
2017-12-03 00:36:52 +01:00
|
|
|
_options.sliderColor = settings.value(SLIDER_COLOR_SETTING,
|
|
|
|
SLIDER_COLOR_DEFAULT).value<QColor>();
|
2020-12-24 16:33:17 +01:00
|
|
|
_options.outputProjection = settings.value(OUTPUT_PROJECTION_SETTING,
|
|
|
|
OUTPUT_PROJECTION_DEFAULT).toInt();
|
|
|
|
_options.inputProjection = settings.value(INPUT_PROJECTION_SETTING,
|
|
|
|
INPUT_PROJECTION_DEFAULT).toInt();
|
2021-07-12 00:21:21 +02:00
|
|
|
_options.hidpiMap = settings.value(HIDPI_MAP_SETTING, HIDPI_MAP_DEFAULT)
|
2018-09-11 00:33:20 +02:00
|
|
|
.toBool();
|
2021-07-12 00:21:21 +02:00
|
|
|
_options.dataPath = settings.value(DATA_PATH_SETTING, DATA_PATH_DEFAULT)
|
|
|
|
.toString();
|
|
|
|
_options.mapsPath = settings.value(MAPS_PATH_SETTING, MAPS_PATH_DEFAULT)
|
|
|
|
.toString();
|
|
|
|
_options.poiPath = settings.value(POI_PATH_SETTING, POI_PATH_DEFAULT)
|
|
|
|
.toString();
|
2016-12-06 21:02:44 +01:00
|
|
|
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->setPalette(_options.palette);
|
|
|
|
_mapView->setMapOpacity(_options.mapOpacity);
|
|
|
|
_mapView->setBackgroundColor(_options.backgroundColor);
|
|
|
|
_mapView->setTrackWidth(_options.trackWidth);
|
|
|
|
_mapView->setRouteWidth(_options.routeWidth);
|
2019-01-31 01:46:53 +01:00
|
|
|
_mapView->setAreaWidth(_options.areaWidth);
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->setTrackStyle(_options.trackStyle);
|
|
|
|
_mapView->setRouteStyle(_options.routeStyle);
|
2019-01-31 01:46:53 +01:00
|
|
|
_mapView->setAreaStyle(_options.areaStyle);
|
|
|
|
_mapView->setAreaOpacity(_options.areaOpacity);
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->setWaypointSize(_options.waypointSize);
|
|
|
|
_mapView->setWaypointColor(_options.waypointColor);
|
|
|
|
_mapView->setPOISize(_options.poiSize);
|
|
|
|
_mapView->setPOIColor(_options.poiColor);
|
|
|
|
_mapView->setRenderHint(QPainter::Antialiasing, _options.pathAntiAliasing);
|
2017-12-03 00:36:52 +01:00
|
|
|
_mapView->setMarkerColor(_options.sliderColor);
|
2016-12-06 21:02:44 +01:00
|
|
|
if (_options.useOpenGL)
|
2017-12-01 00:22:16 +01:00
|
|
|
_mapView->useOpenGL(true);
|
2018-11-17 10:10:35 +01:00
|
|
|
_mapView->setDevicePixelRatio(devicePixelRatioF(),
|
|
|
|
_options.hidpiMap ? devicePixelRatioF() : 1.0);
|
2021-06-17 21:58:25 +02:00
|
|
|
_mapView->setOutputProjection(CRS::projection(_options.outputProjection));
|
|
|
|
_mapView->setInputProjection(CRS::projection(_options.inputProjection));
|
2020-05-20 21:00:36 +02:00
|
|
|
_mapView->setTimeZone(_options.timeZone.zone());
|
2016-12-06 21:02:44 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < _tabs.count(); i++) {
|
|
|
|
_tabs.at(i)->setPalette(_options.palette);
|
|
|
|
_tabs.at(i)->setGraphWidth(_options.graphWidth);
|
|
|
|
_tabs.at(i)->setRenderHint(QPainter::Antialiasing,
|
|
|
|
_options.graphAntiAliasing);
|
2017-12-03 00:36:52 +01:00
|
|
|
_tabs.at(i)->setSliderColor(_options.sliderColor);
|
2016-12-07 02:02:39 +01:00
|
|
|
if (_options.useOpenGL)
|
|
|
|
_tabs.at(i)->useOpenGL(true);
|
2016-12-06 21:02:44 +01:00
|
|
|
}
|
|
|
|
|
2017-05-22 14:54:22 +02:00
|
|
|
Track::setElevationFilter(_options.elevationFilter);
|
|
|
|
Track::setSpeedFilter(_options.speedFilter);
|
|
|
|
Track::setHeartRateFilter(_options.heartRateFilter);
|
|
|
|
Track::setCadenceFilter(_options.cadenceFilter);
|
|
|
|
Track::setPowerFilter(_options.powerFilter);
|
|
|
|
Track::setOutlierElimination(_options.outlierEliminate);
|
2019-11-13 08:27:54 +01:00
|
|
|
Track::setAutomaticPause(_options.automaticPause);
|
2017-05-22 14:54:22 +02:00
|
|
|
Track::setPauseSpeed(_options.pauseSpeed);
|
|
|
|
Track::setPauseInterval(_options.pauseInterval);
|
2018-06-21 20:54:24 +02:00
|
|
|
Track::useReportedSpeed(_options.useReportedSpeed);
|
2020-03-25 23:08:26 +01:00
|
|
|
Track::useDEM(_options.dataUseDEM);
|
|
|
|
Track::showSecondaryElevation(_options.showSecondaryElevation);
|
|
|
|
Track::showSecondarySpeed(_options.showSecondarySpeed);
|
2020-09-20 22:18:35 +02:00
|
|
|
Track::useSegments(_options.useSegments);
|
2020-03-25 23:08:26 +01:00
|
|
|
Route::useDEM(_options.dataUseDEM);
|
|
|
|
Route::showSecondaryElevation(_options.showSecondaryElevation);
|
|
|
|
Waypoint::useDEM(_options.dataUseDEM);
|
|
|
|
Waypoint::showSecondaryElevation(_options.showSecondaryElevation);
|
2017-05-22 14:54:22 +02:00
|
|
|
|
2016-12-06 21:02:44 +01:00
|
|
|
_poi->setRadius(_options.poiRadius);
|
|
|
|
|
2017-05-03 23:55:16 +02:00
|
|
|
QPixmapCache::setCacheLimit(_options.pixmapCache * 1024);
|
|
|
|
|
2016-12-06 01:48:26 +01:00
|
|
|
settings.endGroup();
|
2016-04-26 20:55:29 +02:00
|
|
|
}
|
|
|
|
|
2020-03-17 21:06:51 +01:00
|
|
|
QAction *GUI::mapAction(const QString &name)
|
2016-04-26 20:55:29 +02:00
|
|
|
{
|
2020-12-08 21:29:20 +01:00
|
|
|
QList<QAction *> maps(_mapsActionGroup->actions());
|
2020-03-17 21:06:51 +01:00
|
|
|
|
|
|
|
// Last map
|
|
|
|
for (int i = 0; i < maps.count(); i++) {
|
|
|
|
Map *map = maps.at(i)->data().value<Map*>();
|
|
|
|
if (map->name() == name && map->isReady())
|
|
|
|
return maps.at(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Any usable map
|
|
|
|
for (int i = 0; i < maps.count(); i++) {
|
|
|
|
Map *map = maps.at(i)->data().value<Map*>();
|
|
|
|
if (map->isReady())
|
|
|
|
return maps.at(i);
|
|
|
|
}
|
2016-04-26 20:55:29 +02:00
|
|
|
|
|
|
|
return 0;
|
2016-04-26 09:39:16 +02:00
|
|
|
}
|
2016-08-10 20:36:09 +02:00
|
|
|
|
2017-01-31 09:37:01 +01:00
|
|
|
Units GUI::units() const
|
|
|
|
{
|
2018-02-11 23:51:57 +01:00
|
|
|
return _imperialUnitsAction->isChecked() ? Imperial
|
|
|
|
: _nauticalUnitsAction->isChecked() ? Nautical : Metric;
|
2017-01-31 09:37:01 +01:00
|
|
|
}
|
|
|
|
|
2016-11-01 08:42:16 +01:00
|
|
|
qreal GUI::distance() const
|
2016-08-10 20:36:09 +02:00
|
|
|
{
|
|
|
|
qreal dist = 0;
|
|
|
|
|
|
|
|
if (_showTracksAction->isChecked())
|
|
|
|
dist += _trackDistance;
|
|
|
|
if (_showRoutesAction->isChecked())
|
|
|
|
dist += _routeDistance;
|
|
|
|
|
|
|
|
return dist;
|
|
|
|
}
|
|
|
|
|
2016-11-01 08:42:16 +01:00
|
|
|
qreal GUI::time() const
|
2016-08-10 20:36:09 +02:00
|
|
|
{
|
|
|
|
return (_showTracksAction->isChecked()) ? _time : 0;
|
|
|
|
}
|
2017-01-31 09:37:01 +01:00
|
|
|
|
|
|
|
qreal GUI::movingTime() const
|
|
|
|
{
|
|
|
|
return (_showTracksAction->isChecked()) ? _movingTime : 0;
|
|
|
|
}
|
2018-08-18 21:06:36 +02:00
|
|
|
|
|
|
|
void GUI::show()
|
|
|
|
{
|
|
|
|
QMainWindow::show();
|
|
|
|
|
|
|
|
QWindow *w = windowHandle();
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(w->screen(), &QScreen::logicalDotsPerInchChanged, this,
|
|
|
|
&GUI::logicalDotsPerInchChanged);
|
|
|
|
connect(w, &QWindow::screenChanged, this, &GUI::screenChanged);
|
2019-06-10 19:12:34 +02:00
|
|
|
|
|
|
|
_mapView->fitContentToSize();
|
2018-08-18 21:06:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::screenChanged(QScreen *screen)
|
|
|
|
{
|
2018-11-17 10:10:35 +01:00
|
|
|
_mapView->setDevicePixelRatio(devicePixelRatioF(),
|
|
|
|
_options.hidpiMap ? devicePixelRatioF() : 1.0);
|
2018-08-18 21:06:36 +02:00
|
|
|
|
|
|
|
disconnect(SIGNAL(logicalDotsPerInchChanged(qreal)), this,
|
|
|
|
SLOT(logicalDotsPerInchChanged(qreal)));
|
2021-04-28 00:01:07 +02:00
|
|
|
connect(screen, &QScreen::logicalDotsPerInchChanged, this,
|
|
|
|
&GUI::logicalDotsPerInchChanged);
|
2018-08-18 21:06:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::logicalDotsPerInchChanged(qreal dpi)
|
|
|
|
{
|
|
|
|
Q_UNUSED(dpi)
|
|
|
|
|
2018-11-17 10:10:35 +01:00
|
|
|
_mapView->setDevicePixelRatio(devicePixelRatioF(),
|
|
|
|
_options.hidpiMap ? devicePixelRatioF() : 1.0);
|
2018-08-18 21:06:36 +02:00
|
|
|
}
|