#include <KShell>
#include <KStandardAction>
#include <KStartupInfo>
+#include <KSycoca>
#include <KToggleAction>
#include <KToolBar>
#include <KToolBarPopupAction>
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()
return action;
}
-void DolphinMainWindow::setupUpdateOpenPreferredSearchToolAction()
-{
- QAction* openPreferredSearchTool = actionCollection()->action(QStringLiteral("open_preferred_search_tool"));
- const QList<QWidget*> widgets = openPreferredSearchTool->associatedWidgets();
- for (QWidget* widget : widgets) {
- QMenu* menu = qobject_cast<QMenu*>(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"));
// Add "Edit" actions
bool added = addActionToMenu(ac->action(KStandardAction::name(KStandardAction::Undo)), menu) |
+ addActionToMenu(ac->action(QString("copy_location")), menu) |
addActionToMenu(ac->action(QStringLiteral("copy_to_inactive_split_view")), menu) |
addActionToMenu(ac->action(QStringLiteral("move_to_inactive_split_view")), menu) |
addActionToMenu(ac->action(KStandardAction::name(KStandardAction::SelectAll)), menu) |
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();
QAction* addToPlacesAction = col->action(QStringLiteral("add_to_places"));
QAction* copyToOtherViewAction = col->action(QStringLiteral("copy_to_inactive_split_view"));
QAction* moveToOtherViewAction = col->action(QStringLiteral("move_to_inactive_split_view"));
+ QAction* copyLocation = col->action(QString("copy_location"));
if (list.isEmpty()) {
stateChanged(QStringLiteral("has_no_selection"));
addToPlacesAction->setEnabled(true);
copyToOtherViewAction->setEnabled(false);
moveToOtherViewAction->setEnabled(false);
+ copyLocation->setEnabled(false);
} else {
stateChanged(QStringLiteral("has_selection"));
deleteAction->setEnabled(capabilitiesSource.supportsDeleting());
deleteWithTrashShortcut->setEnabled(capabilitiesSource.supportsDeleting() && !enableMoveToTrash);
cutAction->setEnabled(capabilitiesSource.supportsMoving());
+ copyLocation->setEnabled(list.length() == 1);
showTarget->setEnabled(list.length() == 1 && list.at(0).isLink());
duplicateAction->setEnabled(capabilitiesSource.supportsWriting());
}