diff --git a/lib/translations/ar_SA.ts b/lib/translations/ar_SA.ts index cd02fe7..d49ac95 100644 --- a/lib/translations/ar_SA.ts +++ b/lib/translations/ar_SA.ts @@ -803,6 +803,24 @@ + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/bg.ts b/lib/translations/bg.ts index 6890ca3..4ac185c 100644 --- a/lib/translations/bg.ts +++ b/lib/translations/bg.ts @@ -792,6 +792,24 @@ + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/cs_CZ.ts b/lib/translations/cs_CZ.ts index 0855619..e222bd3 100644 --- a/lib/translations/cs_CZ.ts +++ b/lib/translations/cs_CZ.ts @@ -828,6 +828,24 @@ PDF dokument (*.pdf) + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/cy_GB.ts b/lib/translations/cy_GB.ts index 814bed8..1ad0bd4 100644 --- a/lib/translations/cy_GB.ts +++ b/lib/translations/cy_GB.ts @@ -796,6 +796,24 @@ + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/da_DK.ts b/lib/translations/da_DK.ts index 67dfe9c..d6f8c4d 100644 --- a/lib/translations/da_DK.ts +++ b/lib/translations/da_DK.ts @@ -803,6 +803,24 @@ + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/de_DE.ts b/lib/translations/de_DE.ts index 6b12d8b..e2fc9e0 100644 --- a/lib/translations/de_DE.ts +++ b/lib/translations/de_DE.ts @@ -803,6 +803,24 @@ + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/en_GB.ts b/lib/translations/en_GB.ts index 3679135..b7efdda 100644 --- a/lib/translations/en_GB.ts +++ b/lib/translations/en_GB.ts @@ -803,6 +803,24 @@ + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/en_US.ts b/lib/translations/en_US.ts index 8e3eb7f..fd78079 100644 --- a/lib/translations/en_US.ts +++ b/lib/translations/en_US.ts @@ -792,6 +792,24 @@ + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/fr_CA.ts b/lib/translations/fr_CA.ts index 4906426..bf6a16e 100644 --- a/lib/translations/fr_CA.ts +++ b/lib/translations/fr_CA.ts @@ -828,6 +828,24 @@ Portable Document Format (*.pdf) + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/he_IL.ts b/lib/translations/he_IL.ts index 6cd94da..6ad1cc5 100644 --- a/lib/translations/he_IL.ts +++ b/lib/translations/he_IL.ts @@ -828,6 +828,24 @@ Portable Document Format (*.pdf) + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/id_ID.ts b/lib/translations/id_ID.ts index 1b032f2..80a6ed7 100644 --- a/lib/translations/id_ID.ts +++ b/lib/translations/id_ID.ts @@ -796,6 +796,24 @@ + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/ja_JP.ts b/lib/translations/ja_JP.ts index 390008c..29206b0 100644 --- a/lib/translations/ja_JP.ts +++ b/lib/translations/ja_JP.ts @@ -792,6 +792,24 @@ + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/nl_NL.ts b/lib/translations/nl_NL.ts index 2e14ef6..ab1cf53 100644 --- a/lib/translations/nl_NL.ts +++ b/lib/translations/nl_NL.ts @@ -803,6 +803,24 @@ + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/pl_PL.ts b/lib/translations/pl_PL.ts index d1fbd10..f3857d7 100644 --- a/lib/translations/pl_PL.ts +++ b/lib/translations/pl_PL.ts @@ -792,6 +792,24 @@ + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/pt_BR.ts b/lib/translations/pt_BR.ts index 24973e2..d8ec23d 100644 --- a/lib/translations/pt_BR.ts +++ b/lib/translations/pt_BR.ts @@ -796,6 +796,24 @@ + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/ro_RO.ts b/lib/translations/ro_RO.ts index bcea0d1..74fe649 100644 --- a/lib/translations/ro_RO.ts +++ b/lib/translations/ro_RO.ts @@ -808,6 +808,24 @@ + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/sl_SI.ts b/lib/translations/sl_SI.ts index 02bb4c0..cb177bf 100644 --- a/lib/translations/sl_SI.ts +++ b/lib/translations/sl_SI.ts @@ -803,6 +803,24 @@ + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/ta.ts b/lib/translations/ta.ts index 91fc2a5..f028298 100644 --- a/lib/translations/ta.ts +++ b/lib/translations/ta.ts @@ -829,6 +829,24 @@ Portable Document Format (*.pdf) + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/th_TH.ts b/lib/translations/th_TH.ts index 37f9fa2..2427459 100644 --- a/lib/translations/th_TH.ts +++ b/lib/translations/th_TH.ts @@ -803,6 +803,24 @@ + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/tr_TR.ts b/lib/translations/tr_TR.ts index 3a092a1..62e055d 100644 --- a/lib/translations/tr_TR.ts +++ b/lib/translations/tr_TR.ts @@ -803,6 +803,24 @@ + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/ur_PK.ts b/lib/translations/ur_PK.ts index 5286360..ce87155 100644 --- a/lib/translations/ur_PK.ts +++ b/lib/translations/ur_PK.ts @@ -792,6 +792,24 @@ + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/vi_VN.ts b/lib/translations/vi_VN.ts index 1e2af7b..8071ba9 100644 --- a/lib/translations/vi_VN.ts +++ b/lib/translations/vi_VN.ts @@ -835,6 +835,24 @@ Tệp tài liệu di động (*.pdf) + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/translations/zh_CN.ts b/lib/translations/zh_CN.ts index f5fb169..933df54 100644 --- a/lib/translations/zh_CN.ts +++ b/lib/translations/zh_CN.ts @@ -796,6 +796,24 @@ + + tRecentsList + + + Open Recent + + + + + No Recent Items + + + + + Clear Menu + + + tSettingsWindow diff --git a/lib/trecentslist.cpp b/lib/trecentslist.cpp index 6370199..803f968 100644 --- a/lib/trecentslist.cpp +++ b/lib/trecentslist.cpp @@ -1,9 +1,11 @@ #include "trecentslist.h" #include +#include #include #include #include +#include #include struct tRecentsListPrivate { @@ -12,6 +14,9 @@ struct tRecentsListPrivate { QList paths; QFileSystemWatcher* watcher; + + QMenu* recentsMenu; + QFileIconProvider iconProvider; }; tRecentsList::tRecentsList(QString name, QObject* parent) : @@ -24,6 +29,9 @@ tRecentsList::tRecentsList(QString name, QObject* parent) : QDir::root().mkpath(recents.absolutePath()); d->path = recents.absoluteFilePath(name); + d->recentsMenu = new QMenu(); + d->recentsMenu->setTitle(tr("Open Recent")); + if (!QFile::exists(d->path)) { this->save(); } @@ -37,6 +45,7 @@ tRecentsList::tRecentsList(QString name, QObject* parent) : } tRecentsList::~tRecentsList() { + d->recentsMenu->deleteLater(); delete d; } @@ -66,6 +75,10 @@ void tRecentsList::clear() { this->save(); } +QMenu* tRecentsList::recentsMenu() { + return d->recentsMenu; +} + void tRecentsList::load() { emit beforeUpdated(); @@ -80,6 +93,26 @@ void tRecentsList::load() { d->paths.append(QUrl(path.toString())); } + d->recentsMenu->clear(); + if (d->paths.isEmpty()) { + auto emptyAction = d->recentsMenu->addAction(tr("No Recent Items")); + emptyAction->setEnabled(false); + } else { + for (auto path : d->paths) { + auto recentAction = d->recentsMenu->addAction(d->iconProvider.icon(QFileInfo(path.toLocalFile())), path.fileName(), [path, this] { + emit openRecent(path); + }); + + // Force the icon to be visible in macOS + recentAction->setIconVisibleInMenu(true); + } + } + d->recentsMenu->addSeparator(); + auto clearAction = d->recentsMenu->addAction(tr("Clear Menu"), [this] { + this->clear(); + }); + clearAction->setEnabled(!d->paths.isEmpty()); + emit updated(); } diff --git a/lib/trecentslist.h b/lib/trecentslist.h index 1b2fecd..2c79726 100644 --- a/lib/trecentslist.h +++ b/lib/trecentslist.h @@ -3,6 +3,7 @@ #include +class QMenu; struct tRecentsListPrivate; class tRecentsList : public QObject { Q_OBJECT @@ -15,9 +16,12 @@ class tRecentsList : public QObject { int count(); void clear(); + QMenu* recentsMenu(); + signals: void beforeUpdated(); void updated(); + void openRecent(QUrl url); private: tRecentsListPrivate* d;