diff options
| author | Pan Zhang <[email protected]> | 2026-01-09 17:31:08 +0800 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2026-01-09 14:11:35 +0000 |
| commit | 5b612c6620ced914c7fd239737bef2a6cb55fc50 (patch) | |
| tree | 89f0504d8cc4c49f4266d58ff71d072360627a94 /src/dolphinmainwindow.cpp | |
| parent | 6a6a9cd363271d632b5b546804473e5cd807bb40 (diff) | |
dolphinmainwindow: Reload context menu plugins when configuration changes
Reload the context menu plugins and share the KFileItemActions with the context menu so it stays up-to-date as the user changes the service menu settings.
This uses a KConfigWatcher to trigger settings reload on "kservicemenurc" changes, covering both internal settings changes and external scripts.
Remove the obsolete restart prompt in ContextMenuSettingsPage since changes are now applied instantly.
BUG: 508722
Diffstat (limited to 'src/dolphinmainwindow.cpp')
| -rw-r--r-- | src/dolphinmainwindow.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 9e25f94e8..baf94ef3e 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -256,11 +256,12 @@ DolphinMainWindow::DolphinMainWindow() QTimer::singleShot(0, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction); - m_fileItemActions.setParentWidget(this); - connect(&m_fileItemActions, &KFileItemActions::error, this, [this](const QString &errorMessage) { - showErrorMessage(errorMessage); - }); + setupFileItemActions(); + m_serviceMenuConfigWatcher = KConfigWatcher::create(KSharedConfig::openConfig(QStringLiteral("kservicemenurc"))); + connect(m_serviceMenuConfigWatcher.data(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup & /*group*/, const QByteArrayList & /*names*/) { + setupFileItemActions(); + }); connect(GeneralSettings::self(), &GeneralSettings::splitViewChanged, this, &DolphinMainWindow::slotSplitViewChanged); } @@ -1541,7 +1542,7 @@ void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable) void DolphinMainWindow::openContextMenu(const QPoint &pos, const KFileItem &item, const KFileItemList &selectedItems, const QUrl &url) { - QPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, item, selectedItems, url, &m_fileItemActions); + QPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, item, selectedItems, url, m_fileItemActions); contextMenu->exec(pos); // Delete the menu, unless it has been deleted in its own nested event loop already. @@ -2591,6 +2592,19 @@ void DolphinMainWindow::setupDockWidgets() }); } +void DolphinMainWindow::setupFileItemActions() +{ + if (m_fileItemActions) { + delete m_fileItemActions; + } + + m_fileItemActions = new KFileItemActions(this); + m_fileItemActions->setParentWidget(this); + connect(m_fileItemActions, &KFileItemActions::error, this, [this](const QString &errorMessage) { + showErrorMessage(errorMessage); + }); +} + void DolphinMainWindow::updateFileAndEditActions() { const KFileItemList list = m_activeViewContainer->view()->selectedItems(); @@ -2743,6 +2757,7 @@ void DolphinMainWindow::updateGoActions() void DolphinMainWindow::refreshViews() { + setupFileItemActions(); m_tabWidget->refreshViews(); if (GeneralSettings::modifiedStartupSettings()) { |
