diff options
Diffstat (limited to 'src/global.cpp')
| -rw-r--r-- | src/global.cpp | 82 |
1 files changed, 44 insertions, 38 deletions
diff --git a/src/global.cpp b/src/global.cpp index 5236fa4d1..32a2d4ebb 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -23,7 +23,9 @@ #include "dolphindebug.h" #include "dolphinmainwindowinterface.h" -#include <KRun> +#include <KDialogJobUiDelegate> +#include <KIO/ApplicationLauncherJob> +#include <KService> #include <KWindowSystem> #include <QApplication> @@ -60,13 +62,11 @@ void Dolphin::openNewWindow(const QList<QUrl> &urls, QWidget *window, const Open if (!urls.isEmpty()) { command.append(QLatin1String(" %U")); } - KRun::run( - command, - urls, - window, - QApplication::applicationDisplayName(), - QApplication::windowIcon().name() - ); + KService::Ptr service(new KService(QApplication::applicationDisplayName(), command, QApplication::windowIcon().name())); + auto *job = new KIO::ApplicationLauncherJob(service, window); + job->setUrls(urls); + job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, window)); + job->start(); } bool Dolphin::attachToExistingInstance(const QList<QUrl>& inputUrls, bool openFiles, bool splitView, const QString& preferredService) @@ -78,36 +78,7 @@ bool Dolphin::attachToExistingInstance(const QList<QUrl>& inputUrls, bool openFi return false; } - QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> dolphinInterfaces; - if (!preferredService.isEmpty()) { - QSharedPointer<OrgKdeDolphinMainWindowInterface> preferredInterface( - new OrgKdeDolphinMainWindowInterface(preferredService, - QStringLiteral("/dolphin/Dolphin_1"), - QDBusConnection::sessionBus())); - if (preferredInterface->isValid() && !preferredInterface->lastError().isValid()) { - dolphinInterfaces.append(qMakePair(preferredInterface, QStringList())); - } - } - - // Look for dolphin instances among all available dbus services. - const QStringList dbusServices = QDBusConnection::sessionBus().interface()->registeredServiceNames().value(); - // Don't match the service without trailing "-" (unique instance) - const QString pattern = QStringLiteral("org.kde.dolphin-"); - // Don't match the pid without leading "-" - const QString myPid = QLatin1Char('-') + QString::number(QCoreApplication::applicationPid()); - for (const QString& service : dbusServices) { - if (service.startsWith(pattern) && !service.endsWith(myPid)) { - // Check if instance can handle our URLs - QSharedPointer<OrgKdeDolphinMainWindowInterface> interface( - new OrgKdeDolphinMainWindowInterface(service, - QStringLiteral("/dolphin/Dolphin_1"), - QDBusConnection::sessionBus())); - if (interface->isValid() && !interface->lastError().isValid()) { - dolphinInterfaces.append(qMakePair(interface, QStringList())); - } - } - } - + auto dolphinInterfaces = dolphinGuiInstances(preferredService); if (dolphinInterfaces.isEmpty()) { return false; } @@ -145,3 +116,38 @@ bool Dolphin::attachToExistingInstance(const QList<QUrl>& inputUrls, bool openFi } return attached; } + +QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> Dolphin::dolphinGuiInstances(const QString& preferredService) +{ + QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> dolphinInterfaces; + if (!preferredService.isEmpty()) { + QSharedPointer<OrgKdeDolphinMainWindowInterface> preferredInterface( + new OrgKdeDolphinMainWindowInterface(preferredService, + QStringLiteral("/dolphin/Dolphin_1"), + QDBusConnection::sessionBus())); + if (preferredInterface->isValid() && !preferredInterface->lastError().isValid()) { + dolphinInterfaces.append(qMakePair(preferredInterface, QStringList())); + } + } + + // Look for dolphin instances among all available dbus services. + const QStringList dbusServices = QDBusConnection::sessionBus().interface()->registeredServiceNames().value(); + // Don't match the service without trailing "-" (unique instance) + const QString pattern = QStringLiteral("org.kde.dolphin-"); + // Don't match the pid without leading "-" + const QString myPid = QLatin1Char('-') + QString::number(QCoreApplication::applicationPid()); + for (const QString& service : dbusServices) { + if (service.startsWith(pattern) && !service.endsWith(myPid)) { + // Check if instance can handle our URLs + QSharedPointer<OrgKdeDolphinMainWindowInterface> interface( + new OrgKdeDolphinMainWindowInterface(service, + QStringLiteral("/dolphin/Dolphin_1"), + QDBusConnection::sessionBus())); + if (interface->isValid() && !interface->lastError().isValid()) { + dolphinInterfaces.append(qMakePair(interface, QStringList())); + } + } + } + + return dolphinInterfaces; +} |
