From 913a1acee6e837b1756045f22480507da928d299 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 25 Jan 2022 10:06:43 +0000 Subject: [PATCH] Use KIO::OpenFileManagerWindowJob This is also not optimal because only two file browsers implements org.freedesktop.org/FileManager1 Missing filemanagers: - Konqueror - Krusader - Thunar But at least is freedesktop.org accepted --- src/session/SessionController.cpp | 40 +++++++++---------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/src/session/SessionController.cpp b/src/session/SessionController.cpp index 43200dbf..2d4af099 100644 --- a/src/session/SessionController.cpp +++ b/src/session/SessionController.cpp @@ -50,7 +50,9 @@ #include #include +#include #include + #include #include @@ -1120,39 +1122,19 @@ void SessionController::openBrowser() // so force open dolphin with it selected. // TODO: and for people that have other default file browsers such as // konqueror and krusader? + if (_currentHotSpot && _currentHotSpot->type() == HotSpot::File) { auto *fileHotSpot = qobject_cast(_currentHotSpot.get()); assert(fileHotSpot); - fileHotSpot->fileItem().url(); - - QDBusConnection bus = QDBusConnection::sessionBus(); - QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.FileManager1"), - QStringLiteral("/org/freedesktop/FileManager1"), - QStringLiteral("org.freedesktop.FileManager1"), - QStringLiteral("ShowItems")); - - QList arguments; - arguments.append(QStringLiteral("URIs")); - arguments.append(fileHotSpot->fileItem().url().toLocalFile()); - - message.setArguments(arguments); - auto reply = bus.asyncCall(message); - reply.waitForFinished(); - - if (reply.isError()) { - // error launching via dbus, do the more manual way. - auto job = new KIO::CommandLauncherJob(QStringLiteral("dolphin"), {fileHotSpot->fileItem().url().toLocalFile(), QStringLiteral("--select")}); - job->start(); - } - - return; + auto *job = new KIO::OpenFileManagerWindowJob(); + job->setHighlightUrls({fileHotSpot->fileItem().url()}); + job->start(); + } else { + const QUrl currentUrl = url().isLocalFile() ? url() : QUrl::fromLocalFile(QDir::homePath()); + auto *job = new KIO::OpenUrlJob(currentUrl); + job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, QApplication::activeWindow())); + job->start(); } - - const QUrl currentUrl = url().isLocalFile() ? url() : QUrl::fromLocalFile(QDir::homePath()); - - auto *job = new KIO::OpenUrlJob(currentUrl); - job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, QApplication::activeWindow())); - job->start(); } void SessionController::copy()