]> cloud.milkyroute.net Git - dolphin.git/blob - src/dbusinterface.cpp
Fix selection rect after porting from QFontMetrics::width()
[dolphin.git] / src / dbusinterface.cpp
1 /*
2 * Copyright 2015 Ashish Bansal<bansal.ashish096@gmail.com>
3 *
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.
8 *
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.
13 *
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
18 */
19
20 #include "dbusinterface.h"
21 #include "global.h"
22 #include "dolphin_generalsettings.h"
23
24 #include <KPropertiesDialog>
25
26 #include <QApplication>
27 #include <QDBusConnection>
28 #include <QDBusInterface>
29 #include <QDBusConnectionInterface>
30
31 DBusInterface::DBusInterface() :
32 QObject()
33 {
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);
38 }
39
40 void DBusInterface::ShowFolders(const QStringList& uriList, const QString& startUpId)
41 {
42 Q_UNUSED(startUpId)
43 const QList<QUrl> urls = Dolphin::validateUris(uriList);
44 if (urls.isEmpty()) {
45 return;
46 }
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);
50 }
51 }
52
53 void DBusInterface::ShowItems(const QStringList& uriList, const QString& startUpId)
54 {
55 Q_UNUSED(startUpId)
56 const QList<QUrl> urls = Dolphin::validateUris(uriList);
57 if (urls.isEmpty()) {
58 return;
59 }
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);
63 };
64 }
65
66 void DBusInterface::ShowItemProperties(const QStringList& uriList, const QString& startUpId)
67 {
68 Q_UNUSED(startUpId)
69 const QList<QUrl> urls = Dolphin::validateUris(uriList);
70 if (!urls.isEmpty()) {
71 KPropertiesDialog::showDialog(urls);
72 }
73 }
74
75 void DBusInterface::setAsDaemon()
76 {
77 m_isDaemon = true;
78 }
79
80 bool DBusInterface::isDaemon() const
81 {
82 return m_isDaemon;
83 }