From 74ec3d154d0f3ecb6b69f3c21608010d78022166 Mon Sep 17 00:00:00 2001 From: Akira Ohgaki <akiraohgaki@gmail.com> Date: Sat, 15 Oct 2016 10:33:43 +0900 Subject: [PATCH] Add openDestination slot --- src/handlers/xdgurl.cpp | 12 ++++++++++++ src/handlers/xdgurl.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/handlers/xdgurl.cpp b/src/handlers/xdgurl.cpp index c5d4dbf..b73698d 100644 --- a/src/handlers/xdgurl.cpp +++ b/src/handlers/xdgurl.cpp @@ -3,6 +3,7 @@ #include <QTemporaryFile> #include <QMimeDatabase> #include <QNetworkReply> +#include <QDesktopServices> #include "../core/config.h" #include "../core/network.h" @@ -131,6 +132,8 @@ void XdgUrl::_saveDownloadedFile(QNetworkReply *reply) return; } + _destination = destination; + result["status"] = QString("success_download"); result["message"] = QString("The file has been stored into " + destination); emit finished(Utility::Json::convertObjToStr(result)); @@ -207,6 +210,8 @@ void XdgUrl::_installDownloadedFile(QNetworkReply *reply) return; } + _destination = destination; + result["status"] = QString("success_install"); emit finished(Utility::Json::convertObjToStr(result)); } @@ -303,4 +308,11 @@ void XdgUrl::process() emit started(); } +void XdgUrl::openDestination() +{ + if (!_destination.isEmpty()) { + QDesktopServices::openUrl(QUrl("file://" + _destination)); + } +} + } // namespace Handlers diff --git a/src/handlers/xdgurl.h b/src/handlers/xdgurl.h index becb669..4270252 100644 --- a/src/handlers/xdgurl.h +++ b/src/handlers/xdgurl.h @@ -24,6 +24,7 @@ private: QJsonObject _metadata; QJsonObject _destinations; + QString _destination; public: explicit XdgUrl(const QString &xdgUrl, Core::Config *config, Core::Network *network, QObject *parent = 0); @@ -43,6 +44,7 @@ public slots: QString getMetadata(); bool isValid(); void process(); + void openDestination(); signals: void started(); -- GitLab