diff options
| author | Albert Mkhitaryan <[email protected]> | 2026-02-20 08:48:54 +0000 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2026-02-20 08:48:54 +0000 |
| commit | db49ac4e1916f87143574b064b36ec86f8407145 (patch) | |
| tree | 9620cb68a243caf018473f93833da8e52c57973e /src/dolphinmainwindow.cpp | |
| parent | 2438a457bf7499c91e3b035ed10ade41ac632660 (diff) | |
Add keyboard shortcut support for service menu actions
Introduce ServiceMenuShortcutManager, which registers all service menu actions with KActionCollection at startup allowing users to assign keyboard shortcuts in Configure Keyboard Shorcuts. Save/Load of configs happens via KXMLGUI in dolphinui.rc.
Notes:
- Manager initializes before setupGUI() for shortcut restoration
- Execution and validation handled entirely by KFileItemAction in KIO.
BUG: 260266
Diffstat (limited to 'src/dolphinmainwindow.cpp')
| -rw-r--r-- | src/dolphinmainwindow.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 62ff2fa45..110bef2f3 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -28,6 +28,9 @@ #include "panels/terminal/terminalpanel.h" #include "search/dolphinquery.h" #include "selectionmode/actiontexthelper.h" +#if KIO_VERSION >= QT_VERSION_CHECK(6, 24, 0) +#include "servicemenushortcutmanager.h" +#endif #include "settings/dolphinsettingsdialog.h" #include "statusbar/diskspaceusagemenu.h" #include "statusbar/dolphinstatusbar.h" @@ -206,6 +209,11 @@ DolphinMainWindow::DolphinMainWindow() setupDockWidgets(); +#if KIO_VERSION >= QT_VERSION_CHECK(6, 24, 0) + m_serviceMenuShortcutManager = new ServiceMenuShortcutManager(actionCollection(), this); +#endif + setupFileItemActions(); + const bool usePhoneUi{KRuntimePlatform::runtimePlatform().contains(QLatin1String("phone"))}; setupGUI(Save | Create | ToolBar, usePhoneUi ? QStringLiteral("dolphinuiforphones.rc") : QString() /* load the default dolphinui.rc file */); stateChanged(QStringLiteral("new_file")); @@ -256,8 +264,6 @@ DolphinMainWindow::DolphinMainWindow() QTimer::singleShot(0, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction); - setupFileItemActions(); - m_serviceMenuConfigWatcher = KConfigWatcher::create(KSharedConfig::openConfig(QStringLiteral("kservicemenurc"))); connect(m_serviceMenuConfigWatcher.data(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup & /*group*/, const QByteArrayList & /*names*/) { setupFileItemActions(); @@ -431,6 +437,10 @@ void DolphinMainWindow::slotSelectionChanged(const KFileItemList &selection) { updateFileAndEditActions(); + if (m_fileItemActions) { + m_fileItemActions->setItemListProperties(KFileItemListProperties(selection)); + } + const int selectedUrlsCount = m_tabWidget->currentTabPage()->selectedItemsCount(); QAction *compareFilesAction = actionCollection()->action(QStringLiteral("compare_files")); @@ -1783,6 +1793,10 @@ void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString &mo void DolphinMainWindow::slotKeyBindings() { +#if KIO_VERSION >= QT_VERSION_CHECK(6, 24, 0) + m_serviceMenuShortcutManager->cleanupStaleShortcuts(this); +#endif + KShortcutsDialog dialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, this); dialog.addCollection(actionCollection()); if (m_terminalPanel) { @@ -2624,6 +2638,10 @@ void DolphinMainWindow::setupFileItemActions() connect(m_fileItemActions, &KFileItemActions::error, this, [this](const QString &errorMessage) { showErrorMessage(errorMessage); }); + +#if KIO_VERSION >= QT_VERSION_CHECK(6, 24, 0) + m_serviceMenuShortcutManager->refresh(m_fileItemActions); +#endif } void DolphinMainWindow::updateFileAndEditActions() |
