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); | 42 | Q_UNUSED(startUpId); | ||
elvisangelaccio: Why drop the `Q_UNUSED` ? This variable is still unused. | |||||
40 | const QList<QUrl> urls = Dolphin::validateUris(uriList); | 43 | const QList<QUrl> urls = Dolphin::validateUris(uriList); | ||
41 | if (urls.isEmpty()) { | 44 | if (urls.isEmpty()) { | ||
42 | return; | 45 | return; | ||
43 | } | 46 | } | ||
44 | Dolphin::openNewWindow(urls); | 47 | const auto serviceName = QStringLiteral("org.kde.dolphin-%1").arg( | ||
48 | QCoreApplication::applicationPid() | ||||
49 | ); | ||||
elvisangelaccio: This could be in a single line ;) | |||||
50 | QScopedPointer<QDBusInterface> service; | ||||
51 | service.reset(new QDBusInterface(serviceName, | ||||
52 | QStringLiteral("/dolphin/Dolphin_1"), | ||||
53 | QStringLiteral("org.kde.dolphin.MainWindow"))); | ||||
54 | if (!service->isValid()) { | ||||
55 | return; | ||||
56 | } | ||||
57 | service->call(QStringLiteral("openDirectories"), | ||||
58 | QUrl::toStringList(urls), | ||||
59 | GeneralSettings::splitView()); | ||||
60 | service->call(QStringLiteral("activateWindow")); | ||||
elvisangelaccio: - Please add `const`
- Please prefer `QCoreApplication::applicationPid()`
- Please use… | |||||
45 | } | 61 | } | ||
46 | 62 | | |||
47 | void DBusInterface::ShowItems(const QStringList& uriList, const QString& startUpId) | 63 | void DBusInterface::ShowItems(const QStringList& uriList, const QString& startUpId) | ||
48 | { | 64 | { | ||
49 | Q_UNUSED(startUpId); | | |||
50 | const QList<QUrl> urls = Dolphin::validateUris(uriList); | 65 | const QList<QUrl> urls = Dolphin::validateUris(uriList); | ||
51 | if (urls.isEmpty()) { | 66 | if (urls.isEmpty()) { | ||
52 | return; | 67 | return; | ||
53 | } | 68 | } | ||
54 | Dolphin::openNewWindow(urls, nullptr, Dolphin::OpenNewWindowFlag::Select); | 69 | const auto serviceName = QStringLiteral("org.kde.dolphin-%1").arg( | ||
70 | QCoreApplication::applicationPid() | ||||
71 | ); | ||||
72 | QScopedPointer<QDBusInterface> service; | ||||
73 | service.reset(new QDBusInterface(serviceName, | ||||
74 | QStringLiteral("/dolphin/Dolphin_1"), | ||||
75 | QStringLiteral("org.kde.dolphin.MainWindow"))); | ||||
76 | if (!service->isValid()) { | ||||
77 | return; | ||||
78 | } | ||||
79 | service->call(QStringLiteral("openFiles"), | ||||
80 | QUrl::toStringList(urls), | ||||
81 | GeneralSettings::splitView()); | ||||
82 | service->call(QStringLiteral("activateWindow")); | ||||
55 | } | 83 | } | ||
56 | 84 | | |||
57 | void DBusInterface::ShowItemProperties(const QStringList& uriList, const QString& startUpId) | 85 | void DBusInterface::ShowItemProperties(const QStringList& uriList, const QString& startUpId) | ||
58 | { | 86 | { | ||
59 | Q_UNUSED(startUpId); | 87 | Q_UNUSED(startUpId); | ||
60 | const QList<QUrl> urls = Dolphin::validateUris(uriList); | 88 | const QList<QUrl> urls = Dolphin::validateUris(uriList); | ||
61 | if (!urls.isEmpty()) { | 89 | if (!urls.isEmpty()) { | ||
62 | KPropertiesDialog::showDialog(urls); | 90 | KPropertiesDialog::showDialog(urls); | ||
63 | } | 91 | } | ||
64 | } | 92 | } |
Why drop the Q_UNUSED ? This variable is still unused.