diff options
| author | Nicolas Fella <[email protected]> | 2023-11-07 15:45:01 +0100 |
|---|---|---|
| committer | Nicolas Fella <[email protected]> | 2023-11-08 13:36:51 +0000 |
| commit | 2cd3d58eec5695899c26ca66a631fb79867b6584 (patch) | |
| tree | 8ea47aeaea6eda7aee91885fe545cd930cd070a9 /src/search/dolphinsearchbox.cpp | |
| parent | 8297e0a8c97c6e1f6d46b9ecc9c5f495f294d5b8 (diff) | |
Port away from KMoreTools
The idea behind KMoreTools was to point the user at external tools for a given job.
It provides a rather complex framework for that, including suggesting not-yet-installed tools.
The UX behind that isn't great though, which somewhat deep menu hierarchies and a somewhat arbitrary list of tools.
Most KDE apps have moved away from it, with only Dolphin remaining.
Instead provide direct integration with relevant KDE tools (Filelight, KDiskFree, KFind)
Diffstat (limited to 'src/search/dolphinsearchbox.cpp')
| -rw-r--r-- | src/search/dolphinsearchbox.cpp | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp index a3cec6fe7..dfd733e5d 100644 --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@ -13,9 +13,10 @@ #include "dolphinquery.h" #include "config-dolphin.h" +#include <KIO/ApplicationLauncherJob> #include <KLocalizedString> -#include <KMoreToolsMenuFactory> #include <KSeparator> +#include <KService> #if HAVE_BALOO #include <Baloo/IndexerConfig> #include <Baloo/Query> @@ -395,18 +396,24 @@ void DolphinSearchBox::init() searchLocationGroup->addButton(m_fromHereButton); searchLocationGroup->addButton(m_everywhereButton); - auto moreSearchToolsButton = new QToolButton(this); - moreSearchToolsButton->setAutoRaise(true); - moreSearchToolsButton->setPopupMode(QToolButton::InstantPopup); - moreSearchToolsButton->setIcon(QIcon::fromTheme("arrow-down-double")); - moreSearchToolsButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - moreSearchToolsButton->setText(i18n("More Search Tools")); - moreSearchToolsButton->setMenu(new QMenu(this)); - connect(moreSearchToolsButton->menu(), &QMenu::aboutToShow, moreSearchToolsButton->menu(), [this, moreSearchToolsButton]() { - m_menuFactory.reset(new KMoreToolsMenuFactory("dolphin/search-tools")); - moreSearchToolsButton->menu()->clear(); - m_menuFactory->fillMenuFromGroupingNames(moreSearchToolsButton->menu(), {"files-find"}, this->m_searchPath); - }); + KService::Ptr kfind = KService::serviceByDesktopName(QStringLiteral("org.kde.kfind")); + + QToolButton *kfindToolsButton = nullptr; + if (kfind) { + kfindToolsButton = new QToolButton(this); + kfindToolsButton->setAutoRaise(true); + kfindToolsButton->setPopupMode(QToolButton::InstantPopup); + kfindToolsButton->setIcon(QIcon::fromTheme("arrow-down-double")); + kfindToolsButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + kfindToolsButton->setText(i18n("Open %1", kfind->name())); + kfindToolsButton->setIcon(QIcon::fromTheme(kfind->icon())); + + connect(kfindToolsButton, &QToolButton::clicked, this, [this, kfind] { + auto *job = new KIO::ApplicationLauncherJob(kfind); + job->setUrls({m_searchPath}); + job->start(); + }); + } // Create "Facets" widget m_facetsWidget = new DolphinFacetsWidget(this); @@ -429,7 +436,9 @@ void DolphinSearchBox::init() optionsLayout->addWidget(m_fromHereButton); optionsLayout->addWidget(m_everywhereButton); optionsLayout->addWidget(new KSeparator(Qt::Vertical, this)); - optionsLayout->addWidget(moreSearchToolsButton); + if (kfindToolsButton) { + optionsLayout->addWidget(kfindToolsButton); + } optionsLayout->addStretch(1); m_optionsScrollArea = new QScrollArea(this); |
