Try to launch via DBus - as there is a API for selecting files

If that fails, then manually call dolphin
Currently only Dolphin and Nautilus supports that API call.
wilder
Tomaz Canabrava 4 years ago committed by Tomaz Canabrava
parent a158926ae8
commit 43763804cc
  1. 25
      src/session/SessionController.cpp

@ -16,6 +16,10 @@
// Qt
#include <QAction>
#include <QApplication>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusPendingCall>
#include <QFileDialog>
#include <QIcon>
#include <QKeyEvent>
@ -1121,8 +1125,25 @@ void SessionController::openBrowser()
assert(fileHotSpot);
fileHotSpot->fileItem().url();
auto job = new KIO::CommandLauncherJob(QStringLiteral("dolphin"), {fileHotSpot->fileItem().url().toLocalFile(), QStringLiteral("--select")});
job->start();
QDBusConnection bus = QDBusConnection::sessionBus();
QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.FileManager1"),
QStringLiteral("/org/freedesktop/FileManager1"),
QStringLiteral("org.freedesktop.FileManager1"),
QStringLiteral("ShowItems"));
QList<QVariant> 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;
}

Loading…
Cancel
Save