Fixed Dolphin's extension
It was not working because it used the model (that is now async) instead of dbus interfaces. CCMAIL: aleixpol@kde.org
This commit is contained in:
parent
e20c3c907d
commit
4477ff29d9
1 changed files with 28 additions and 21 deletions
|
@ -19,23 +19,21 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sendfileitemaction.h"
|
#include "sendfileitemaction.h"
|
||||||
#include <interfaces/devicesmodel.h>
|
|
||||||
#include <interfaces/dbusinterfaces.h>
|
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QVariantList>
|
#include <QVariantList>
|
||||||
|
#include <QUrl>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
#include <KPluginFactory>
|
#include <KPluginFactory>
|
||||||
#include <KPluginLoader>
|
#include <KPluginLoader>
|
||||||
|
|
||||||
#include <KProcess>
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <QUrl>
|
|
||||||
|
#include <interfaces/devicesmodel.h>
|
||||||
|
#include <interfaces/dbusinterfaces.h>
|
||||||
|
|
||||||
K_PLUGIN_FACTORY(SendFileItemActionFactory, registerPlugin<SendFileItemAction>();)
|
K_PLUGIN_FACTORY(SendFileItemActionFactory, registerPlugin<SendFileItemAction>();)
|
||||||
|
|
||||||
|
@ -47,21 +45,30 @@ SendFileItemAction::SendFileItemAction(QObject* parent, const QVariantList& ): K
|
||||||
|
|
||||||
QList<QAction*> SendFileItemAction::actions(const KFileItemListProperties& fileItemInfos, QWidget* parentWidget)
|
QList<QAction*> SendFileItemAction::actions(const KFileItemListProperties& fileItemInfos, QWidget* parentWidget)
|
||||||
{
|
{
|
||||||
DevicesModel m;
|
|
||||||
|
|
||||||
QList<QAction*> actions;
|
QList<QAction*> actions;
|
||||||
|
|
||||||
for(int i = 0; i<m.rowCount(); ++i) {
|
DaemonDbusInterface iface;
|
||||||
QModelIndex idx = m.index(i);
|
if (!iface.isValid()) {
|
||||||
DeviceDbusInterface* dev = m.getDevice(idx);
|
return actions;
|
||||||
if(dev->isReachable() && dev->isPaired()) {
|
}
|
||||||
QAction* action = new QAction(QIcon::fromTheme(dev->iconName()), dev->name(), parentWidget);
|
|
||||||
action->setProperty("id", idx.data(DevicesModel::IdModelRole));
|
QDBusPendingReply<QStringList> reply = iface.devices(true, true);
|
||||||
action->setProperty("urls", QVariant::fromValue(fileItemInfos.urlList()));
|
reply.waitForFinished();
|
||||||
action->setProperty("parentWidget", QVariant::fromValue(parentWidget));
|
const QStringList devices = reply.value();
|
||||||
connect(action, SIGNAL(triggered(bool)), this, SLOT(sendFile()));
|
foreach (const QString& id, devices) {
|
||||||
actions += action;
|
DeviceDbusInterface deviceIface(id);
|
||||||
|
if (!deviceIface.isValid()) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!deviceIface.hasPlugin("kdeconnect_share")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QAction* action = new QAction(QIcon::fromTheme(deviceIface.iconName()), deviceIface.name(), parentWidget);
|
||||||
|
action->setProperty("id", id);
|
||||||
|
action->setProperty("urls", QVariant::fromValue(fileItemInfos.urlList()));
|
||||||
|
action->setProperty("parentWidget", QVariant::fromValue(parentWidget));
|
||||||
|
connect(action, SIGNAL(triggered(bool)), this, SLOT(sendFile()));
|
||||||
|
actions += action;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actions.count() > 1) {
|
if (actions.count() > 1) {
|
||||||
|
@ -81,10 +88,10 @@ QList<QAction*> SendFileItemAction::actions(const KFileItemListProperties& fileI
|
||||||
void SendFileItemAction::sendFile()
|
void SendFileItemAction::sendFile()
|
||||||
{
|
{
|
||||||
QList<QUrl> urls = sender()->property("urls").value<QList<QUrl>>();
|
QList<QUrl> urls = sender()->property("urls").value<QList<QUrl>>();
|
||||||
|
QString id = sender()->property("id").toString();
|
||||||
foreach(const QUrl& url, urls) {
|
foreach(const QUrl& url, urls) {
|
||||||
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+sender()->property("id").toString()+"/share", "org.kde.kdeconnect.device.share", "shareUrl");
|
QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kdeconnect", "/modules/kdeconnect/devices/"+id+"/share", "org.kde.kdeconnect.device.share", "shareUrl");
|
||||||
msg.setArguments(QVariantList() << url.toString());
|
msg.setArguments(QVariantList() << url.toString());
|
||||||
|
|
||||||
QDBusConnection::sessionBus().call(msg);
|
QDBusConnection::sessionBus().call(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue