diff --git a/doc/index.docbook b/doc/index.docbook
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -2004,6 +2004,17 @@
Opens &konsole; within the current folder.
+
+
+
+&Ctrl;&Shift;F
+
+Tools
+Open Preferred Search Tool
+
+Opens preferred search tool in the current folder.
+
+
Tools
diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h
--- a/src/dolphinmainwindow.h
+++ b/src/dolphinmainwindow.h
@@ -348,6 +348,9 @@
*/
void toggleShowMenuBar();
+ /** Opens preferred search tool for the current location. */
+ void openPreferredSearchTool();
+
/** Opens a terminal window for the current location. */
void openTerminal();
@@ -558,6 +561,14 @@
/** Adds "What's This?" texts to many widgets and StandardActions. */
void setupWhatsThis();
+ /**
+ * Returns local path for the active container URL.
+ * If the given directory is not local, it can still be the URL of an
+ * ioslave using UDS_LOCAL_PATH which to be converted first.
+ * Return user's home path if unsuccessful.
+ */
+ QString localPath();
+
private:
/**
* Implements a custom error handling for the undo manager. This
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -56,6 +56,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -839,23 +840,32 @@
}
}
-void DolphinMainWindow::openTerminal()
-{
- QString dir(QDir::homePath());
-
- // If the given directory is not local, it can still be the URL of an
- // ioslave using UDS_LOCAL_PATH which to be converted first.
+QString DolphinMainWindow::localPath() {
KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
KJobWidgets::setWindow(statJob, this);
statJob->exec();
QUrl url = statJob->mostLocalUrl();
-
- //If the URL is local after the above conversion, set the directory.
if (url.isLocalFile()) {
- dir = url.toLocalFile();
+ return url.toLocalFile();
+ }
+ return QDir::homePath();
+}
+
+void DolphinMainWindow::openPreferredSearchTool()
+{
+ QMenu searchTools;
+ KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(
+ &searchTools, { "files-find" }, QUrl(localPath())
+ );
+ QList actions = searchTools.actions();
+ if (!(actions.isEmpty())) {
+ actions.first()->trigger();
}
+}
- KToolInvocation::invokeTerminal(QString(), dir);
+void DolphinMainWindow::openTerminal()
+{
+ KToolInvocation::invokeTerminal(QString(), localPath());
}
void DolphinMainWindow::editSettings()
@@ -1029,6 +1039,7 @@
QMenu* toolsMenu = new QMenu(i18nc("@action:inmenu", "Tools"), menu);
toolsMenu->addAction(ac->action(QStringLiteral("show_filter_bar")));
toolsMenu->addAction(ac->action(QStringLiteral("compare_files")));
+ toolsMenu->addAction(ac->action(QStringLiteral("open_preferred_search_tool")));
toolsMenu->addAction(ac->action(QStringLiteral("open_terminal")));
toolsMenu->addAction(ac->action(QStringLiteral("change_remote_encoding")));
menu->addMenu(toolsMenu);
@@ -1344,6 +1355,15 @@
compareFiles->setEnabled(false);
connect(compareFiles, &QAction::triggered, this, &DolphinMainWindow::compareFiles);
+ QAction* openPreferredSearchTool = actionCollection()->addAction(QStringLiteral("open_preferred_search_tool"));
+ openPreferredSearchTool->setText(i18nc("@action:inmenu Tools", "Open Preferred Search Tool"));
+ openPreferredSearchTool->setWhatsThis(xi18nc("@info:whatsthis",
+ "This opens a preferred search tool for the viewed location."
+ "Use More Search Tools menu to configure it."));
+ openPreferredSearchTool->setIcon(QIcon::fromTheme(QStringLiteral("search")));
+ actionCollection()->setDefaultShortcut(openPreferredSearchTool, Qt::CTRL + Qt::SHIFT + Qt::Key_F);
+ connect(openPreferredSearchTool, &QAction::triggered, this, &DolphinMainWindow::openPreferredSearchTool);
+
#ifdef HAVE_TERMINAL
if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
QAction* openTerminal = actionCollection()->addAction(QStringLiteral("open_terminal"));
diff --git a/src/dolphinpart.h b/src/dolphinpart.h
--- a/src/dolphinpart.h
+++ b/src/dolphinpart.h
@@ -194,7 +194,7 @@
void slotOpenTerminal();
/**
- * Open KFind with the current path.
+ * Open preferred search tool in the current directory to find files.
*/
void slotFindFile();
@@ -234,6 +234,8 @@
void openSelectionDialog(const QString& title, const QString& text,
bool selectItems);
+ QString localPath();
+
private:
DolphinView* m_view;
DolphinViewActionHandler* m_actionHandler;
diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp
--- a/src/dolphinpart.cpp
+++ b/src/dolphinpart.cpp
@@ -40,6 +40,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -530,30 +531,34 @@
// TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
}
-void DolphinPart::slotOpenTerminal()
-{
- QString dir(QDir::homePath());
-
- QUrl u(url());
-
- // If the given directory is not local, it can still be the URL of an
- // ioslave using UDS_LOCAL_PATH which to be converted first.
- KIO::StatJob* statJob = KIO::mostLocalUrl(u);
+QString DolphinPart::localPath() {
+ KIO::StatJob* statJob = KIO::mostLocalUrl(url());
KJobWidgets::setWindow(statJob, widget());
statJob->exec();
- u = statJob->mostLocalUrl();
-
- //If the URL is local after the above conversion, set the directory.
- if (u.isLocalFile()) {
- dir = u.toLocalFile();
+ QUrl url = statJob->mostLocalUrl();
+ if (url.isLocalFile()) {
+ return url.toLocalFile();
}
+ return QDir::homePath();
+}
- KToolInvocation::invokeTerminal(QString(), dir);
+void DolphinPart::slotOpenTerminal()
+{
+ KToolInvocation::invokeTerminal(QString(), localPath());
}
void DolphinPart::slotFindFile()
{
- KRun::run(QStringLiteral("kfind"), {url()}, widget());
+ QMenu searchTools;
+ KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(
+ &searchTools, { "files-find" }, QUrl(localPath())
+ );
+ QList actions = searchTools.actions();
+ if (!(actions.isEmpty())) {
+ actions.first()->trigger();
+ } else {
+ KRun::run(QStringLiteral("kfind"), {url()}, widget());
+ }
}
void DolphinPart::updateNewMenu()
diff --git a/src/dolphinui.rc b/src/dolphinui.rc
--- a/src/dolphinui.rc
+++ b/src/dolphinui.rc
@@ -48,6 +48,7 @@