From 7ac94588c8aaeea7ddcc515cc89e03d6b498f79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Fri, 18 Dec 2015 22:21:11 +0100 Subject: [PATCH] Added navigation toolbar --- gpxsee.qrc | 4 + icons/arrow-left-double.png | Bin 0 -> 926 bytes icons/arrow-left.png | Bin 0 -> 707 bytes icons/arrow-right-double.png | Bin 0 -> 924 bytes icons/arrow-right.png | Bin 0 -> 682 bytes lang/gpxsee_cs.ts | 155 +++++++++++++++++++++-------------- src/filebrowser.cpp | 28 +++++++ src/filebrowser.h | 5 ++ src/gui.cpp | 122 +++++++++++++++++++++++++-- src/gui.h | 12 +++ src/icons.h | 4 + src/keys.h | 2 + 12 files changed, 266 insertions(+), 66 deletions(-) create mode 100644 icons/arrow-left-double.png create mode 100644 icons/arrow-left.png create mode 100644 icons/arrow-right-double.png create mode 100644 icons/arrow-right.png diff --git a/gpxsee.qrc b/gpxsee.qrc index 01939195..d24494c6 100644 --- a/gpxsee.qrc +++ b/gpxsee.qrc @@ -9,6 +9,10 @@ icons/application-exit.png icons/applications-internet.png icons/view-refresh.png + icons/arrow-left.png + icons/arrow-right.png + icons/arrow-left-double.png + icons/arrow-right-double.png lang/gpxsee_cs.qm diff --git a/icons/arrow-left-double.png b/icons/arrow-left-double.png new file mode 100644 index 0000000000000000000000000000000000000000..1422338f7277561c05baf8b3a4be4ecd8fdbad5b GIT binary patch literal 926 zcmV;P17ZA$P)B)mZ#3DVELZOr%3LbLl#e*Q?$xAP#7sVb#E3HBdHr?#MnN4=* zz4z;5W@rclnutPw!PTjuB3 zrJ?gftA#U#^E(E!Q*36Bv**#}3zrW+UVc0h%*`;%K$ohM)o&K27mD>peF0He+k{@4 zs7!o)dhWEvZH|@tiZt#=Q-#!>x#_v_vGN$|D|LVYZw5z>kj2fDQzyTeIy%K%--YZ- zkf7XvGw`r_tXgnV4r;9$B$EK&2AIuj@1M^6;f{pkRzn1VEyB8AGw6*Og&N#Eo>1+}42NEcoYX6M+K zBSWPdhYx;Y`N9t!2?OOafE#e&Txl~(Gx{okXEWK@8E>BF5MSC`+;?{W-U{5F%OshN zw%KSIh>&3c$Sv?dN}(i500)bKt+M?~CHvu#Tq=i#*9hF`lm>AM+)B%cMXsY`AweKU z&|Kq5<0-&c9Bl6RUoW4d)9}D|aqv6`wlrpjrwk(WzBm%r{2WFndUJ&`r z|FkpMxs^T8Pb|SGXx%cbi4MgJ6Bc0JcBs7yOUs2Kh($07*qoM6N<$g0%0n AIsgCw literal 0 HcmV?d00001 diff --git a/icons/arrow-left.png b/icons/arrow-left.png new file mode 100644 index 0000000000000000000000000000000000000000..9988dd35a904b9ba4134ff143dd1faffc9cd3c53 GIT binary patch literal 707 zcmV;!0zCbRP)k=W~* z>6t_{9>r#56UH|vwMqncpD@kQ&2&2ba6C6|kwa9d72ru3HmG`4f)gCxd7r27GBcRH zI+8h#im8yP8F)%iC6i=I!370|=>qlZob_%vd2BS5N}*UU!t(^O1hiyonc9Prf<-D2 zOxLNeD;oYZ6v@W5(kNDoFvfsghEG0N%hZ0mLv{!v1cPBf#_?$B>k?|F1|8F|;uicK zA0}+T-3)XAaOF~Rvq6Cl2*2XBW~hGB9QD6MkHp%K+@JX zCy$@;N~_rzEp?aQqF1r)*bFfcl6LS1R}m$;3J$mN=WO_~nS;i?aH7YA-7rHzAZc6L z1$0;k-FSESiFbdiSURtiT~63Z1_Qrak@BH~!@KcEW}&>kb)r(Pf9uBps7^o?(6tUW z-obgf{$YD~HNUnnP#a|Dr^BkG2#Pv`+xQ!9`L~+W%PZd>^p;XyqM0N}9oYAn@3d~` p*HZZ%aKcK5xXr!xH2-Pyg*140J%;e78kMnxw zp20*W$SBS8@^BC5a)0mhp2fMu%-9GCtPvUg?_ipsnWNW^dh{(_!5TRyokxXBg*lp{ z9q*So!1>|r!`boC@jG;!9@1B&V3bOw_Fb5|P}teO^NDGC6w<;Ok>BL$j1GJV#~ zyN_Eb*(h)VTs(g8BC5(7P7tBKj`H8=dRW!4k=7NmO?^GW0Fup zL9w!Xrj#kE&B~E<`18X9kDvTLOVf0ff8x9Ag9Rv*1{@l2Bq3vCEiF_hKnsqQeHWQ^ zr0C$#0i~q6O*8TnJk#g+R}S9aR03RuJI0amN;`RA_uP!D zot|`DDOIlX{rD!VI>AyZn@qN0Y4iBNLFk4yZQS0Mz@~JTv2*Mt`}V^Tn+(Ji4i`g%cLq z-6ce>$N;Y5qQCga|FgQEZ}8uer1-Et25^JRHTzVg>!c9;==8P%g(U#lWx*P&tMJBlqD?Q zU3Bsz`4zfB4|)Te8p=}$5z_qZyfryC`60pI(+i>_!JKARzJjVKl!Gz~Qw1tc7oUi4 zVzqYeUBj?IDpV*1C8!`-4@ww1KZKd=!qFWfMsv3=whN`}S$OxLgGCg$4 zaaL%a9-&1Hv?ubLO^SHbK7WBcUK- z0m%|zfFgp75I^q_+@ryj2TS|0^aYzua^hpl)M&;X*O2Y~Pe4Br5|jCeN&?=tMc zEMP*keH1b!3CGZYgT`%Wtr0~LAQQ_ndEkN#ci;VpGx}cJu&BYu0aQ_k5GM_hh(N~9 zXla>;ZrOdx%kf(z>11NmCl3DOW@CfgzzGfy4$GdZ%<@va+VQIpLNvcJK$^h&go+#d zh<5yIyu^RIddHHazzzTputJN6y|aumeTv|Z^SdV6`NR-ZgLBBSv1L^^{``K%FXK08 zraM@|pb`HZT;=a=Z*9- GUI - + About Qt O Qt - + GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese - + Open file Otevřít soubor - + Save as Uložit jako - + Open POI file Otevřít POI soubor - + Open Otevřít - + Quit Ukončit - - - + + + Keyboard controls Ovládací klávesy - + Save Uložit - + Close Zavřít - + Reload Znovu načíst - + Show Zobrazit - - + + File Soubor - - - + + + Data sources Zdroje dat - + Load POI file Nahrát POI soubor - + Show POIs Zobrazit POI - + Show map Zobrazit mapu - + Show graphs Zobrazovat grafy - + Show toolbars Zobrazovat nástrojové lišty - + + Next + Následující + + + + Previous + Předchozí + + + + Last + Poslední + + + + First + První + + + Map Mapa - + POI POI - + Settings Nastavení - + Help Nápověda - + Elevation Výška - + Speed Rychlost - + Next file Následující soubor - + Previous file Předchozí soubor - + + First file + První soubor + + + + Last file + Poslední soubor + + + Append modifier Modifikátor nahradit/přidat - + Map (tiles) source URLs are read on program startup from the following file: URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru: - + 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: Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad: - + To make GPXSee load a POI file automatically on startup, add the file to the following directory: POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře: - - + + Line: %1 Řádka: %1 - + Maximum Maximum - + Minimum Minimum - - + + About GPXSee O aplikaci GPXSee - + + Navigation + Navigace + + + GPX viewer and analyzer Prohlížeč a analyzátor GPX - + Map sources Mapové zdroje - + POIs POI body - + Distance Vzdálenost - + Time Čas - + Ascent Stoupání - - - - + + + + m m - + Descent Klesání - + %1 tracks Počet tras: %1 - - + + km km - - + + Error Chyba - + Error loading GPX file: %1 Soubor GPX nelze otevřít: %1 - + Error loading POI file: %1 Soubor POI nelze otevřít: diff --git a/src/filebrowser.cpp b/src/filebrowser.cpp index f04b5f55..8caea900 100644 --- a/src/filebrowser.cpp +++ b/src/filebrowser.cpp @@ -41,6 +41,16 @@ void FileBrowser::setFilter(const QStringList &filter) reloadDirectory(_files.last().canonicalPath()); } +bool FileBrowser::isLast() +{ + return (_files.size() > 0 && _index == _files.size() - 1); +} + +bool FileBrowser::isFirst() +{ + return (_files.size() > 0 && _index == 0); +} + QString FileBrowser::next() { if (_index < 0 || _index == _files.size() - 1) @@ -57,6 +67,24 @@ QString FileBrowser::prev() return _files.at(--_index).absoluteFilePath(); } +QString FileBrowser::last() +{ + if (_files.empty()) + return QString(); + + _index = _files.size() - 1; + return _files.last().absoluteFilePath(); +} + +QString FileBrowser::first() +{ + if (_files.empty()) + return QString(); + + _index = 0; + return _files.first().absoluteFilePath(); +} + void FileBrowser::reloadDirectory(const QString &path) { QDir dir(path); diff --git a/src/filebrowser.h b/src/filebrowser.h index 2e3fadc3..267118d0 100644 --- a/src/filebrowser.h +++ b/src/filebrowser.h @@ -20,6 +20,11 @@ public: QString next(); QString prev(); + QString last(); + QString first(); + + bool isLast(); + bool isFirst(); private slots: void reloadDirectory(const QString &path); diff --git a/src/gui.cpp b/src/gui.cpp index 73c2ae02..21adb6a3 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -118,6 +118,8 @@ void GUI::createActions() _fileActionGroup->setExclusive(false); _fileActionGroup->setEnabled(false); + _navigationActionGroup = new QActionGroup(this); + _navigationActionGroup->setEnabled(false); // General actions _exitAction = new QAction(QIcon(QPixmap(QUIT_ICON)), tr("Quit"), this); @@ -191,6 +193,22 @@ void GUI::createActions() _showToolbarsAction->setChecked(true); connect(_showToolbarsAction, SIGNAL(triggered(bool)), this, SLOT(showToolbars(bool))); + + // 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())); } void GUI::createMenus() @@ -247,6 +265,12 @@ void GUI::createToolBars() #ifdef Q_OS_MAC _showToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); #endif // Q_OS_MAC + + _navigationToolBar = addToolBar(tr("Navigation")); + _navigationToolBar->addAction(_firstAction); + _navigationToolBar->addAction(_prevAction); + _navigationToolBar->addAction(_nextAction); + _navigationToolBar->addAction(_lastAction); } void GUI::createTrackView() @@ -314,8 +338,10 @@ void GUI::keys() QString("
" - "
") + tr("Next file") + QString("SPACE
") + tr("Previous file") + QString("BACKSPACE
") - + tr("Append modifier") + QString("SHIFT
")); + + tr("First file") + QString("HOME") + + tr("Last file") + QString("END" + "") + tr("Append modifier") + + QString("SHIFT")); msgBox.exec(); } @@ -368,6 +394,8 @@ bool GUI::openFile(const QString &fileName) _browser->setCurrent(fileName); updateStatusBarInfo(); _fileActionGroup->setEnabled(true); + _navigationActionGroup->setEnabled(true); + updateNavigationActions(); return true; } else return false; @@ -506,6 +534,7 @@ void GUI::closeFile() _files.clear(); _fileActionGroup->setEnabled(false); + _navigationActionGroup->setEnabled(false); updateStatusBarInfo(); } @@ -537,9 +566,11 @@ void GUI::showToolbars(bool checked) addToolBar(_showToolBar); _fileToolBar->show(); _showToolBar->show(); + _navigationToolBar->show(); } else { removeToolBar(_fileToolBar); removeToolBar(_showToolBar); + removeToolBar(_navigationToolBar); } } @@ -578,18 +609,97 @@ void GUI::graphChanged(int index) _speedGraph->setSliderPosition(_elevationGraph->sliderPosition()); } +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); + } +} + +void GUI::next() +{ + QString file = _browser->next(); + if (file.isNull()) + return; + + closeFile(); + openFile(file); + + updateNavigationActions(); +} + +void GUI::prev() +{ + QString file = _browser->prev(); + if (file.isNull()) + return; + + closeFile(); + openFile(file); + + updateNavigationActions(); +} + +void GUI::last() +{ + QString file = _browser->last(); + if (file.isNull()) + return; + + closeFile(); + openFile(file); + + updateNavigationActions(); +} + +void GUI::first() +{ + QString file = _browser->first(); + if (file.isNull()) + return; + + closeFile(); + openFile(file); + + updateNavigationActions(); +} + void GUI::keyPressEvent(QKeyEvent *event) { QString file; - if (event->key() == PREV_KEY) - file = _browser->prev(); - if (event->key() == NEXT_KEY) - file = _browser->next(); + 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; + } if (!file.isNull()) { if (!(event->modifiers() & MODIFIER)) closeFile(); openFile(file); } + + updateNavigationActions(); } diff --git a/src/gui.h b/src/gui.h index c14cfb66..049bb5c4 100644 --- a/src/gui.h +++ b/src/gui.h @@ -45,6 +45,11 @@ private slots: void mapChanged(int); void graphChanged(int); + void next(); + void prev(); + void last(); + void first(); + private: void loadFiles(); @@ -59,6 +64,7 @@ private: bool loadFile(const QString &fileName); void saveFile(const QString &fileName); void updateStatusBarInfo(); + void updateNavigationActions(); void keyPressEvent(QKeyEvent * event); @@ -70,8 +76,10 @@ private: QToolBar *_fileToolBar; QToolBar *_showToolBar; + QToolBar *_navigationToolBar; QTabWidget *_trackGraphs; QActionGroup *_fileActionGroup; + QActionGroup *_navigationActionGroup; QAction *_exitAction; QAction *_keysAction; @@ -88,6 +96,10 @@ private: QAction *_showMapAction; QAction *_showGraphsAction; QAction *_showToolbarsAction; + QAction *_nextAction; + QAction *_prevAction; + QAction *_lastAction; + QAction *_firstAction; QList _mapActions; QLabel *_fileNameLabel; diff --git a/src/icons.h b/src/icons.h index 32f8b16a..efc6b292 100644 --- a/src/icons.h +++ b/src/icons.h @@ -12,6 +12,10 @@ #define SHOW_MAP_ICON ":/icons/applications-internet.png" #define QUIT_ICON ":/icons/application-exit.png" #define RELOAD_FILE_ICON ":/icons/view-refresh.png" +#define NEXT_FILE_ICON ":/icons/arrow-right.png" +#define PREV_FILE_ICON ":/icons/arrow-left.png" +#define LAST_FILE_ICON ":/icons/arrow-right-double.png" +#define FIRST_FILE_ICON ":/icons/arrow-left-double.png" #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) #define QT_ICON ":/trolltech/qmessagebox/images/qtlogo-64.png" diff --git a/src/keys.h b/src/keys.h index 123cf41f..57576565 100644 --- a/src/keys.h +++ b/src/keys.h @@ -3,6 +3,8 @@ #define NEXT_KEY Qt::Key_Space #define PREV_KEY Qt::Key_Backspace +#define FIRST_KEY Qt::Key_Home +#define LAST_KEY Qt::Key_End #define MODIFIER Qt::ShiftModifier #endif // KEYS_H