[Photo Plugin] Make photo plugin use QUrl instead of a local path
This is a companion merge request for !476, this way it can be accessed directly from QML's FileDialog
This commit is contained in:
parent
5639905b8d
commit
186526c0bb
3 changed files with 9 additions and 9 deletions
|
@ -295,7 +295,7 @@ int main(int argc, char** argv)
|
||||||
const QString fileName = parser.value(QStringLiteral("photo"));
|
const QString fileName = parser.value(QStringLiteral("photo"));
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + device + QStringLiteral("/photo"), QStringLiteral("org.kde.kdeconnect.device.photo"), QStringLiteral("requestPhoto"));
|
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/modules/kdeconnect/devices/") + device + QStringLiteral("/photo"), QStringLiteral("org.kde.kdeconnect.device.photo"), QStringLiteral("requestPhoto"));
|
||||||
msg.setArguments({fileName});
|
msg.setArguments({QUrl::fromLocalFile(fileName).toString()});
|
||||||
blockOnReply(QDBusConnection::sessionBus().asyncCall(msg));
|
blockOnReply(QDBusConnection::sessionBus().asyncCall(msg));
|
||||||
} else {
|
} else {
|
||||||
QTextStream(stderr) << i18n("Please specify a filename for the photo") << endl;
|
QTextStream(stderr) << i18n("Please specify a filename for the photo") << endl;
|
||||||
|
|
|
@ -35,18 +35,18 @@ bool PhotoPlugin::receivePacket(const NetworkPacket& np)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& fileName = requestedFiles.takeFirst();
|
const QString url = requestedFiles.takeFirst();
|
||||||
FileTransferJob* job = np.createPayloadTransferJob(QUrl::fromLocalFile(fileName));
|
FileTransferJob* job = np.createPayloadTransferJob(QUrl(url));
|
||||||
connect(job, &FileTransferJob::result, this, [this, fileName] {
|
connect(job, &FileTransferJob::result, this, [this, url] {
|
||||||
Q_EMIT photoReceived(fileName);
|
Q_EMIT photoReceived(url);
|
||||||
});
|
});
|
||||||
job->start();
|
job->start();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhotoPlugin::requestPhoto(const QString& fileName)
|
void PhotoPlugin::requestPhoto(const QString& url)
|
||||||
{
|
{
|
||||||
requestedFiles.append(fileName);
|
requestedFiles.append(url);
|
||||||
NetworkPacket np(PACKET_TYPE_PHOTO_REQUEST);
|
NetworkPacket np(PACKET_TYPE_PHOTO_REQUEST);
|
||||||
sendPacket(np);
|
sendPacket(np);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public:
|
||||||
explicit PhotoPlugin(QObject* parent, const QVariantList& args);
|
explicit PhotoPlugin(QObject* parent, const QVariantList& args);
|
||||||
~PhotoPlugin() override;
|
~PhotoPlugin() override;
|
||||||
|
|
||||||
Q_SCRIPTABLE void requestPhoto(const QString& fileName);
|
Q_SCRIPTABLE void requestPhoto(const QString& url);
|
||||||
|
|
||||||
bool receivePacket(const NetworkPacket& np) override;
|
bool receivePacket(const NetworkPacket& np) override;
|
||||||
void connected() override {}
|
void connected() override {}
|
||||||
|
@ -32,7 +32,7 @@ public:
|
||||||
QString dbusPath() const override;
|
QString dbusPath() const override;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
Q_SCRIPTABLE void photoReceived(const QString& fileName);
|
Q_SCRIPTABLE void photoReceived(const QString& url);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStringList requestedFiles;
|
QStringList requestedFiles;
|
||||||
|
|
Loading…
Reference in a new issue