diff --git a/plugins/share/shareplugin.cpp b/plugins/share/shareplugin.cpp index 31bc7b1ec..a45026633 100644 --- a/plugins/share/shareplugin.cpp +++ b/plugins/share/shareplugin.cpp @@ -192,13 +192,14 @@ void SharePlugin::openDestinationFolder() QDesktopServices::openUrl(destinationDir()); } -void SharePlugin::shareUrl(const QUrl& url) +void SharePlugin::shareUrl(const QUrl& url, bool open) { NetworkPacket packet(PACKET_TYPE_SHARE_REQUEST); - if(url.isLocalFile()) { + if (url.isLocalFile()) { QSharedPointer ioFile(new QFile(url.toLocalFile())); packet.setPayload(ioFile, ioFile->size()); packet.set(QStringLiteral("filename"), QUrl(url).fileName()); + packet.set(QStringLiteral("open"), open); } else { packet.set(QStringLiteral("url"), url.toString()); } @@ -207,7 +208,7 @@ void SharePlugin::shareUrl(const QUrl& url) void SharePlugin::shareUrls(const QStringList& urls) { for(const QString& url : urls) { - shareUrl(QUrl(url)); + shareUrl(QUrl(url), false); } } @@ -218,18 +219,6 @@ void SharePlugin::shareText(const QString& text) sendPacket(packet); } -void SharePlugin::openFile(const QUrl& url) -{ - NetworkPacket packet(PACKET_TYPE_SHARE_REQUEST); - if(url.isLocalFile()) { - QSharedPointer ioFile(new QFile(url.toLocalFile())); - packet.setPayload(ioFile, ioFile->size()); - packet.set(QStringLiteral("filename"), QUrl(url).fileName()); - packet.set(QStringLiteral("open"), true); - } - sendPacket(packet); -} - QString SharePlugin::dbusPath() const { return QStringLiteral("/modules/kdeconnect/devices/") + device()->id() + QStringLiteral("/share"); diff --git a/plugins/share/shareplugin.h b/plugins/share/shareplugin.h index e952824e9..e542a992d 100644 --- a/plugins/share/shareplugin.h +++ b/plugins/share/shareplugin.h @@ -41,10 +41,10 @@ public: explicit SharePlugin(QObject* parent, const QVariantList& args); ///Helper method, QDBus won't recognize QUrl - Q_SCRIPTABLE void shareUrl(const QString& url) { shareUrl(QUrl(url)); } + Q_SCRIPTABLE void shareUrl(const QString& url) { shareUrl(QUrl(url), false); } Q_SCRIPTABLE void shareUrls(const QStringList& urls); Q_SCRIPTABLE void shareText(const QString& text); - Q_SCRIPTABLE void openFile(const QString& file) { openFile(QUrl(file)); } + Q_SCRIPTABLE void openFile(const QString& file) { shareUrl(QUrl(file), true); } bool receivePacket(const NetworkPacket& np) override; void connected() override {} @@ -58,8 +58,7 @@ Q_SIGNALS: private: void finished(KJob* job, const qint64 dateModified); - void shareUrl(const QUrl& url); - void openFile(const QUrl& url); + void shareUrl(const QUrl& url, bool open); QUrl destinationDir() const; QUrl getFileDestination(const QString filename) const; void setDateModified(const QUrl& destination, const qint64 timestamp);