Changeset View
Changeset View
Standalone View
Standalone View
fileitemactionplugin/sendfileitemaction.cpp
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 47 | { | |||
---|---|---|---|---|---|
50 | DaemonDbusInterface iface; | 50 | DaemonDbusInterface iface; | ||
51 | if (!iface.isValid()) { | 51 | if (!iface.isValid()) { | ||
52 | return actions; | 52 | return actions; | ||
53 | } | 53 | } | ||
54 | 54 | | |||
55 | QDBusPendingReply<QStringList> reply = iface.devices(true, true); | 55 | QDBusPendingReply<QStringList> reply = iface.devices(true, true); | ||
56 | reply.waitForFinished(); | 56 | reply.waitForFinished(); | ||
57 | const QStringList devices = reply.value(); | 57 | const QStringList devices = reply.value(); | ||
58 | Q_FOREACH (const QString& id, devices) { | 58 | for (const QString& id : devices) { | ||
59 | DeviceDbusInterface deviceIface(id); | 59 | DeviceDbusInterface deviceIface(id); | ||
60 | if (!deviceIface.isValid()) { | 60 | if (!deviceIface.isValid()) { | ||
61 | continue; | 61 | continue; | ||
62 | } | 62 | } | ||
63 | if (!deviceIface.hasPlugin(QStringLiteral("kdeconnect_share"))) { | 63 | if (!deviceIface.hasPlugin(QStringLiteral("kdeconnect_share"))) { | ||
64 | continue; | 64 | continue; | ||
65 | } | 65 | } | ||
66 | QAction* action = new QAction(QIcon::fromTheme(deviceIface.iconName()), deviceIface.name(), parentWidget); | 66 | QAction* action = new QAction(QIcon::fromTheme(deviceIface.iconName()), deviceIface.name(), parentWidget); | ||
Show All 15 Lines | 81 | if(actions.count() == 1) { | |||
82 | actions.first()->setText(i18n("Send to '%1' via KDE Connect", actions.first()->text())); | 82 | actions.first()->setText(i18n("Send to '%1' via KDE Connect", actions.first()->text())); | ||
83 | } | 83 | } | ||
84 | return actions; | 84 | return actions; | ||
85 | } | 85 | } | ||
86 | } | 86 | } | ||
87 | 87 | | |||
88 | void SendFileItemAction::sendFile() | 88 | void SendFileItemAction::sendFile() | ||
89 | { | 89 | { | ||
90 | QList<QUrl> urls = sender()->property("urls").value<QList<QUrl>>(); | 90 | const QList<QUrl> urls = sender()->property("urls").value<QList<QUrl>>(); | ||
91 | QString id = sender()->property("id").toString(); | 91 | QString id = sender()->property("id").toString(); | ||
92 | Q_FOREACH (const QUrl& url, urls) { | 92 | for (const QUrl& url : urls) { | ||
93 | QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+id+"/share", QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareUrl")); | 93 | QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), "/modules/kdeconnect/devices/"+id+"/share", QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("shareUrl")); | ||
94 | msg.setArguments(QVariantList() << url.toString()); | 94 | msg.setArguments(QVariantList() << url.toString()); | ||
95 | QDBusConnection::sessionBus().call(msg); | 95 | QDBusConnection::sessionBus().call(msg); | ||
96 | } | 96 | } | ||
97 | } | 97 | } | ||
98 | 98 | | |||
99 | #include "sendfileitemaction.moc" | 99 | #include "sendfileitemaction.moc" |