Commit 8e548519 authored by camilo higuita's avatar camilo higuita

coreect issue with lost downloader improvements on merges and using png icon...

coreect issue with lost downloader improvements on merges and using png icon on windows and android instead of svgs and no mor esymblinks there
parent f8e42360
......@@ -49,6 +49,11 @@ linux:unix:!android {
}
}else:win32 {
message("Using OpenSSL for Windows")
LIBS += -L$$PWD/../../../../../../Qt/Tools/OpenSSL/Win_x64/lib/ -llibssl
LIBS += -L$$PWD/../../../../../../Qt/Tools/OpenSSL/Win_x64/lib/ -llibcrypto
}
......@@ -79,8 +84,14 @@ linux:unix:!android {
system(git clone $$LUV_REPO $$PWD/src/maui-style/icons/luv-icon-theme)
}
RESOURCES += $$PWD/src/maui-style/icons.qrc \
$$PWD/src/maui-style/style.qrc
RESOURCES += $$PWD/src/maui-style/style.qrc
win32|android: {
DEFINES += ICONS_PNG
RESOURCES += $$PWD/src/maui-style/icons_png.qrc
}else {
RESOURCES += $$PWD/src/maui-style/icons.qrc
}
}
contains(DEFINES, COMPONENT_TAGGING):{
......@@ -324,3 +335,4 @@ DISTFILES += \
#LIBS += -L$$PWD/libs/bin/ -lKF5ConfigCore
#INCLUDEPATH += $$PWD/libs/includes/KConfigCore
#DEPENDPATH += $$PWD/libs/includes/KConfigCore
#include "downloader.h"
FMH::Downloader::Downloader(QObject *parent) : QObject(parent), manager(new QNetworkAccessManager)
FMH::Downloader::Downloader(QObject *parent) : QObject(parent), manager(new QNetworkAccessManager), array(new QByteArray)
{}
FMH::Downloader::~Downloader()
FMH::Downloader::~Downloader()
{
qDebug()<< "DELETEING DOWNLOADER";
this->manager->deleteLater();
// this->reply->deleteLater();
this->reply->deleteLater();
this->reply = nullptr;
this->array->clear();
}
void FMH::Downloader::setFile(const QString &fileURL, const QString &fileName)
void FMH::Downloader::setFile(const QUrl &fileURL, const QUrl &fileName)
{
QString filePath = fileURL;
if(fileName.isEmpty() || fileURL.isEmpty())
return;
QNetworkRequest request;
request.setUrl(QUrl(fileURL));
request.setUrl(fileURL);
reply = manager->get(request);
file = new QFile;
file->setFileName(QUrl(fileName).toLocalFile());
file->setFileName(fileName.toLocalFile());
if(!file->open(QIODevice::WriteOnly))
qWarning() << "Could not open file to save download";
qWarning()<< "can not open file to write download";
qDebug() << QSslSocket::sslLibraryBuildVersionString();
qDebug() << QSslSocket::supportsSsl();
qDebug() << QSslSocket::sslLibraryVersionString();
connect(reply, SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(onDownloadProgress(qint64,qint64)));
connect(manager, SIGNAL(finished(QNetworkReply*)),this,SLOT(onFinished(QNetworkReply*)));
......@@ -33,29 +37,29 @@ void FMH::Downloader::setFile(const QString &fileURL, const QString &fileName)
connect(reply, SIGNAL(finished()),this,SLOT(onReplyFinished()));
}
void FMH::Downloader::getArray(const QString &fileURL, const QMap<QString, QString> &headers)
void FMH::Downloader::getArray(const QUrl &fileURL, const QMap<QString, QString> &headers)
{
qDebug() << fileURL << headers;
if(fileURL.isEmpty())
return;
QNetworkRequest request;
request.setUrl(QUrl(fileURL));
request.setUrl(fileURL);
if(!headers.isEmpty())
{
for(auto key: headers.keys())
for(const auto &key: headers.keys())
request.setRawHeader(key.toLocal8Bit(), headers[key].toLocal8Bit());
}
reply = manager->get(request);
connect(reply, &QNetworkReply::readyRead, [this]()
connect(reply, &QIODevice::readyRead, [this]()
{
switch(reply->error())
{
case QNetworkReply::NoError:
{
this->array = reply->readAll();
this->array->append(reply->readAll());
break;
}
......@@ -67,14 +71,16 @@ void FMH::Downloader::getArray(const QString &fileURL, const QMap<QString, QStri
}
});
connect(reply, &QNetworkReply::finished, [=]()
connect(reply, &QNetworkReply::finished, [this]()
{
qDebug() << "Array reply is now finished";
emit this->dataReady(this->array);
emit this->dataReady(*this->array);
emit this->done();
});
}
void FMH::Downloader::onDownloadProgress(qint64 bytesRead, qint64 bytesTotal)
{
emit this->progress((bytesRead * bytesTotal) / 100);
......@@ -94,7 +100,7 @@ void FMH::Downloader::onFinished(QNetworkReply *reply)
default:
{
emit this->warning(reply->errorString());
};
}
}
if(file->isOpen())
......@@ -103,10 +109,12 @@ void FMH::Downloader::onFinished(QNetworkReply *reply)
emit this->fileSaved(file->fileName());
file->deleteLater();
}
}
void FMH::Downloader::onReadyRead()
{
qDebug()<< "WRITTING TO FILE >>>>>";
file->write(reply->readAll());
// emit this->fileSaved(file->fileName());
}
......
......@@ -25,16 +25,14 @@ public:
Downloader(QObject *parent = nullptr);
virtual ~Downloader();
void setFile(const QString &fileURL, const QString &fileName = QString());
void getArray(const QString &fileURL, const QMap<QString, QString> &headers = {});
void setFile(const QUrl &fileURL, const QUrl &fileName = QUrl());
void getArray(const QUrl &fileURL, const QMap<QString, QString> &headers = {});
private:
QNetworkAccessManager *manager;
QNetworkReply *reply;
QFile *file;
QByteArray array;
QByteArray *array;
signals:
void progress(int percent);
......
......@@ -220,7 +220,11 @@ void MauiKit::initResources()
{
#if defined QICON_H && defined QQUICKSTYLE_H
Q_INIT_RESOURCE(mauikit);
#ifdef ICONS_PNG
Q_INIT_RESOURCE(icons_png);
#else
Q_INIT_RESOURCE(icons);
#endif
Q_INIT_RESOURCE(style);
QIcon::setThemeSearchPaths({":/icons/luv-icon-theme"});
QIcon::setThemeName("Luv");
......
Markdown is supported
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