Skip to content
Snippets Groups Projects
Commit 74ec3d15 authored by akiraohgaki's avatar akiraohgaki
Browse files

Add openDestination slot

parent 723f5c49
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <QTemporaryFile> #include <QTemporaryFile>
#include <QMimeDatabase> #include <QMimeDatabase>
#include <QNetworkReply> #include <QNetworkReply>
#include <QDesktopServices>
#include "../core/config.h" #include "../core/config.h"
#include "../core/network.h" #include "../core/network.h"
...@@ -131,6 +132,8 @@ void XdgUrl::_saveDownloadedFile(QNetworkReply *reply) ...@@ -131,6 +132,8 @@ void XdgUrl::_saveDownloadedFile(QNetworkReply *reply)
return; return;
} }
_destination = destination;
result["status"] = QString("success_download"); result["status"] = QString("success_download");
result["message"] = QString("The file has been stored into " + destination); result["message"] = QString("The file has been stored into " + destination);
emit finished(Utility::Json::convertObjToStr(result)); emit finished(Utility::Json::convertObjToStr(result));
...@@ -207,6 +210,8 @@ void XdgUrl::_installDownloadedFile(QNetworkReply *reply) ...@@ -207,6 +210,8 @@ void XdgUrl::_installDownloadedFile(QNetworkReply *reply)
return; return;
} }
_destination = destination;
result["status"] = QString("success_install"); result["status"] = QString("success_install");
emit finished(Utility::Json::convertObjToStr(result)); emit finished(Utility::Json::convertObjToStr(result));
} }
...@@ -303,4 +308,11 @@ void XdgUrl::process() ...@@ -303,4 +308,11 @@ void XdgUrl::process()
emit started(); emit started();
} }
void XdgUrl::openDestination()
{
if (!_destination.isEmpty()) {
QDesktopServices::openUrl(QUrl("file://" + _destination));
}
}
} // namespace Handlers } // namespace Handlers
...@@ -24,6 +24,7 @@ private: ...@@ -24,6 +24,7 @@ private:
QJsonObject _metadata; QJsonObject _metadata;
QJsonObject _destinations; QJsonObject _destinations;
QString _destination;
public: public:
explicit XdgUrl(const QString &xdgUrl, Core::Config *config, Core::Network *network, QObject *parent = 0); explicit XdgUrl(const QString &xdgUrl, Core::Config *config, Core::Network *network, QObject *parent = 0);
...@@ -43,6 +44,7 @@ public slots: ...@@ -43,6 +44,7 @@ public slots:
QString getMetadata(); QString getMetadata();
bool isValid(); bool isValid();
void process(); void process();
void openDestination();
signals: signals:
void started(); void started();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment