]>
cloud.milkyroute.net Git - dolphin.git/blob - src/dbusinterface.cpp
2 * Copyright 2015 Ashish Bansal<bansal.ashish096@gmail.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "dbusinterface.h"
22 #include "dolphin_generalsettings.h"
24 #include <KPropertiesDialog>
26 #include <QApplication>
27 #include <QDBusConnection>
28 #include <QDBusInterface>
29 #include <QDBusConnectionInterface>
31 DBusInterface::DBusInterface() :
34 QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/freedesktop/FileManager1"), this,
35 QDBusConnection::ExportScriptableContents
| QDBusConnection::ExportAdaptors
);
36 QDBusConnection::sessionBus().interface()->registerService(QStringLiteral("org.freedesktop.FileManager1"),
37 QDBusConnectionInterface::QueueService
);
40 void DBusInterface::ShowFolders(const QStringList
& uriList
, const QString
& startUpId
)
43 const QList
<QUrl
> urls
= Dolphin::validateUris(uriList
);
47 const auto serviceName
= isDaemon() ? QString() : QStringLiteral("org.kde.dolphin-%1").arg(QCoreApplication::applicationPid());
48 if(!Dolphin::attachToExistingInstance(urls
, false, GeneralSettings::splitView(), serviceName
)) {
49 Dolphin::openNewWindow(urls
);
53 void DBusInterface::ShowItems(const QStringList
& uriList
, const QString
& startUpId
)
56 const QList
<QUrl
> urls
= Dolphin::validateUris(uriList
);
60 const auto serviceName
= isDaemon() ? QString() : QStringLiteral("org.kde.dolphin-%1").arg(QCoreApplication::applicationPid());
61 if(!Dolphin::attachToExistingInstance(urls
, true, GeneralSettings::splitView(), serviceName
)) {
62 Dolphin::openNewWindow(urls
, nullptr, Dolphin::OpenNewWindowFlag::Select
);
66 void DBusInterface::ShowItemProperties(const QStringList
& uriList
, const QString
& startUpId
)
69 const QList
<QUrl
> urls
= Dolphin::validateUris(uriList
);
70 if (!urls
.isEmpty()) {
71 KPropertiesDialog::showDialog(urls
);
75 void DBusInterface::setAsDaemon()
80 bool DBusInterface::isDaemon() const