Changeset View
Changeset View
Standalone View
Standalone View
src/dbusinterface.cpp
Show All 13 Lines | |||||
14 | * You should have received a copy of the GNU General Public License | 14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | 15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "dbusinterface.h" | 20 | #include "dbusinterface.h" | ||
21 | #include "global.h" | 21 | #include "global.h" | ||
22 | #include "dolphin_generalsettings.h" | ||||
22 | 23 | | |||
23 | #include <KPropertiesDialog> | 24 | #include <KPropertiesDialog> | ||
24 | 25 | | |||
26 | #include <QApplication> | ||||
25 | #include <QDBusConnection> | 27 | #include <QDBusConnection> | ||
28 | #include <QDBusInterface> | ||||
26 | #include <QDBusConnectionInterface> | 29 | #include <QDBusConnectionInterface> | ||
27 | 30 | | |||
28 | DBusInterface::DBusInterface() : | 31 | DBusInterface::DBusInterface() : | ||
29 | QObject() | 32 | QObject() | ||
30 | { | 33 | { | ||
31 | QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/freedesktop/FileManager1"), this, | 34 | QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/freedesktop/FileManager1"), this, | ||
32 | QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors); | 35 | QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors); | ||
33 | QDBusConnection::sessionBus().interface()->registerService(QStringLiteral("org.freedesktop.FileManager1"), | 36 | QDBusConnection::sessionBus().interface()->registerService(QStringLiteral("org.freedesktop.FileManager1"), | ||
34 | QDBusConnectionInterface::QueueService); | 37 | QDBusConnectionInterface::QueueService); | ||
35 | } | 38 | } | ||
36 | 39 | | |||
37 | void DBusInterface::ShowFolders(const QStringList& uriList, const QString& startUpId) | 40 | void DBusInterface::ShowFolders(const QStringList& uriList, const QString& startUpId) | ||
38 | { | 41 | { | ||
39 | Q_UNUSED(startUpId); | | |||
elvisangelaccio: Why drop the `Q_UNUSED` ? This variable is still unused. | |||||
40 | const QList<QUrl> urls = Dolphin::validateUris(uriList); | 42 | const QList<QUrl> urls = Dolphin::validateUris(uriList); | ||
41 | if (urls.isEmpty()) { | 43 | if (urls.isEmpty()) { | ||
42 | return; | 44 | return; | ||
43 | } | 45 | } | ||
44 | Dolphin::openNewWindow(urls); | 46 | QString serviceName = QString("org.kde.dolphin-") + QString::number(qApp->applicationPid()); | ||
47 | QScopedPointer<QDBusInterface> service; | ||||
48 | service.reset(new QDBusInterface(serviceName, | ||||
49 | QStringLiteral("/dolphin/Dolphin_1"), | ||||
50 | QStringLiteral("org.kde.dolphin.MainWindow"))); | ||||
51 | if (!service->isValid()) { | ||||
52 | return; | ||||
53 | } | ||||
54 | service->call(QStringLiteral("openDirectories"), | ||||
55 | QUrl::toStringList(urls), | ||||
56 | GeneralSettings::splitView()); | ||||
57 | service->call(QStringLiteral("tryRaise")); | ||||
elvisangelaccio: - Please add `const`
- Please prefer `QCoreApplication::applicationPid()`
- Please use… | |||||
45 | } | 58 | } | ||
elvisangelaccio: This could be in a single line ;) | |||||
46 | 59 | | |||
47 | void DBusInterface::ShowItems(const QStringList& uriList, const QString& startUpId) | 60 | void DBusInterface::ShowItems(const QStringList& uriList, const QString& startUpId) | ||
48 | { | 61 | { | ||
49 | Q_UNUSED(startUpId); | | |||
50 | const QList<QUrl> urls = Dolphin::validateUris(uriList); | 62 | const QList<QUrl> urls = Dolphin::validateUris(uriList); | ||
51 | if (urls.isEmpty()) { | 63 | if (urls.isEmpty()) { | ||
52 | return; | 64 | return; | ||
53 | } | 65 | } | ||
54 | Dolphin::openNewWindow(urls, nullptr, Dolphin::OpenNewWindowFlag::Select); | 66 | QString serviceName = QString("org.kde.dolphin-") + QString::number(qApp->applicationPid()); | ||
67 | QScopedPointer<QDBusInterface> service; | ||||
68 | service.reset(new QDBusInterface(serviceName, | ||||
69 | QStringLiteral("/dolphin/Dolphin_1"), | ||||
70 | QStringLiteral("org.kde.dolphin.MainWindow"))); | ||||
71 | if (!service->isValid()) { | ||||
72 | return; | ||||
73 | } | ||||
74 | service->call(QStringLiteral("openFiles"), | ||||
75 | QUrl::toStringList(urls), | ||||
76 | GeneralSettings::splitView()); | ||||
77 | service->call(QStringLiteral("tryRaise")); | ||||
55 | } | 78 | } | ||
56 | 79 | | |||
57 | void DBusInterface::ShowItemProperties(const QStringList& uriList, const QString& startUpId) | 80 | void DBusInterface::ShowItemProperties(const QStringList& uriList, const QString& startUpId) | ||
58 | { | 81 | { | ||
59 | Q_UNUSED(startUpId); | 82 | Q_UNUSED(startUpId); | ||
60 | const QList<QUrl> urls = Dolphin::validateUris(uriList); | 83 | const QList<QUrl> urls = Dolphin::validateUris(uriList); | ||
61 | if (!urls.isEmpty()) { | 84 | if (!urls.isEmpty()) { | ||
62 | KPropertiesDialog::showDialog(urls); | 85 | KPropertiesDialog::showDialog(urls); | ||
63 | } | 86 | } | ||
64 | } | 87 | } |
Why drop the Q_UNUSED ? This variable is still unused.