2016-04-29 21:13:38 +02:00
|
|
|
#include <QApplication>
|
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>
|
2015-11-23 02:37:08 +01:00
|
|
|
#include <QSignalMapper>
|
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>
|
2015-10-05 01:43:48 +02:00
|
|
|
#include "config.h"
|
|
|
|
#include "icons.h"
|
|
|
|
#include "keys.h"
|
2016-04-28 08:49:06 +02:00
|
|
|
#include "settings.h"
|
2015-10-05 01:43:48 +02:00
|
|
|
#include "gpx.h"
|
2015-11-23 02:37:08 +01:00
|
|
|
#include "map.h"
|
2015-11-23 23:19:57 +01:00
|
|
|
#include "maplist.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-02-11 20:58:52 +01:00
|
|
|
#include "trackview.h"
|
2016-05-12 09:03:05 +02:00
|
|
|
#include "trackinfo.h"
|
2015-10-20 22:18:41 +02:00
|
|
|
#include "filebrowser.h"
|
2016-04-12 23:15:17 +02:00
|
|
|
#include "cpuarch.h"
|
2016-05-24 03:01:22 +02:00
|
|
|
#include "exportdialog.h"
|
2016-06-24 00:55:44 +02:00
|
|
|
#include "graphtab.h"
|
2016-07-25 19:32:36 +02:00
|
|
|
#include "misc.h"
|
2015-10-19 00:35:08 +02:00
|
|
|
#include "gui.h"
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
|
2016-02-12 20:12:37 +01:00
|
|
|
GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2016-03-24 19:34:46 +01:00
|
|
|
loadMaps();
|
|
|
|
loadPOIs();
|
2015-11-23 02:37:08 +01:00
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
createTrackView();
|
|
|
|
createTrackGraphs();
|
|
|
|
createStatusBar();
|
2016-08-09 01:16:19 +02:00
|
|
|
createActions();
|
|
|
|
createMenus();
|
|
|
|
createToolBars();
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2015-10-20 22:18:41 +02:00
|
|
|
_browser = new FileBrowser(this);
|
|
|
|
_browser->setFilter(QStringList("*.gpx"));
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
QVBoxLayout *layout = new QVBoxLayout;
|
|
|
|
layout->addWidget(_track);
|
|
|
|
layout->addWidget(_trackGraphs);
|
2016-04-12 23:15:17 +02:00
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
layout->setSpacing(0);
|
|
|
|
#endif // Q_OS_WIN32
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
QWidget *widget = new QWidget;
|
|
|
|
widget->setLayout(layout);
|
|
|
|
setCentralWidget(widget);
|
|
|
|
|
2016-04-30 10:54:07 +02:00
|
|
|
setWindowIcon(QIcon(QPixmap(APP_ICON)));
|
2015-10-05 01:43:48 +02:00
|
|
|
setWindowTitle(APP_NAME);
|
|
|
|
setUnifiedTitleAndToolBarOnMac(true);
|
|
|
|
|
2016-02-08 17:53:09 +01:00
|
|
|
_trackCount = 0;
|
2016-08-09 23:08:49 +02:00
|
|
|
_routeCount = 0;
|
|
|
|
_waypointCount = 0;
|
2016-08-10 20:36:09 +02:00
|
|
|
_trackDistance = 0;
|
|
|
|
_routeDistance = 0;
|
|
|
|
_time = 0;
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2016-03-30 20:50:51 +02:00
|
|
|
_sliderPos = 0;
|
|
|
|
|
2016-03-23 09:38:22 +01:00
|
|
|
updateGraphTabs();
|
2016-03-25 09:50:19 +01:00
|
|
|
updateTrackView();
|
2016-08-10 21:17:12 +02:00
|
|
|
updateStatusBarInfo();
|
2016-03-21 22:37:55 +01:00
|
|
|
|
2016-04-26 09:39:16 +02:00
|
|
|
readSettings();
|
2016-05-25 23:27:07 +02:00
|
|
|
|
2016-05-27 22:45:58 +02:00
|
|
|
_exportPaperSize = (QLocale::system().measurementSystem()
|
2016-05-25 23:27:07 +02:00
|
|
|
== QLocale::ImperialSystem) ? QPrinter::Letter : QPrinter::A4;
|
|
|
|
_exportOrientation = QPrinter::Portrait;
|
2016-05-27 22:45:58 +02:00
|
|
|
_exportFileName = QString("%1/export.pdf").arg(QDir::currentPath());
|
|
|
|
_exportMargins = MarginsF(5.0, 5.0, 5.0, 5.0);
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2016-05-13 18:48:42 +02:00
|
|
|
GUI::~GUI()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < _tabs.size(); i++) {
|
2016-06-24 00:55:44 +02:00
|
|
|
if (_trackGraphs->indexOf(_tabs.at(i)) < 0)
|
|
|
|
delete _tabs.at(i);
|
2016-05-13 18:48:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-24 19:34:46 +01:00
|
|
|
void GUI::loadMaps()
|
2015-11-23 02:37:08 +01:00
|
|
|
{
|
2016-03-25 11:27:42 +01:00
|
|
|
if (QFile::exists(USER_MAP_FILE))
|
|
|
|
_maps = MapList::load(this, USER_MAP_FILE);
|
|
|
|
else
|
|
|
|
_maps = MapList::load(this, GLOBAL_MAP_FILE);
|
2016-03-24 19:34:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::loadPOIs()
|
|
|
|
{
|
2016-03-25 11:27:42 +01:00
|
|
|
QFileInfoList list;
|
2016-03-24 19:34:46 +01:00
|
|
|
QDir userDir(USER_POI_DIR);
|
|
|
|
QDir globalDir(GLOBAL_POI_DIR);
|
|
|
|
|
2016-03-25 11:27:42 +01:00
|
|
|
if (userDir.exists())
|
|
|
|
list = userDir.entryInfoList(QStringList(), QDir::Files);
|
|
|
|
else
|
|
|
|
list = globalDir.entryInfoList(QStringList(), QDir::Files);
|
|
|
|
|
2016-02-12 20:12:37 +01:00
|
|
|
for (int i = 0; i < list.size(); ++i)
|
|
|
|
_poi.loadFile(list.at(i).absoluteFilePath());
|
2015-11-23 02:37:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::createMapActions()
|
|
|
|
{
|
|
|
|
QActionGroup *ag = new QActionGroup(this);
|
|
|
|
ag->setExclusive(true);
|
|
|
|
|
|
|
|
QSignalMapper *sm = new QSignalMapper(this);
|
|
|
|
|
|
|
|
for (int i = 0; i < _maps.count(); i++) {
|
|
|
|
QAction *a = new QAction(_maps.at(i)->name(), this);
|
|
|
|
a->setCheckable(true);
|
|
|
|
a->setActionGroup(ag);
|
|
|
|
|
|
|
|
sm->setMapping(a, i);
|
|
|
|
connect(a, SIGNAL(triggered()), sm, SLOT(map()));
|
|
|
|
|
|
|
|
_mapActions.append(a);
|
|
|
|
}
|
|
|
|
|
|
|
|
connect(sm, SIGNAL(mapped(int)), this, SLOT(mapChanged(int)));
|
|
|
|
}
|
|
|
|
|
2016-03-05 18:01:13 +01:00
|
|
|
void GUI::createPOIFilesActions()
|
|
|
|
{
|
|
|
|
_poiFilesSM = new QSignalMapper(this);
|
|
|
|
|
2016-03-05 22:42:22 +01:00
|
|
|
for (int i = 0; i < _poi.files().count(); i++)
|
|
|
|
createPOIFileAction(i);
|
2016-03-05 18:01:13 +01:00
|
|
|
|
2016-03-05 22:42:22 +01:00
|
|
|
connect(_poiFilesSM, SIGNAL(mapped(int)), this, SLOT(poiFileChecked(int)));
|
|
|
|
}
|
2016-03-05 18:01:13 +01:00
|
|
|
|
2016-03-05 22:42:22 +01:00
|
|
|
QAction *GUI::createPOIFileAction(int index)
|
|
|
|
{
|
|
|
|
QAction *a = new QAction(QFileInfo(_poi.files().at(index)).fileName(),
|
|
|
|
this);
|
|
|
|
a->setCheckable(true);
|
2016-03-05 18:01:13 +01:00
|
|
|
|
2016-03-05 22:42:22 +01:00
|
|
|
_poiFilesSM->setMapping(a, index);
|
|
|
|
connect(a, SIGNAL(triggered()), _poiFilesSM, SLOT(map()));
|
|
|
|
|
|
|
|
_poiFilesActions.append(a);
|
|
|
|
|
|
|
|
return a;
|
2016-03-05 18:01:13 +01:00
|
|
|
}
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
void GUI::createActions()
|
|
|
|
{
|
|
|
|
// 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
|
2015-10-06 00:48:43 +02:00
|
|
|
_exitAction = new QAction(QIcon(QPixmap(QUIT_ICON)), tr("Quit"), this);
|
2016-04-11 22:08:00 +02:00
|
|
|
_exitAction->setShortcut(QUIT_SHORTCUT);
|
2016-03-24 19:16:26 +01:00
|
|
|
connect(_exitAction, SIGNAL(triggered()), this, SLOT(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
|
2015-11-30 22:42:51 +01:00
|
|
|
_dataSourcesAction = new QAction(tr("Data sources"), this);
|
|
|
|
connect(_dataSourcesAction, SIGNAL(triggered()), this, SLOT(dataSources()));
|
2015-10-21 01:09:17 +02:00
|
|
|
_keysAction = new QAction(tr("Keyboard controls"), this);
|
|
|
|
connect(_keysAction, SIGNAL(triggered()), this, SLOT(keys()));
|
2015-10-05 01:43:48 +02:00
|
|
|
_aboutAction = new QAction(QIcon(QPixmap(APP_ICON)),
|
|
|
|
tr("About GPXSee"), this);
|
|
|
|
connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about()));
|
|
|
|
|
2016-08-09 01:16:19 +02:00
|
|
|
// File actions
|
2015-10-05 01:43:48 +02:00
|
|
|
_openFileAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
|
|
|
|
tr("Open"), this);
|
2016-04-11 22:08:00 +02:00
|
|
|
_openFileAction->setShortcut(OPEN_SHORTCUT);
|
2015-10-05 01:43:48 +02:00
|
|
|
connect(_openFileAction, SIGNAL(triggered()), this, SLOT(openFile()));
|
2016-04-05 09:10:19 +02:00
|
|
|
addAction(_openFileAction);
|
2016-05-15 22:38:15 +02:00
|
|
|
_printFileAction = new QAction(QIcon(QPixmap(PRINT_FILE_ICON)),
|
2016-05-27 22:45:58 +02:00
|
|
|
tr("Print..."), this);
|
2016-05-15 22:38:15 +02:00
|
|
|
_printFileAction->setActionGroup(_fileActionGroup);
|
|
|
|
connect(_printFileAction, SIGNAL(triggered()), this, SLOT(printFile()));
|
|
|
|
addAction(_printFileAction);
|
|
|
|
_exportFileAction = new QAction(QIcon(QPixmap(EXPORT_FILE_ICON)),
|
2016-05-27 22:45:58 +02:00
|
|
|
tr("Export to PDF..."), this);
|
2016-05-15 22:38:15 +02:00
|
|
|
_exportFileAction->setShortcut(EXPORT_SHORTCUT);
|
|
|
|
_exportFileAction->setActionGroup(_fileActionGroup);
|
|
|
|
connect(_exportFileAction, SIGNAL(triggered()), this, SLOT(exportFile()));
|
|
|
|
addAction(_exportFileAction);
|
2015-10-05 01:43:48 +02:00
|
|
|
_closeFileAction = new QAction(QIcon(QPixmap(CLOSE_FILE_ICON)),
|
|
|
|
tr("Close"), this);
|
2016-04-11 22:08:00 +02:00
|
|
|
_closeFileAction->setShortcut(CLOSE_SHORTCUT);
|
2015-10-05 01:43:48 +02:00
|
|
|
_closeFileAction->setActionGroup(_fileActionGroup);
|
2016-03-23 20:56:39 +01:00
|
|
|
connect(_closeFileAction, SIGNAL(triggered()), this, SLOT(closeAll()));
|
2016-04-05 09:10:19 +02:00
|
|
|
addAction(_closeFileAction);
|
2015-10-20 22:18:41 +02:00
|
|
|
_reloadFileAction = new QAction(QIcon(QPixmap(RELOAD_FILE_ICON)),
|
|
|
|
tr("Reload"), this);
|
2016-04-11 22:08:00 +02:00
|
|
|
_reloadFileAction->setShortcut(RELOAD_SHORTCUT);
|
2015-10-20 22:18:41 +02:00
|
|
|
_reloadFileAction->setActionGroup(_fileActionGroup);
|
|
|
|
connect(_reloadFileAction, SIGNAL(triggered()), this, SLOT(reloadFile()));
|
2016-04-05 09:10:19 +02:00
|
|
|
addAction(_reloadFileAction);
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
// POI actions
|
|
|
|
_openPOIAction = new QAction(QIcon(QPixmap(OPEN_FILE_ICON)),
|
2015-11-23 02:37:08 +01:00
|
|
|
tr("Load POI file"), this);
|
2015-10-05 01:43:48 +02:00
|
|
|
connect(_openPOIAction, SIGNAL(triggered()), this, SLOT(openPOIFile()));
|
2016-03-05 18:01:13 +01:00
|
|
|
_closePOIAction = new QAction(QIcon(QPixmap(CLOSE_FILE_ICON)),
|
|
|
|
tr("Close POI files"), this);
|
|
|
|
connect(_closePOIAction, SIGNAL(triggered()), this, SLOT(closePOIFiles()));
|
2016-08-02 20:46:22 +02:00
|
|
|
_overlapPOIAction = new QAction(tr("Overlap POIs"), this);
|
|
|
|
_overlapPOIAction->setCheckable(true);
|
2016-08-09 01:16:19 +02:00
|
|
|
connect(_overlapPOIAction, SIGNAL(triggered(bool)), _track,
|
|
|
|
SLOT(setPOIOverlap(bool)));
|
|
|
|
_showPOILabelsAction = new QAction(tr("Show POI labels"), this);
|
|
|
|
_showPOILabelsAction->setCheckable(true);
|
|
|
|
connect(_showPOILabelsAction, SIGNAL(triggered(bool)), _track,
|
|
|
|
SLOT(showPOILabels(bool)));
|
2015-10-05 01:43:48 +02:00
|
|
|
_showPOIAction = new QAction(QIcon(QPixmap(SHOW_POI_ICON)),
|
2015-11-23 02:37:08 +01:00
|
|
|
tr("Show POIs"), this);
|
2015-10-05 01:43:48 +02:00
|
|
|
_showPOIAction->setCheckable(true);
|
2016-04-11 22:08:00 +02:00
|
|
|
_showPOIAction->setShortcut(SHOW_POI_SHORTCUT);
|
2015-11-24 00:24:26 +01:00
|
|
|
connect(_showPOIAction, SIGNAL(triggered(bool)), this, SLOT(showPOI(bool)));
|
2016-04-05 09:10:19 +02:00
|
|
|
addAction(_showPOIAction);
|
2016-03-05 18:01:13 +01:00
|
|
|
createPOIFilesActions();
|
2015-11-23 02:37:08 +01:00
|
|
|
|
|
|
|
// Map actions
|
|
|
|
_showMapAction = new QAction(QIcon(QPixmap(SHOW_MAP_ICON)), tr("Show map"),
|
|
|
|
this);
|
|
|
|
_showMapAction->setCheckable(true);
|
2016-04-11 22:08:00 +02:00
|
|
|
_showMapAction->setShortcut(SHOW_MAP_SHORTCUT);
|
2015-11-24 00:24:26 +01:00
|
|
|
connect(_showMapAction, SIGNAL(triggered(bool)), this, SLOT(showMap(bool)));
|
2016-04-05 09:10:19 +02:00
|
|
|
addAction(_showMapAction);
|
2016-04-01 19:25:34 +02:00
|
|
|
_clearMapCacheAction = new QAction(tr("Clear tile cache"), this);
|
|
|
|
connect(_clearMapCacheAction, SIGNAL(triggered()), this,
|
|
|
|
SLOT(clearMapCache()));
|
|
|
|
if (_maps.empty()) {
|
2015-11-23 02:37:08 +01:00
|
|
|
_showMapAction->setEnabled(false);
|
2016-04-01 19:25:34 +02:00
|
|
|
_clearMapCacheAction->setEnabled(false);
|
|
|
|
} else {
|
2015-11-23 02:37:08 +01:00
|
|
|
createMapActions();
|
2016-04-08 22:33:19 +02:00
|
|
|
|
|
|
|
_nextMapAction = new QAction(tr("Next map"), this);
|
2016-04-11 22:08:00 +02:00
|
|
|
_nextMapAction->setShortcut(NEXT_MAP_SHORTCUT);
|
2016-04-08 22:33:19 +02:00
|
|
|
connect(_nextMapAction, SIGNAL(triggered()), this, SLOT(nextMap()));
|
|
|
|
addAction(_nextMapAction);
|
|
|
|
_prevMapAction = new QAction(tr("Next map"), this);
|
2016-04-11 22:08:00 +02:00
|
|
|
_prevMapAction->setShortcut(PREV_MAP_SHORTCUT);
|
2016-04-08 22:33:19 +02:00
|
|
|
connect(_prevMapAction, SIGNAL(triggered()), this, SLOT(prevMap()));
|
|
|
|
addAction(_prevMapAction);
|
2016-02-07 18:12:03 +01:00
|
|
|
}
|
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);
|
2016-08-09 01:16:19 +02:00
|
|
|
_showTracksAction->setCheckable(true);
|
2016-08-10 20:36:09 +02:00
|
|
|
connect(_showTracksAction, SIGNAL(triggered(bool)), this,
|
2016-08-09 01:16:19 +02:00
|
|
|
SLOT(showTracks(bool)));
|
2016-08-16 00:27:54 +02:00
|
|
|
_showRoutesAction = new QAction(tr("Show routes"), this);
|
2016-08-09 01:16:19 +02:00
|
|
|
_showRoutesAction->setCheckable(true);
|
2016-08-10 20:36:09 +02:00
|
|
|
connect(_showRoutesAction, SIGNAL(triggered(bool)), this,
|
2016-08-09 01:16:19 +02:00
|
|
|
SLOT(showRoutes(bool)));
|
2016-08-16 00:27:54 +02:00
|
|
|
_showWaypointsAction = new QAction(tr("Show waypoints"), this);
|
2016-08-09 01:16:19 +02:00
|
|
|
_showWaypointsAction->setCheckable(true);
|
|
|
|
connect(_showWaypointsAction, SIGNAL(triggered(bool)), _track,
|
|
|
|
SLOT(showWaypoints(bool)));
|
2016-08-09 10:47:49 +02:00
|
|
|
_showWaypointLabelsAction = new QAction(tr("Waypoint labels"), this);
|
2016-08-09 01:16:19 +02:00
|
|
|
_showWaypointLabelsAction->setCheckable(true);
|
|
|
|
connect(_showWaypointLabelsAction, SIGNAL(triggered(bool)), _track,
|
|
|
|
SLOT(showWaypointLabels(bool)));
|
2016-08-16 00:27:54 +02:00
|
|
|
_showRouteWaypointsAction = new QAction(tr("Route waypoints"), this);
|
2016-08-09 10:47:49 +02:00
|
|
|
_showRouteWaypointsAction->setCheckable(true);
|
|
|
|
connect(_showRouteWaypointsAction, SIGNAL(triggered(bool)), _track,
|
|
|
|
SLOT(showRouteWaypoints(bool)));
|
2016-08-09 01:16:19 +02:00
|
|
|
|
2015-11-24 00:24:26 +01:00
|
|
|
// Settings actions
|
|
|
|
_showGraphsAction = new QAction(tr("Show graphs"), this);
|
|
|
|
_showGraphsAction->setCheckable(true);
|
2016-04-11 22:08:00 +02:00
|
|
|
_showGraphsAction->setShortcut(SHOW_GRAPHS_SHORTCUT);
|
2015-11-24 00:24:26 +01:00
|
|
|
connect(_showGraphsAction, SIGNAL(triggered(bool)), this,
|
|
|
|
SLOT(showGraphs(bool)));
|
2016-04-05 09:10:19 +02:00
|
|
|
addAction(_showGraphsAction);
|
2015-11-24 00:24:26 +01:00
|
|
|
_showToolbarsAction = new QAction(tr("Show toolbars"), this);
|
|
|
|
_showToolbarsAction->setCheckable(true);
|
|
|
|
connect(_showToolbarsAction, SIGNAL(triggered(bool)), this,
|
|
|
|
SLOT(showToolbars(bool)));
|
2015-12-19 20:23:07 +01:00
|
|
|
QActionGroup *ag = new QActionGroup(this);
|
|
|
|
ag->setExclusive(true);
|
|
|
|
_metricUnitsAction = new QAction(tr("Metric"), this);
|
|
|
|
_metricUnitsAction->setCheckable(true);
|
|
|
|
_metricUnitsAction->setActionGroup(ag);
|
|
|
|
connect(_metricUnitsAction, SIGNAL(triggered()), this,
|
|
|
|
SLOT(setMetricUnits()));
|
|
|
|
_imperialUnitsAction = new QAction(tr("Imperial"), this);
|
|
|
|
_imperialUnitsAction->setCheckable(true);
|
|
|
|
_imperialUnitsAction->setActionGroup(ag);
|
|
|
|
connect(_imperialUnitsAction, SIGNAL(triggered()), this,
|
|
|
|
SLOT(setImperialUnits()));
|
2016-04-05 09:10:19 +02:00
|
|
|
_fullscreenAction = new QAction(QIcon(QPixmap(FULLSCREEN_ICON)),
|
|
|
|
tr("Fullscreen mode"), this);
|
|
|
|
_fullscreenAction->setCheckable(true);
|
2016-04-11 22:08:00 +02:00
|
|
|
_fullscreenAction->setShortcut(FULLSCREEN_SHORTCUT);
|
2016-04-05 09:10:19 +02:00
|
|
|
connect(_fullscreenAction, SIGNAL(triggered(bool)), this,
|
|
|
|
SLOT(showFullscreen(bool)));
|
|
|
|
addAction(_fullscreenAction);
|
2015-12-18 22:21:11 +01:00
|
|
|
|
|
|
|
// Navigation actions
|
|
|
|
_nextAction = new QAction(QIcon(QPixmap(NEXT_FILE_ICON)), tr("Next"), this);
|
|
|
|
_nextAction->setActionGroup(_navigationActionGroup);
|
|
|
|
connect(_nextAction, SIGNAL(triggered()), this, SLOT(next()));
|
|
|
|
_prevAction = new QAction(QIcon(QPixmap(PREV_FILE_ICON)), tr("Previous"),
|
|
|
|
this);
|
|
|
|
_prevAction->setActionGroup(_navigationActionGroup);
|
|
|
|
connect(_prevAction, SIGNAL(triggered()), this, SLOT(prev()));
|
|
|
|
_lastAction = new QAction(QIcon(QPixmap(LAST_FILE_ICON)), tr("Last"), this);
|
|
|
|
_lastAction->setActionGroup(_navigationActionGroup);
|
|
|
|
connect(_lastAction, SIGNAL(triggered()), this, SLOT(last()));
|
|
|
|
_firstAction = new QAction(QIcon(QPixmap(FIRST_FILE_ICON)), tr("First"),
|
|
|
|
this);
|
|
|
|
_firstAction->setActionGroup(_navigationActionGroup);
|
|
|
|
connect(_firstAction, SIGNAL(triggered()), this, SLOT(first()));
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::createMenus()
|
|
|
|
{
|
2016-08-09 01:16:19 +02:00
|
|
|
QMenu *fileMenu = menuBar()->addMenu(tr("File"));
|
|
|
|
fileMenu->addAction(_openFileAction);
|
|
|
|
fileMenu->addSeparator();
|
|
|
|
fileMenu->addAction(_printFileAction);
|
|
|
|
fileMenu->addAction(_exportFileAction);
|
|
|
|
fileMenu->addSeparator();
|
|
|
|
fileMenu->addAction(_reloadFileAction);
|
|
|
|
fileMenu->addSeparator();
|
|
|
|
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
|
|
|
|
2016-08-09 01:16:19 +02:00
|
|
|
QMenu *mapMenu = menuBar()->addMenu(tr("Map"));
|
|
|
|
mapMenu->addActions(_mapActions);
|
|
|
|
mapMenu->addSeparator();
|
|
|
|
mapMenu->addAction(_clearMapCacheAction);
|
|
|
|
mapMenu->addSeparator();
|
|
|
|
mapMenu->addAction(_showMapAction);
|
2015-11-23 02:37:08 +01:00
|
|
|
|
2016-08-09 01:16:19 +02:00
|
|
|
QMenu *poiMenu = menuBar()->addMenu(tr("POI"));
|
|
|
|
_poiFilesMenu = poiMenu->addMenu(tr("POI files"));
|
2016-03-05 18:01:13 +01:00
|
|
|
_poiFilesMenu->addActions(_poiFilesActions);
|
2016-08-09 01:16:19 +02:00
|
|
|
poiMenu->addSeparator();
|
|
|
|
poiMenu->addAction(_openPOIAction);
|
|
|
|
poiMenu->addAction(_closePOIAction);
|
|
|
|
poiMenu->addSeparator();
|
|
|
|
poiMenu->addAction(_showPOILabelsAction);
|
|
|
|
poiMenu->addAction(_overlapPOIAction);
|
|
|
|
poiMenu->addSeparator();
|
|
|
|
poiMenu->addAction(_showPOIAction);
|
|
|
|
|
|
|
|
QMenu *dataMenu = menuBar()->addMenu(tr("Data"));
|
2016-08-09 10:47:49 +02:00
|
|
|
QMenu *displayMenu = dataMenu->addMenu(tr("Display"));
|
|
|
|
displayMenu->addAction(_showWaypointLabelsAction);
|
|
|
|
displayMenu->addAction(_showRouteWaypointsAction);
|
|
|
|
dataMenu->addSeparator();
|
2016-08-09 01:16:19 +02:00
|
|
|
dataMenu->addAction(_showTracksAction);
|
|
|
|
dataMenu->addAction(_showRoutesAction);
|
|
|
|
dataMenu->addAction(_showWaypointsAction);
|
|
|
|
|
|
|
|
QMenu *settingsMenu = menuBar()->addMenu(tr("Settings"));
|
|
|
|
QMenu *unitsMenu = settingsMenu->addMenu(tr("Units"));
|
|
|
|
unitsMenu->addAction(_metricUnitsAction);
|
|
|
|
unitsMenu->addAction(_imperialUnitsAction);
|
|
|
|
settingsMenu->addSeparator();
|
|
|
|
settingsMenu->addAction(_showToolbarsAction);
|
|
|
|
settingsMenu->addAction(_showGraphsAction);
|
|
|
|
settingsMenu->addSeparator();
|
|
|
|
settingsMenu->addAction(_fullscreenAction);
|
|
|
|
|
|
|
|
QMenu *helpMenu = menuBar()->addMenu(tr("Help"));
|
|
|
|
helpMenu->addAction(_dataSourcesAction);
|
|
|
|
helpMenu->addAction(_keysAction);
|
|
|
|
helpMenu->addSeparator();
|
|
|
|
helpMenu->addAction(_aboutAction);
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::createToolBars()
|
|
|
|
{
|
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"));
|
|
|
|
_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"));
|
|
|
|
_showToolBar->addAction(_showPOIAction);
|
|
|
|
_showToolBar->addAction(_showMapAction);
|
2015-12-18 22:21:11 +01:00
|
|
|
|
|
|
|
_navigationToolBar = addToolBar(tr("Navigation"));
|
|
|
|
_navigationToolBar->addAction(_firstAction);
|
|
|
|
_navigationToolBar->addAction(_prevAction);
|
|
|
|
_navigationToolBar->addAction(_nextAction);
|
|
|
|
_navigationToolBar->addAction(_lastAction);
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::createTrackView()
|
|
|
|
{
|
2016-02-11 20:58:52 +01:00
|
|
|
_track = new TrackView(this);
|
2016-04-12 23:15:17 +02:00
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
_track->setFrameShape(QFrame::NoFrame);
|
|
|
|
#endif // Q_OS_WIN32
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::createTrackGraphs()
|
|
|
|
{
|
|
|
|
_trackGraphs = new QTabWidget;
|
|
|
|
connect(_trackGraphs, SIGNAL(currentChanged(int)), this,
|
|
|
|
SLOT(graphChanged(int)));
|
|
|
|
|
|
|
|
_trackGraphs->setFixedHeight(200);
|
|
|
|
_trackGraphs->setSizePolicy(
|
|
|
|
QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed));
|
2016-04-12 23:15:17 +02:00
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
_trackGraphs->setDocumentMode(true);
|
|
|
|
#endif // Q_OS_WIN32
|
2016-05-13 18:48:42 +02:00
|
|
|
|
2016-06-24 00:55:44 +02:00
|
|
|
_tabs.append(new ElevationGraph);
|
|
|
|
_tabs.append(new SpeedGraph);
|
|
|
|
_tabs.append(new HeartRateGraph);
|
|
|
|
_tabs.append(new TemperatureGraph);
|
|
|
|
|
|
|
|
for (int i = 0; i < _tabs.count(); i++)
|
|
|
|
connect(_tabs.at(i), SIGNAL(sliderPositionChanged(qreal)), this,
|
|
|
|
SLOT(sliderPositionChanged(qreal)));
|
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();
|
|
|
|
_timeLabel = new QLabel();
|
|
|
|
_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);
|
|
|
|
|
|
|
|
msgBox.setWindowTitle(tr("About GPXSee"));
|
2016-04-12 23:15:17 +02:00
|
|
|
msgBox.setText(QString("<h2>") + QString(APP_NAME) + QString("</h2><p>")
|
|
|
|
+ QString("<p>") + tr("Version ") + APP_VERSION + QString(" (")
|
|
|
|
+ CPU_ARCH + QString(", Qt ") + QString(QT_VERSION_STR)
|
|
|
|
+ QString(")</p>"));
|
2015-10-22 00:05:45 +02:00
|
|
|
msgBox.setInformativeText(QString("<table width=\"300\"><tr><td>")
|
|
|
|
+ tr("GPXSee is distributed under the terms of the GNU General Public "
|
|
|
|
"License version 3. For more info about GPXSee visit the project "
|
2016-02-07 18:27:50 +01:00
|
|
|
"homepage at ") + QString("<a href=\"" APP_HOMEPAGE "\">" APP_HOMEPAGE
|
2015-10-22 00:05:45 +02:00
|
|
|
"</a>.</td></tr></table>"));
|
|
|
|
|
|
|
|
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"));
|
|
|
|
msgBox.setText(QString("<h3>") + tr("Keyboard controls") + QString("</h3>"));
|
|
|
|
msgBox.setInformativeText(
|
2016-04-09 09:14:10 +02:00
|
|
|
QString("<div><table width=\"300\"><tr><td>") + tr("Next file")
|
2015-10-21 01:09:17 +02:00
|
|
|
+ QString("</td><td><i>SPACE</i></td></tr><tr><td>") + tr("Previous file")
|
|
|
|
+ QString("</td><td><i>BACKSPACE</i></td></tr><tr><td>")
|
2015-12-18 22:21:11 +01:00
|
|
|
+ tr("First file") + QString("</td><td><i>HOME</i></td></tr><tr><td>")
|
2016-04-08 22:33:19 +02:00
|
|
|
+ tr("Last file") + QString("</td><td><i>END</i></td></tr><tr><td>")
|
|
|
|
+ tr("Append modifier") + QString("</td><td><i>SHIFT</i></td></tr>"
|
|
|
|
"<tr><td></td><td></td></tr><tr><td>")
|
|
|
|
+ tr("Next map") + QString("</td><td><i>")
|
|
|
|
+ _nextMapAction->shortcut().toString() + QString("</i></td></tr><tr><td>")
|
|
|
|
+ tr("Previous map") + QString("</td><td><i>")
|
|
|
|
+ _prevMapAction->shortcut().toString() + QString("</i></td></tr>"
|
|
|
|
"</table></div>"));
|
2015-10-22 00:05:45 +02:00
|
|
|
|
2015-10-21 01:09:17 +02:00
|
|
|
msgBox.exec();
|
|
|
|
}
|
|
|
|
|
2015-11-30 22:42:51 +01:00
|
|
|
void GUI::dataSources()
|
|
|
|
{
|
|
|
|
QMessageBox msgBox(this);
|
|
|
|
|
|
|
|
msgBox.setWindowTitle(tr("Data sources"));
|
|
|
|
msgBox.setText(QString("<h3>") + tr("Data sources") + QString("</h3>"));
|
|
|
|
msgBox.setInformativeText(
|
|
|
|
QString("<h4>") + tr("Map sources") + QString("</h4><p>")
|
|
|
|
+ tr("Map (tiles) source URLs are read on program startup from the "
|
|
|
|
"following file:")
|
2016-03-24 19:34:46 +01:00
|
|
|
+ QString("</p><p><code>") + USER_MAP_FILE + QString("</code></p><p>")
|
2015-12-01 23:38:02 +01:00
|
|
|
+ tr("The file format is one map entry per line, consisting of the map "
|
|
|
|
"name and tiles URL delimited by a TAB character. The tile X and Y "
|
|
|
|
"coordinates are replaced with $x and $y in the URL and the zoom "
|
|
|
|
"level is replaced with $z. An example map file could look like:")
|
|
|
|
+ QString("</p><p><code>Map1 http://tile.server.com/map/$z/$x/$y.png"
|
|
|
|
"<br/>Map2 http://mapserver.org/map/$z-$x-$y</code></p>")
|
2015-11-30 22:42:51 +01:00
|
|
|
|
|
|
|
+ QString("<h4>") + tr("POIs") + QString("</h4><p>")
|
|
|
|
+ tr("To make GPXSee load a POI file automatically on startup, add "
|
|
|
|
"the file to the following directory:")
|
2016-03-24 19:34:46 +01:00
|
|
|
+ QString("</p><p><code>") + USER_POI_DIR + QString("</code></p>")
|
2015-11-30 22:42:51 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
msgBox.exec();
|
|
|
|
}
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
void GUI::openFile()
|
|
|
|
{
|
2016-02-12 20:12:37 +01:00
|
|
|
QStringList files = QFileDialog::getOpenFileNames(this, tr("Open file"),
|
|
|
|
QString(), tr("GPX files (*.gpx);;All files (*)"));
|
2015-10-05 01:43:48 +02:00
|
|
|
QStringList list = files;
|
|
|
|
|
2015-10-07 01:30:03 +02:00
|
|
|
for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
|
2015-10-20 22:18:41 +02:00
|
|
|
openFile(*it);
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool GUI::openFile(const QString &fileName)
|
|
|
|
{
|
2016-03-23 20:56:39 +01:00
|
|
|
bool ret = true;
|
|
|
|
|
2015-10-20 22:18:41 +02:00
|
|
|
if (fileName.isEmpty() || _files.contains(fileName))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (loadFile(fileName)) {
|
|
|
|
_files.append(fileName);
|
|
|
|
_browser->setCurrent(fileName);
|
|
|
|
_fileActionGroup->setEnabled(true);
|
2015-12-18 22:21:11 +01:00
|
|
|
_navigationActionGroup->setEnabled(true);
|
2016-03-25 10:49:08 +01:00
|
|
|
} else {
|
2016-03-29 20:58:33 +02:00
|
|
|
if (_files.isEmpty())
|
|
|
|
_fileActionGroup->setEnabled(false);
|
2016-03-23 20:56:39 +01:00
|
|
|
ret = false;
|
2016-03-25 10:49:08 +01:00
|
|
|
}
|
2016-03-23 20:56:39 +01:00
|
|
|
|
|
|
|
updateNavigationActions();
|
|
|
|
updateStatusBarInfo();
|
2016-04-19 08:51:11 +02:00
|
|
|
updateWindowTitle();
|
2016-03-23 20:56:39 +01:00
|
|
|
updateGraphTabs();
|
2016-03-25 09:50:19 +01:00
|
|
|
updateTrackView();
|
2016-03-23 20:56:39 +01:00
|
|
|
|
|
|
|
return ret;
|
2015-10-20 22:18:41 +02:00
|
|
|
}
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2015-10-20 22:18:41 +02:00
|
|
|
bool GUI::loadFile(const QString &fileName)
|
|
|
|
{
|
|
|
|
GPX gpx;
|
2015-10-17 12:08:30 +02:00
|
|
|
|
2015-10-20 22:18:41 +02:00
|
|
|
if (gpx.loadFile(fileName)) {
|
2016-06-24 00:55:44 +02:00
|
|
|
for (int i = 0; i < _tabs.count(); i++)
|
|
|
|
_tabs.at(i)->loadGPX(gpx);
|
2016-03-24 20:50:11 +01:00
|
|
|
updateGraphTabs();
|
2016-03-25 09:50:19 +01:00
|
|
|
_track->setHidden(false);
|
2015-10-20 22:18:41 +02:00
|
|
|
_track->loadGPX(gpx);
|
|
|
|
if (_showPOIAction->isChecked())
|
|
|
|
_track->loadPOI(_poi);
|
2015-10-17 12:08:30 +02:00
|
|
|
|
2016-08-09 23:08:49 +02:00
|
|
|
for (int i = 0; i < gpx.tracks().count(); i++) {
|
2016-08-10 20:36:09 +02:00
|
|
|
_trackDistance += gpx.tracks().at(i)->distance();
|
2016-08-09 23:08:49 +02:00
|
|
|
_time += gpx.tracks().at(i)->time();
|
|
|
|
const QDate &date = gpx.tracks().at(i)->date().date();
|
2016-05-21 16:10:24 +02:00
|
|
|
if (_dateRange.first.isNull() || _dateRange.first > date)
|
|
|
|
_dateRange.first = date;
|
|
|
|
if (_dateRange.second.isNull() || _dateRange.second < date)
|
|
|
|
_dateRange.second = date;
|
2016-02-08 17:53:09 +01:00
|
|
|
}
|
2016-08-09 23:08:49 +02:00
|
|
|
_trackCount += gpx.tracks().count();
|
|
|
|
|
|
|
|
for (int i = 0; i < gpx.routes().count(); i++)
|
2016-08-10 20:36:09 +02:00
|
|
|
_routeDistance += gpx.routes().at(i)->distance();
|
2016-08-09 23:08:49 +02:00
|
|
|
_routeCount += gpx.routes().count();
|
2016-02-08 17:53:09 +01:00
|
|
|
|
2016-08-09 23:08:49 +02:00
|
|
|
_waypointCount += gpx.waypoints().count();
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2015-10-20 22:18:41 +02:00
|
|
|
return true;
|
|
|
|
} else {
|
2015-11-26 19:13:59 +01:00
|
|
|
QString error = fileName + QString("\n\n")
|
|
|
|
+ tr("Error loading GPX file:\n%1").arg(gpx.errorString())
|
|
|
|
+ QString("\n");
|
|
|
|
if (gpx.errorLine())
|
|
|
|
error.append(tr("Line: %1").arg(gpx.errorLine()));
|
|
|
|
|
|
|
|
QMessageBox::critical(this, tr("Error"), error);
|
2015-10-20 22:18:41 +02:00
|
|
|
return false;
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::openPOIFile()
|
|
|
|
{
|
2016-03-22 19:47:11 +01:00
|
|
|
QStringList files = QFileDialog::getOpenFileNames(this, tr("Open POI file"),
|
2016-02-12 20:12:37 +01:00
|
|
|
QString(), tr("GPX files (*.gpx);;CSV files (*.csv);;All files (*)"));
|
2016-03-22 19:47:11 +01:00
|
|
|
QStringList list = files;
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2016-03-22 19:47:11 +01:00
|
|
|
for (QStringList::Iterator it = list.begin(); it != list.end(); it++)
|
|
|
|
openPOIFile(*it);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GUI::openPOIFile(const QString &fileName)
|
|
|
|
{
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!_poi.loadFile(fileName)) {
|
|
|
|
QString error = tr("Error loading POI file:\n%1")
|
|
|
|
.arg(_poi.errorString()) + QString("\n");
|
|
|
|
if (_poi.errorLine())
|
|
|
|
error.append(tr("Line: %1").arg(_poi.errorLine()));
|
|
|
|
QMessageBox::critical(this, tr("Error"), error);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
_showPOIAction->setChecked(true);
|
|
|
|
_track->loadPOI(_poi);
|
2016-08-02 20:46:22 +02:00
|
|
|
QAction *action = createPOIFileAction(_poi.files().indexOf(fileName));
|
|
|
|
action->setChecked(true);
|
|
|
|
_poiFilesMenu->addAction(action);
|
2016-03-22 19:47:11 +01:00
|
|
|
|
|
|
|
return true;
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-05 18:01:13 +01:00
|
|
|
void GUI::closePOIFiles()
|
|
|
|
{
|
|
|
|
_poiFilesMenu->clear();
|
|
|
|
|
|
|
|
for (int i = 0; i < _poiFilesActions.count(); i++)
|
|
|
|
delete _poiFilesActions[i];
|
|
|
|
_poiFilesActions.clear();
|
|
|
|
|
|
|
|
_track->clearPOI();
|
|
|
|
|
|
|
|
_poi.clear();
|
|
|
|
}
|
|
|
|
|
2016-05-15 22:38:15 +02:00
|
|
|
void GUI::printFile()
|
|
|
|
{
|
|
|
|
QPrinter printer(QPrinter::HighResolution);
|
2016-05-24 03:01:22 +02:00
|
|
|
QPrintDialog dialog(&printer, this);
|
2016-05-15 22:38:15 +02:00
|
|
|
|
2016-05-24 03:01:22 +02:00
|
|
|
if (dialog.exec() == QDialog::Accepted)
|
2016-05-15 22:38:15 +02:00
|
|
|
plot(&printer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::exportFile()
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
|
|
|
QPrinter printer(QPrinter::HighResolution);
|
2016-05-27 22:45:58 +02:00
|
|
|
printer.setCreator(QString(APP_NAME) + QString(" ") + QString(APP_VERSION));
|
2016-05-25 23:27:07 +02:00
|
|
|
printer.setOrientation(_exportOrientation);
|
|
|
|
printer.setOutputFileName(_exportFileName);
|
|
|
|
printer.setPaperSize(_exportPaperSize);
|
2016-05-27 22:45:58 +02:00
|
|
|
printer.setPageMargins(_exportMargins.left(), _exportMargins.top(),
|
|
|
|
_exportMargins.right(), _exportMargins.bottom(), QPrinter::Millimeter);
|
2016-05-24 03:01:22 +02:00
|
|
|
ExportDialog dialog(&printer, this);
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2016-05-25 23:27:07 +02:00
|
|
|
if (dialog.exec() == QDialog::Accepted) {
|
|
|
|
_exportFileName = printer.outputFileName();
|
|
|
|
_exportPaperSize = printer.paperSize();
|
|
|
|
_exportOrientation = printer.orientation();
|
2016-05-27 22:45:58 +02:00
|
|
|
printer.getPageMargins(&(_exportMargins.rleft()),
|
|
|
|
&(_exportMargins.rtop()), &(_exportMargins.rright()),
|
|
|
|
&(_exportMargins.rbottom()), QPrinter::Millimeter);
|
2016-05-24 03:01:22 +02:00
|
|
|
plot(&printer);
|
2016-05-25 23:27:07 +02:00
|
|
|
}
|
2016-05-15 22:38:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::plot(QPrinter *printer)
|
|
|
|
{
|
|
|
|
QPainter p(printer);
|
2016-05-12 09:03:05 +02:00
|
|
|
TrackInfo info;
|
2016-05-25 23:27:07 +02:00
|
|
|
qreal ih, gh, mh, ratio;
|
2016-08-09 23:08:49 +02:00
|
|
|
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
2016-08-10 20:36:09 +02:00
|
|
|
qreal d = distance();
|
|
|
|
qreal t = time();
|
2016-05-15 22:38:15 +02:00
|
|
|
|
2016-05-21 16:10:24 +02:00
|
|
|
if (_dateRange.first.isValid()) {
|
|
|
|
if (_dateRange.first == _dateRange.second) {
|
|
|
|
QString format = QLocale::system().dateFormat(QLocale::LongFormat);
|
|
|
|
info.insert(tr("Date"), _dateRange.first.toString(format));
|
|
|
|
} else {
|
|
|
|
QString format = QLocale::system().dateFormat(QLocale::ShortFormat);
|
|
|
|
info.insert(tr("Date"), QString("%1 - %2")
|
|
|
|
.arg(_dateRange.first.toString(format),
|
|
|
|
_dateRange.second.toString(format)));
|
|
|
|
}
|
|
|
|
}
|
2016-08-09 23:08:49 +02:00
|
|
|
|
2016-08-10 08:20:24 +02:00
|
|
|
if (_trackCount > 1)
|
2016-08-09 23:08:49 +02:00
|
|
|
info.insert(tr("Tracks"), QString::number(_trackCount));
|
2016-08-10 08:20:24 +02:00
|
|
|
if (_routeCount > 1)
|
2016-08-09 23:08:49 +02:00
|
|
|
info.insert(tr("Routes"), QString::number(_routeCount));
|
2016-08-10 08:20:24 +02:00
|
|
|
if (_waypointCount > 2)
|
2016-08-09 23:08:49 +02:00
|
|
|
info.insert(tr("Waypoints"), QString::number(_waypointCount));
|
|
|
|
|
2016-08-10 20:36:09 +02:00
|
|
|
if (d > 0)
|
|
|
|
info.insert(tr("Distance"), ::distance(d, units));
|
|
|
|
if (t > 0)
|
|
|
|
info.insert(tr("Time"), ::timeSpan(t));
|
2016-05-21 16:10:24 +02:00
|
|
|
|
2016-05-12 09:03:05 +02:00
|
|
|
|
2016-05-25 23:27:07 +02:00
|
|
|
ratio = p.paintEngine()->paintDevice()->logicalDpiX() / SCREEN_DPI;
|
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;
|
2016-05-22 15:47:23 +02:00
|
|
|
info.plot(&p, QRectF(0, 0, printer->width(), ih));
|
2016-05-21 16:10:24 +02:00
|
|
|
}
|
|
|
|
if (_trackGraphs->isVisible()) {
|
2016-05-24 03:01:22 +02:00
|
|
|
qreal r = (((qreal)(printer)->width()) / (qreal)(printer->height()));
|
|
|
|
gh = (printer->width() > printer->height())
|
|
|
|
? 0.15 * r * (printer->height() - ih - 2*mh)
|
|
|
|
: 0.15 * (printer->height() - ih - 2*mh);
|
2016-05-25 23:27:07 +02:00
|
|
|
gh = qMax(gh, ratio * 150);
|
2016-08-09 01:16:19 +02:00
|
|
|
GraphTab *gt = static_cast<GraphTab*>(_trackGraphs->currentWidget());
|
|
|
|
gt->plot(&p, QRectF(0, printer->height() - gh, printer->width(), gh));
|
2016-05-24 03:01:22 +02:00
|
|
|
} else
|
|
|
|
gh = 0;
|
|
|
|
_track->plot(&p, QRectF(0, ih + mh, printer->width(), printer->height()
|
|
|
|
- (ih + 2*mh + gh)));
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2015-10-20 22:18:41 +02:00
|
|
|
void GUI::reloadFile()
|
|
|
|
{
|
2016-02-29 09:04:36 +01:00
|
|
|
_trackCount = 0;
|
2016-08-09 23:08:49 +02:00
|
|
|
_routeCount = 0;
|
|
|
|
_waypointCount = 0;
|
2016-08-10 20:36:09 +02:00
|
|
|
_trackDistance = 0;
|
|
|
|
_routeDistance = 0;
|
|
|
|
_time = 0;
|
|
|
|
_dateRange = DateRange(QDate(), QDate());
|
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();
|
2015-10-20 22:18:41 +02:00
|
|
|
_track->clear();
|
|
|
|
|
2016-06-06 20:38:10 +02:00
|
|
|
_sliderPos = 0;
|
|
|
|
|
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();
|
2016-03-25 09:50:19 +01:00
|
|
|
updateGraphTabs();
|
|
|
|
updateTrackView();
|
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;
|
2016-08-10 20:36:09 +02:00
|
|
|
_trackDistance = 0;
|
|
|
|
_routeDistance = 0;
|
|
|
|
_time = 0;
|
|
|
|
_dateRange = DateRange(QDate(), QDate());
|
2015-10-12 01:12:12 +02:00
|
|
|
|
2016-03-30 20:50:51 +02:00
|
|
|
_sliderPos = 0;
|
|
|
|
|
2016-06-24 00:55:44 +02:00
|
|
|
for (int i = 0; i < _tabs.count(); i++)
|
|
|
|
_tabs.at(i)->clear();
|
2015-10-05 01:43:48 +02:00
|
|
|
_track->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();
|
2016-03-25 09:50:19 +01:00
|
|
|
updateTrackView();
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2015-11-24 00:24:26 +01:00
|
|
|
void GUI::showPOI(bool checked)
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2015-11-24 00:24:26 +01:00
|
|
|
if (checked)
|
2015-10-05 01:43:48 +02:00
|
|
|
_track->loadPOI(_poi);
|
|
|
|
else
|
|
|
|
_track->clearPOI();
|
|
|
|
}
|
|
|
|
|
2015-11-24 00:24:26 +01:00
|
|
|
void GUI::showMap(bool checked)
|
2015-11-23 02:37:08 +01:00
|
|
|
{
|
2015-11-24 00:24:26 +01:00
|
|
|
if (checked)
|
2015-11-23 02:37:08 +01:00
|
|
|
_track->setMap(_currentMap);
|
|
|
|
else
|
|
|
|
_track->setMap(0);
|
|
|
|
}
|
2015-10-20 22:18:41 +02:00
|
|
|
|
2015-11-24 00:24:26 +01:00
|
|
|
void GUI::showGraphs(bool checked)
|
|
|
|
{
|
|
|
|
_trackGraphs->setHidden(!checked);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::showToolbars(bool checked)
|
|
|
|
{
|
|
|
|
if (checked) {
|
|
|
|
addToolBar(_fileToolBar);
|
|
|
|
addToolBar(_showToolBar);
|
2015-12-19 08:29:31 +01:00
|
|
|
addToolBar(_navigationToolBar);
|
2015-11-24 00:24:26 +01:00
|
|
|
_fileToolBar->show();
|
|
|
|
_showToolBar->show();
|
2015-12-18 22:21:11 +01:00
|
|
|
_navigationToolBar->show();
|
2015-11-24 00:24:26 +01:00
|
|
|
} else {
|
|
|
|
removeToolBar(_fileToolBar);
|
|
|
|
removeToolBar(_showToolBar);
|
2015-12-18 22:21:11 +01:00
|
|
|
removeToolBar(_navigationToolBar);
|
2015-11-24 00:24:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-05 09:10:19 +02:00
|
|
|
void GUI::showFullscreen(bool checked)
|
|
|
|
{
|
|
|
|
if (checked) {
|
|
|
|
_frameStyle = _track->frameStyle();
|
|
|
|
_showGraphs = _showGraphsAction->isChecked();
|
|
|
|
|
|
|
|
statusBar()->hide();
|
|
|
|
menuBar()->hide();
|
|
|
|
showToolbars(false);
|
|
|
|
showGraphs(false);
|
|
|
|
_showGraphsAction->setChecked(false);
|
|
|
|
_track->setFrameStyle(QFrame::NoFrame);
|
|
|
|
|
|
|
|
showFullScreen();
|
|
|
|
} else {
|
|
|
|
statusBar()->show();
|
|
|
|
menuBar()->show();
|
|
|
|
if (_showToolbarsAction->isChecked())
|
|
|
|
showToolbars(true);
|
|
|
|
_showGraphsAction->setChecked(_showGraphs);
|
|
|
|
if (_showGraphsAction->isEnabled())
|
|
|
|
showGraphs(_showGraphs);
|
|
|
|
_track->setFrameStyle(_frameStyle);
|
|
|
|
|
|
|
|
showNormal();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-10 20:36:09 +02:00
|
|
|
void GUI::showTracks(bool show)
|
2016-08-09 01:16:19 +02:00
|
|
|
{
|
2016-08-10 20:36:09 +02:00
|
|
|
_track->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();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::showRoutes(bool show)
|
|
|
|
{
|
|
|
|
_track->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();
|
2016-08-09 01:16:19 +02:00
|
|
|
}
|
|
|
|
|
2016-04-01 19:25:34 +02:00
|
|
|
void GUI::clearMapCache()
|
|
|
|
{
|
|
|
|
_currentMap->clearCache();
|
|
|
|
_track->redraw();
|
|
|
|
}
|
|
|
|
|
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)
|
2016-03-25 09:50:19 +01:00
|
|
|
_fileNameLabel->setText(tr("No GPX 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-08-09 23:08:49 +02:00
|
|
|
_fileNameLabel->setText(tr("%1 files").arg(_files.count()));
|
2015-10-17 12:08:30 +02:00
|
|
|
|
2016-08-10 21:17:12 +02:00
|
|
|
qreal d = distance();
|
2016-07-25 19:32:36 +02:00
|
|
|
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
2016-08-10 21:17:12 +02:00
|
|
|
if (d > 0)
|
|
|
|
_distanceLabel->setText(::distance(distance(), units));
|
|
|
|
else
|
|
|
|
_distanceLabel->clear();
|
|
|
|
|
|
|
|
qreal t = time();
|
|
|
|
if (t > 0)
|
|
|
|
_timeLabel->setText(::timeSpan(time()));
|
|
|
|
else
|
|
|
|
_timeLabel->clear();
|
2015-10-17 12:08:30 +02:00
|
|
|
}
|
|
|
|
|
2016-04-19 08:51:11 +02:00
|
|
|
void GUI::updateWindowTitle()
|
|
|
|
{
|
|
|
|
if (_files.count() == 1)
|
|
|
|
setWindowTitle(QFileInfo(_files.at(0)).fileName()
|
|
|
|
+ QString(" - " APP_NAME));
|
|
|
|
else
|
|
|
|
setWindowTitle(APP_NAME);
|
|
|
|
}
|
|
|
|
|
2015-11-23 02:37:08 +01:00
|
|
|
void GUI::mapChanged(int index)
|
|
|
|
{
|
|
|
|
_currentMap = _maps.at(index);
|
|
|
|
|
|
|
|
if (_showMapAction->isChecked())
|
|
|
|
_track->setMap(_currentMap);
|
|
|
|
}
|
|
|
|
|
2016-04-08 22:33:19 +02:00
|
|
|
void GUI::nextMap()
|
|
|
|
{
|
|
|
|
if (_maps.count() < 2)
|
|
|
|
return;
|
|
|
|
int next = (_maps.indexOf(_currentMap) + 1) % _maps.count();
|
|
|
|
_mapActions.at(next)->setChecked(true);
|
|
|
|
mapChanged(next);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::prevMap()
|
|
|
|
{
|
|
|
|
if (_maps.count() < 2)
|
|
|
|
return;
|
|
|
|
int prev = (_maps.indexOf(_currentMap) + _maps.count() - 1) % _maps.count();
|
|
|
|
_mapActions.at(prev)->setChecked(true);
|
|
|
|
mapChanged(prev);
|
|
|
|
}
|
|
|
|
|
2016-03-05 18:01:13 +01:00
|
|
|
void GUI::poiFileChecked(int index)
|
|
|
|
{
|
|
|
|
_poi.enableFile(_poi.files().at(index),
|
|
|
|
_poiFilesActions.at(index)->isChecked());
|
2016-03-19 09:05:40 +01:00
|
|
|
|
2016-03-05 18:01:13 +01:00
|
|
|
_track->clearPOI();
|
2016-03-19 09:05:40 +01:00
|
|
|
if (_showPOIAction->isChecked())
|
|
|
|
_track->loadPOI(_poi);
|
2016-03-05 18:01:13 +01:00
|
|
|
}
|
|
|
|
|
2016-03-30 20:50:51 +02:00
|
|
|
void GUI::sliderPositionChanged(qreal pos)
|
|
|
|
{
|
|
|
|
_sliderPos = pos;
|
2016-03-30 23:07:54 +02:00
|
|
|
_track->movePositionMarker(_sliderPos);
|
2016-03-30 20:50:51 +02:00
|
|
|
}
|
|
|
|
|
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-08-09 01:16:19 +02:00
|
|
|
GraphTab *gt = static_cast<GraphTab*>(_trackGraphs->widget(index));
|
|
|
|
gt->setSliderPosition(_sliderPos);
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2015-12-18 22:21:11 +01:00
|
|
|
void GUI::updateNavigationActions()
|
|
|
|
{
|
|
|
|
if (_browser->isLast()) {
|
|
|
|
_nextAction->setEnabled(false);
|
|
|
|
_lastAction->setEnabled(false);
|
|
|
|
} else {
|
|
|
|
_nextAction->setEnabled(true);
|
|
|
|
_lastAction->setEnabled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_browser->isFirst()) {
|
|
|
|
_prevAction->setEnabled(false);
|
|
|
|
_firstAction->setEnabled(false);
|
|
|
|
} else {
|
|
|
|
_prevAction->setEnabled(true);
|
|
|
|
_firstAction->setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-23 09:38:22 +01:00
|
|
|
void GUI::updateGraphTabs()
|
|
|
|
{
|
2016-03-24 20:50:11 +01:00
|
|
|
int index;
|
2016-06-24 00:55:44 +02:00
|
|
|
GraphTab *tab;
|
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);
|
|
|
|
if (!tab->count() && (index = _trackGraphs->indexOf(tab)) >= 0)
|
2016-03-24 20:50:11 +01:00
|
|
|
_trackGraphs->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);
|
|
|
|
if (tab->count() && _trackGraphs->indexOf(tab) < 0)
|
|
|
|
_trackGraphs->insertTab(i, tab, _tabs.at(i)->label());
|
2016-03-24 20:50:11 +01:00
|
|
|
}
|
|
|
|
|
2016-04-05 09:10:19 +02:00
|
|
|
if (_trackGraphs->count()) {
|
|
|
|
if (_showGraphsAction->isChecked())
|
|
|
|
_trackGraphs->setHidden(false);
|
|
|
|
_showGraphsAction->setEnabled(true);
|
|
|
|
} else {
|
|
|
|
_trackGraphs->setHidden(true);
|
|
|
|
_showGraphsAction->setEnabled(false);
|
2016-03-24 20:50:11 +01:00
|
|
|
}
|
2016-03-23 09:38:22 +01:00
|
|
|
}
|
|
|
|
|
2016-03-25 09:50:19 +01:00
|
|
|
void GUI::updateTrackView()
|
|
|
|
{
|
2016-08-09 01:16:19 +02:00
|
|
|
_track->setHidden(!(_track->trackCount() + _track->routeCount()
|
|
|
|
+ _track->waypointCount()));
|
2016-03-25 09:50:19 +01:00
|
|
|
}
|
|
|
|
|
2015-12-19 20:23:07 +01:00
|
|
|
void GUI::setMetricUnits()
|
|
|
|
{
|
2016-01-14 00:37:51 +01:00
|
|
|
_track->setUnits(Metric);
|
2016-06-24 00:55:44 +02:00
|
|
|
for (int i = 0; i <_tabs.count(); i++)
|
|
|
|
_tabs.at(i)->setUnits(Metric);
|
2015-12-19 20:23:07 +01:00
|
|
|
updateStatusBarInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::setImperialUnits()
|
|
|
|
{
|
2016-01-14 00:37:51 +01:00
|
|
|
_track->setUnits(Imperial);
|
2016-06-24 00:55:44 +02:00
|
|
|
for (int i = 0; i <_tabs.count(); i++)
|
|
|
|
_tabs.at(i)->setUnits(Imperial);
|
2015-12-19 20:23:07 +01:00
|
|
|
updateStatusBarInfo();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
case Qt::Key_Escape:
|
|
|
|
if (_fullscreenAction->isChecked()) {
|
|
|
|
_fullscreenAction->setChecked(false);
|
|
|
|
showFullscreen(false);
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
2016-04-26 09:39:16 +02:00
|
|
|
|
|
|
|
void GUI::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
|
|
|
writeSettings();
|
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::writeSettings()
|
|
|
|
{
|
2016-04-26 20:55:29 +02:00
|
|
|
QSettings settings(APP_NAME, APP_NAME);
|
2016-04-26 09:39:16 +02:00
|
|
|
|
2016-04-28 08:49:06 +02:00
|
|
|
settings.beginGroup(WINDOW_SETTINGS_GROUP);
|
|
|
|
settings.setValue(WINDOW_SIZE_SETTING, size());
|
|
|
|
settings.setValue(WINDOW_POS_SETTING, pos());
|
2016-04-26 09:39:16 +02:00
|
|
|
settings.endGroup();
|
|
|
|
|
2016-04-28 08:49:06 +02:00
|
|
|
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
|
|
|
|
settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked()
|
2016-04-26 09:39:16 +02:00
|
|
|
? Imperial : Metric);
|
2016-04-28 08:49:06 +02:00
|
|
|
settings.setValue(SHOW_TOOLBARS_SETTING, _showToolbarsAction->isChecked());
|
|
|
|
settings.setValue(SHOW_GRAPHS_SETTING, _showGraphsAction->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);
|
|
|
|
if (_currentMap)
|
|
|
|
settings.setValue(CURRENT_MAP_SETTING, _currentMap->name());
|
|
|
|
settings.setValue(SHOW_MAP_SETTING, _showMapAction->isChecked());
|
2016-04-26 20:55:29 +02:00
|
|
|
settings.endGroup();
|
|
|
|
|
2016-04-28 08:49:06 +02:00
|
|
|
settings.beginGroup(POI_SETTINGS_GROUP);
|
|
|
|
settings.setValue(SHOW_POI_SETTING, _showPOIAction->isChecked());
|
2016-08-02 20:46:22 +02:00
|
|
|
settings.setValue(OVERLAP_POI_SETTING, _overlapPOIAction->isChecked());
|
2016-04-28 08:49:06 +02:00
|
|
|
|
|
|
|
settings.remove(DISABLED_POI_FILE_SETTINGS_PREFIX);
|
|
|
|
settings.beginWriteArray(DISABLED_POI_FILE_SETTINGS_PREFIX);
|
|
|
|
for (int i = 0, j = 0; i < _poiFilesActions.count(); i++) {
|
|
|
|
if (!_poiFilesActions.at(i)->isChecked()) {
|
|
|
|
settings.setArrayIndex(j++);
|
|
|
|
settings.setValue(DISABLED_POI_FILE_SETTING, _poi.files().at(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
settings.setValue(SHOW_TRACKS_SETTING, _showTracksAction->isChecked());
|
|
|
|
settings.setValue(SHOW_ROUTES_SETTING, _showRoutesAction->isChecked());
|
|
|
|
settings.setValue(SHOW_WAYPOINTS_SETTING,
|
|
|
|
_showWaypointsAction->isChecked());
|
|
|
|
settings.setValue(SHOW_WAYPOINT_LABELS_SETTING,
|
|
|
|
_showWaypointLabelsAction->isChecked());
|
2016-08-09 10:47:49 +02:00
|
|
|
settings.setValue(SHOW_ROUTE_WAYPOINTS_SETTING,
|
|
|
|
_showRouteWaypointsAction->isChecked());
|
2016-08-09 01:16:19 +02:00
|
|
|
|
|
|
|
settings.endGroup();
|
2016-04-26 09:39:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GUI::readSettings()
|
|
|
|
{
|
2016-04-26 20:55:29 +02:00
|
|
|
QSettings settings(APP_NAME, APP_NAME);
|
2016-04-26 09:39:16 +02:00
|
|
|
|
2016-04-28 08:49:06 +02:00
|
|
|
settings.beginGroup(WINDOW_SETTINGS_GROUP);
|
|
|
|
resize(settings.value(WINDOW_SIZE_SETTING, QSize(600, 800)).toSize());
|
|
|
|
move(settings.value(WINDOW_POS_SETTING, QPoint(10, 10)).toPoint());
|
2016-04-26 09:39:16 +02:00
|
|
|
settings.endGroup();
|
|
|
|
|
2016-04-28 08:49:06 +02:00
|
|
|
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
|
2016-05-21 16:10:24 +02:00
|
|
|
Units u = QLocale::system().measurementSystem() == QLocale::ImperialSystem
|
|
|
|
? Imperial : Metric;
|
|
|
|
if (settings.value(UNITS_SETTING, u).toInt() == Imperial) {
|
2016-04-26 09:39:16 +02:00
|
|
|
setImperialUnits();
|
|
|
|
_imperialUnitsAction->setChecked(true);
|
|
|
|
} else
|
|
|
|
_metricUnitsAction->setChecked(true);
|
2016-08-09 01:16:19 +02:00
|
|
|
if (settings.value(SHOW_TOOLBARS_SETTING, true).toBool() == false)
|
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);
|
2016-08-09 01:16:19 +02:00
|
|
|
if (settings.value(SHOW_GRAPHS_SETTING, true).toBool() == false)
|
2016-04-26 09:39:16 +02:00
|
|
|
showGraphs(false);
|
2016-08-09 01:16:19 +02:00
|
|
|
else
|
2016-04-26 09:39:16 +02:00
|
|
|
_showGraphsAction->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);
|
|
|
|
if (settings.value(SHOW_MAP_SETTING, true).toBool() == true)
|
2016-04-26 20:55:29 +02:00
|
|
|
_showMapAction->setChecked(true);
|
|
|
|
if (_maps.count()) {
|
2016-04-28 08:49:06 +02:00
|
|
|
int index = mapIndex(settings.value(CURRENT_MAP_SETTING).toString());
|
2016-04-26 20:55:29 +02:00
|
|
|
_mapActions.at(index)->setChecked(true);
|
|
|
|
_currentMap = _maps.at(index);
|
|
|
|
if (_showMapAction->isChecked())
|
|
|
|
_track->setMap(_currentMap);
|
|
|
|
} else
|
|
|
|
_currentMap = 0;
|
|
|
|
settings.endGroup();
|
|
|
|
|
2016-04-28 08:49:06 +02:00
|
|
|
settings.beginGroup(POI_SETTINGS_GROUP);
|
2016-08-09 01:16:19 +02:00
|
|
|
if (settings.value(OVERLAP_POI_SETTING, true).toBool() == false)
|
2016-08-02 20:46:22 +02:00
|
|
|
_track->setPOIOverlap(false);
|
2016-08-09 01:16:19 +02:00
|
|
|
else
|
2016-08-02 20:46:22 +02:00
|
|
|
_overlapPOIAction->setChecked(true);
|
2016-08-09 01:16:19 +02:00
|
|
|
if (settings.value(LABELS_POI_SETTING, true).toBool() == false)
|
|
|
|
_track->showPOILabels(false);
|
|
|
|
else
|
|
|
|
_showPOILabelsAction->setChecked(true);
|
2016-04-28 08:49:06 +02:00
|
|
|
if (settings.value(SHOW_POI_SETTING, false).toBool() == true)
|
2016-04-26 20:55:29 +02:00
|
|
|
_showPOIAction->setChecked(true);
|
2016-04-28 08:49:06 +02:00
|
|
|
for (int i = 0; i < _poiFilesActions.count(); i++)
|
|
|
|
_poiFilesActions.at(i)->setChecked(true);
|
|
|
|
int size = settings.beginReadArray(DISABLED_POI_FILE_SETTINGS_PREFIX);
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
settings.setArrayIndex(i);
|
|
|
|
int index = _poi.files().indexOf(settings.value(
|
|
|
|
DISABLED_POI_FILE_SETTING).toString());
|
|
|
|
if (index >= 0) {
|
|
|
|
_poi.enableFile(_poi.files().at(index), false);
|
|
|
|
_poiFilesActions.at(index)->setChecked(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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-08-16 00:27:54 +02:00
|
|
|
if (settings.value(SHOW_TRACKS_SETTING, true).toBool() == false) {
|
2016-08-09 01:16:19 +02:00
|
|
|
_track->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-08-16 00:27:54 +02:00
|
|
|
if (settings.value(SHOW_ROUTES_SETTING, true).toBool() == false) {
|
2016-08-09 01:16:19 +02:00
|
|
|
_track->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);
|
|
|
|
if (settings.value(SHOW_WAYPOINTS_SETTING, true).toBool() == false)
|
|
|
|
_track->showWaypoints(false);
|
|
|
|
else
|
|
|
|
_showWaypointsAction->setChecked(true);
|
|
|
|
if (settings.value(SHOW_WAYPOINT_LABELS_SETTING, true).toBool() == false)
|
|
|
|
_track->showWaypointLabels(false);
|
|
|
|
else
|
|
|
|
_showWaypointLabelsAction->setChecked(true);
|
2016-08-09 10:47:49 +02:00
|
|
|
if (settings.value(SHOW_ROUTE_WAYPOINTS_SETTING, true).toBool() == false)
|
|
|
|
_track->showRouteWaypoints(false);
|
|
|
|
else
|
|
|
|
_showRouteWaypointsAction->setChecked(true);
|
2016-08-09 01:16:19 +02:00
|
|
|
settings.endGroup();
|
2016-04-26 20:55:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int GUI::mapIndex(const QString &name)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < _maps.count(); i++)
|
|
|
|
if (_maps.at(i)->name() == name)
|
|
|
|
return i;
|
|
|
|
|
|
|
|
return 0;
|
2016-04-26 09:39:16 +02:00
|
|
|
}
|
2016-08-10 20:36:09 +02:00
|
|
|
|
|
|
|
qreal GUI::distance()
|
|
|
|
{
|
|
|
|
qreal dist = 0;
|
|
|
|
|
|
|
|
if (_showTracksAction->isChecked())
|
|
|
|
dist += _trackDistance;
|
|
|
|
if (_showRoutesAction->isChecked())
|
|
|
|
dist += _routeDistance;
|
|
|
|
|
|
|
|
return dist;
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal GUI::time()
|
|
|
|
{
|
|
|
|
return (_showTracksAction->isChecked()) ? _time : 0;
|
|
|
|
}
|