Commit 186526c0 authored by Kareem Abduljaleel's avatar Kareem Abduljaleel Committed by Aleix Pol Gonzalez
Browse files

[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
parent 5639905b
Pipeline #226316 passed with stage
in 4 minutes and 27 seconds
......@@ -295,7 +295,7 @@ int main(int argc, char** argv)
const QString fileName = parser.value(QStringLiteral("photo"));
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"));
msg.setArguments({fileName});
msg.setArguments({QUrl::fromLocalFile(fileName).toString()});
blockOnReply(QDBusConnection::sessionBus().asyncCall(msg));
} else {
QTextStream(stderr) << i18n("Please specify a filename for the photo") << endl;
......
......@@ -35,18 +35,18 @@ bool PhotoPlugin::receivePacket(const NetworkPacket& np)
return true;
}
const QString& fileName = requestedFiles.takeFirst();
FileTransferJob* job = np.createPayloadTransferJob(QUrl::fromLocalFile(fileName));
connect(job, &FileTransferJob::result, this, [this, fileName] {
Q_EMIT photoReceived(fileName);
const QString url = requestedFiles.takeFirst();
FileTransferJob* job = np.createPayloadTransferJob(QUrl(url));
connect(job, &FileTransferJob::result, this, [this, url] {
Q_EMIT photoReceived(url);
});
job->start();
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);
sendPacket(np);
}
......
......@@ -24,7 +24,7 @@ public:
explicit PhotoPlugin(QObject* parent, const QVariantList& args);
~PhotoPlugin() override;
Q_SCRIPTABLE void requestPhoto(const QString& fileName);
Q_SCRIPTABLE void requestPhoto(const QString& url);
bool receivePacket(const NetworkPacket& np) override;
void connected() override {}
......@@ -32,7 +32,7 @@ public:
QString dbusPath() const override;
Q_SIGNALS:
Q_SCRIPTABLE void photoReceived(const QString& fileName);
Q_SCRIPTABLE void photoReceived(const QString& url);
private:
QStringList requestedFiles;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment