X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/0d6b900a8433bd538ec3afec37b9da62b3806870..b6700f77dd8e07fdab0d40ea4bc91f8d0c03ae70:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 668f511ee..d45b77676 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -67,6 +67,7 @@ #include #include #include +#include #include #include #include @@ -205,7 +206,9 @@ DolphinMainWindow::DolphinMainWindow() : setupWhatsThis(); - QTimer::singleShot(0, this, &DolphinMainWindow::setupUpdateOpenPreferredSearchToolAction); + connect(KSycoca::self(), QOverload<>::of(&KSycoca::databaseChanged), this, &DolphinMainWindow::updateOpenPreferredSearchToolAction); + + QTimer::singleShot(0, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction); } DolphinMainWindow::~DolphinMainWindow() @@ -982,29 +985,6 @@ QPointer DolphinMainWindow::preferredSearchTool() return action; } -void DolphinMainWindow::setupUpdateOpenPreferredSearchToolAction() -{ - QAction* openPreferredSearchTool = actionCollection()->action(QStringLiteral("open_preferred_search_tool")); - const QList widgets = openPreferredSearchTool->associatedWidgets(); - for (QWidget* widget : widgets) { - QMenu* menu = qobject_cast(widget); - if (menu) { - connect(menu, &QMenu::aboutToShow, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction); - } - } - - // Update the open_preferred_search_tool action *before* the Configure Shortcuts window is shown, - // since this action is then listed in that window and it should be up-to-date when it is displayed. - // This update is instantaneous if user made no changes to the search tools in the meantime. - // Maybe all KStandardActions should defer calls to their slots, so that we could simply connect() to trigger()? - connect( - actionCollection()->action(KStandardAction::name(KStandardAction::KeyBindings)), &QAction::hovered, - this, &DolphinMainWindow::updateOpenPreferredSearchToolAction - ); - - updateOpenPreferredSearchToolAction(); -} - void DolphinMainWindow::updateOpenPreferredSearchToolAction() { QAction* openPreferredSearchTool = actionCollection()->action(QStringLiteral("open_preferred_search_tool")); @@ -1180,7 +1160,6 @@ void DolphinMainWindow::updateControlMenu() addActionToMenu(ac->action(QStringLiteral("show_filter_bar")), menu); addActionToMenu(ac->action(QStringLiteral("open_preferred_search_tool")), menu); addActionToMenu(ac->action(QStringLiteral("open_terminal")), menu); - connect(menu, &QMenu::aboutToShow, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction); menu->addSeparator();