diff --git a/icons/GUI/FlatColor/actions/22x22/document-open-recent.svg b/icons/GUI/FlatColor/actions/22x22/document-open-recent.svg
new file mode 100644
index 00000000..648f5cad
--- /dev/null
+++ b/icons/GUI/FlatColor/actions/22x22/document-open-recent.svg
@@ -0,0 +1,4 @@
+
diff --git a/icons/GUI/Papirus/actions/22x22/document-open-recent.svg b/icons/GUI/Papirus/actions/22x22/document-open-recent.svg
new file mode 100644
index 00000000..01364f89
--- /dev/null
+++ b/icons/GUI/Papirus/actions/22x22/document-open-recent.svg
@@ -0,0 +1,10 @@
+
diff --git a/src/GUI/gui.cpp b/src/GUI/gui.cpp
index df4f640e..4149760d 100644
--- a/src/GUI/gui.cpp
+++ b/src/GUI/gui.cpp
@@ -59,12 +59,13 @@
#include "gui.h"
+#define MAX_RECENT_FILES 10
#define TOOLBAR_ICON_SIZE 22
GUI::GUI()
{
QString activeMap;
- QStringList disabledPOIs;
+ QStringList disabledPOIs, recentFiles;
_poi = new POI(this);
_dem = new DEMLoader(ProgramPaths::demDir(true), this);
@@ -108,10 +109,13 @@ GUI::GUI()
_movingTime = 0;
_lastTab = 0;
- readSettings(activeMap, disabledPOIs);
+ readSettings(activeMap, disabledPOIs, recentFiles);
loadInitialMaps(activeMap);
loadInitialPOIs(disabledPOIs);
+#ifndef Q_OS_ANDROID
+ loadRecentFiles(recentFiles);
+#endif // Q_OS_ANDROID
updateGraphTabs();
updateStatusBarInfo();
@@ -261,6 +265,15 @@ void GUI::createActions()
_statisticsAction->setActionGroup(_fileActionGroup);
connect(_statisticsAction, &QAction::triggered, this, &GUI::statistics);
addAction(_statisticsAction);
+#ifndef Q_OS_ANDROID
+ _recentFilesActionGroup = new QActionGroup(this);
+ connect(_recentFilesActionGroup, &QActionGroup::triggered, this,
+ &GUI::recentFileSelected);
+ _clearRecentFilesAction = new QAction(tr("Clear list"), this);
+ _clearRecentFilesAction->setMenuRole(QAction::NoRole);
+ connect(_clearRecentFilesAction, &QAction::triggered, this,
+ &GUI::clearRecentFiles);
+#endif // Q_OS_ANDROID
// POI actions
_poisActionGroup = new QActionGroup(this);
@@ -614,6 +627,14 @@ void GUI::createMenus()
{
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(_openFileAction);
+#ifndef Q_OS_ANDROID
+ _recentFilesMenu = fileMenu->addMenu(tr("Open recent"));
+ _recentFilesMenu->setIcon(QIcon::fromTheme(OPEN_RECENT_NAME,
+ QIcon(OPEN_RECENT_ICON)));
+ _recentFilesMenu->setEnabled(false);
+ _recentFilesEnd = _recentFilesMenu->addSeparator();
+ _recentFilesMenu->addAction(_clearRecentFilesAction);
+#endif // Q_OS_ANDROID
fileMenu->addAction(_openDirAction);
fileMenu->addSeparator();
#ifndef Q_OS_ANDROID
@@ -1018,6 +1039,9 @@ bool GUI::openFile(const QString &fileName, bool tryUnknown, int &showError)
updateNavigationActions();
updateStatusBarInfo();
updateWindowTitle();
+#ifndef Q_OS_ANDROID
+ updateRecentFiles(fileName);
+#endif // Q_OS_ANDROID
return true;
}
@@ -1992,6 +2016,48 @@ void GUI::updateWindowTitle()
setWindowTitle(APP_NAME);
}
+#ifndef Q_OS_ANDROID
+void GUI::updateRecentFiles(const QString &fileName)
+{
+ QAction *a = 0;
+
+ QList actions(_recentFilesActionGroup->actions());
+ for (int i = 0; i < actions.size(); i++) {
+ if (actions.at(i)->text() == fileName) {
+ a = actions.at(i);
+ break;
+ }
+ }
+
+ if (a)
+ delete a;
+ else if (actions.size() == MAX_RECENT_FILES)
+ delete actions.last();
+
+ actions = _recentFilesActionGroup->actions();
+ QAction *before = actions.size() ? actions.last() : _recentFilesEnd;
+ _recentFilesMenu->insertAction(before,
+ new QAction(fileName, _recentFilesActionGroup));
+ _recentFilesMenu->setEnabled(true);
+}
+
+void GUI::clearRecentFiles()
+{
+ QList actions(_recentFilesActionGroup->actions());
+
+ for (int i = 0; i < actions.size(); i++)
+ delete actions.at(i);
+
+ _recentFilesMenu->setEnabled(false);
+}
+
+void GUI::recentFileSelected(QAction *action)
+{
+ int showError = 1;
+ openFile(action->text(), true, showError);
+}
+#endif // Q_OS_ANDROID
+
void GUI::mapChanged(QAction *action)
{
_map = action->data().value