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 00000000..1422338f Binary files /dev/null and b/icons/arrow-left-double.png differ diff --git a/icons/arrow-left.png b/icons/arrow-left.png new file mode 100644 index 00000000..9988dd35 Binary files /dev/null and b/icons/arrow-left.png differ diff --git a/icons/arrow-right-double.png b/icons/arrow-right-double.png new file mode 100644 index 00000000..80386e7a Binary files /dev/null and b/icons/arrow-right-double.png differ diff --git a/icons/arrow-right.png b/icons/arrow-right.png new file mode 100644 index 00000000..83870eea Binary files /dev/null and b/icons/arrow-right.png differ diff --git a/lang/gpxsee_cs.ts b/lang/gpxsee_cs.ts index c19f504b..d2c5f07e 100644 --- a/lang/gpxsee_cs.ts +++ b/lang/gpxsee_cs.ts @@ -47,256 +47,291 @@ 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