X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/da2bad9c68122f1c399b187ba6150b120dc5f674..7e10da6e2e0171fa30a1162e5767be2b95937c21:/src/dolphinrecenttabsmenu.cpp diff --git a/src/dolphinrecenttabsmenu.cpp b/src/dolphinrecenttabsmenu.cpp index adc6a8eda..74aaf232e 100644 --- a/src/dolphinrecenttabsmenu.cpp +++ b/src/dolphinrecenttabsmenu.cpp @@ -5,15 +5,17 @@ */ #include "dolphinrecenttabsmenu.h" +#include "search/dolphinquery.h" #include #include #include #include +#include -DolphinRecentTabsMenu::DolphinRecentTabsMenu(QObject* parent) : - KActionMenu(QIcon::fromTheme(QStringLiteral("edit-undo")), i18n("Recently Closed Tabs"), parent) +DolphinRecentTabsMenu::DolphinRecentTabsMenu(QObject *parent) + : KActionMenu(QIcon::fromTheme(QStringLiteral("edit-undo")), i18n("Recently Closed Tabs"), parent) { setPopupMode(QToolButton::InstantPopup); setEnabled(false); @@ -24,14 +26,21 @@ DolphinRecentTabsMenu::DolphinRecentTabsMenu(QObject* parent) : addSeparator(); - connect(menu(), &QMenu::triggered, - this, &DolphinRecentTabsMenu::handleAction); + connect(menu(), &QMenu::triggered, this, &DolphinRecentTabsMenu::handleAction); } -void DolphinRecentTabsMenu::rememberClosedTab(const QUrl& url, const QByteArray& state) +void DolphinRecentTabsMenu::rememberClosedTab(const QUrl &url, const QByteArray &state) { - QAction* action = new QAction(menu()); - action->setText(url.path()); + QAction *action = new QAction(menu()); + if (DolphinQuery::supportsScheme(url.scheme())) { + const DolphinQuery query = DolphinQuery::fromSearchUrl(url); + action->setText(i18n("Search for %1 in %2", query.text(), query.includeFolder())); + } else if (url.scheme() == QLatin1String("filenamesearch")) { + const QUrlQuery query(url); + action->setText(i18n("Search for %1 in %2", query.queryItemValue(QStringLiteral("search")), query.queryItemValue(QStringLiteral("url")))); + } else { + action->setText(url.path()); + } action->setData(state); const QString iconName = KIO::iconNameForUrl(url); action->setIcon(QIcon::fromTheme(iconName)); @@ -59,12 +68,12 @@ void DolphinRecentTabsMenu::undoCloseTab() handleAction(menu()->actions().at(2)); } -void DolphinRecentTabsMenu::handleAction(QAction* action) +void DolphinRecentTabsMenu::handleAction(QAction *action) { if (action == m_clearListAction) { // Clear all actions except the "Empty Recently Closed Tabs" // action and the separator - QList actions = menu()->actions(); + QList actions = menu()->actions(); const int count = actions.size(); for (int i = count - 1; i >= 2; i--) { removeAction(actions.at(i)); @@ -83,3 +92,5 @@ void DolphinRecentTabsMenu::handleAction(QAction* action) setEnabled(false); } } + +#include "moc_dolphinrecenttabsmenu.cpp"