From 30299e00b137fb5abf31e6f82fc8f4753f9a929a Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Sun, 18 Apr 2021 08:37:45 +0200 Subject: Reuse KFileItemActions instance during lifetime of dolphin With https://invent.kde.org/frameworks/kio/-/merge_requests/411 the plugin instances can be reused during the lifetime of the KFileItemActions object. This improves performance and also allows the plugins to emit errors, even if they run async. --- src/dolphinmainwindow.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/dolphinmainwindow.cpp') diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index d8c27526b..fe39d4d2f 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -65,6 +65,8 @@ #include #include +#include + #include #include #include @@ -207,6 +209,13 @@ DolphinMainWindow::DolphinMainWindow() : connect(KSycoca::self(), QOverload<>::of(&KSycoca::databaseChanged), this, &DolphinMainWindow::updateOpenPreferredSearchToolAction); QTimer::singleShot(0, this, &DolphinMainWindow::updateOpenPreferredSearchToolAction); + + m_fileItemActions.setParentWidget(this); +#if KIO_VERSION >= QT_VERSION_CHECK(5, 82, 0) + connect(&m_fileItemActions, &KFileItemActions::error, this, [this](const QString &errorMessage) { + showErrorMessage(errorMessage); + }); +#endif } DolphinMainWindow::~DolphinMainWindow() @@ -1125,7 +1134,7 @@ void DolphinMainWindow::openContextMenu(const QPoint& pos, const QUrl& url, const QList& customActions) { - QPointer contextMenu = new DolphinContextMenu(this, pos, item, url); + QPointer contextMenu = new DolphinContextMenu(this, pos, item, url, &m_fileItemActions); contextMenu.data()->setCustomActions(customActions); const DolphinContextMenu::Command command = contextMenu.data()->open(); -- cgit v1.3