mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Refactor DownloaderManager private member variable names
This commit is contained in:
parent
7131f9ed36
commit
7d350adfeb
|
@ -1,21 +1,21 @@
|
||||||
#include "DownloadManager.hpp"
|
#include "DownloadManager.hpp"
|
||||||
|
|
||||||
|
#include "common/QLogging.hpp"
|
||||||
#include "singletons/Paths.hpp"
|
#include "singletons/Paths.hpp"
|
||||||
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include "common/QLogging.hpp"
|
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
DownloadManager::DownloadManager(QObject *parent)
|
DownloadManager::DownloadManager(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
|
, manager_(new QNetworkAccessManager)
|
||||||
{
|
{
|
||||||
manager = new QNetworkAccessManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadManager::~DownloadManager()
|
DownloadManager::~DownloadManager()
|
||||||
{
|
{
|
||||||
manager->deleteLater();
|
this->manager_->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::setFile(QString fileURL, const QString &channelName)
|
void DownloadManager::setFile(QString fileURL, const QString &channelName)
|
||||||
|
@ -25,18 +25,18 @@ void DownloadManager::setFile(QString fileURL, const QString &channelName)
|
||||||
getPaths()->twitchProfileAvatars + "/twitch/" + channelName + ".png";
|
getPaths()->twitchProfileAvatars + "/twitch/" + channelName + ".png";
|
||||||
QNetworkRequest request;
|
QNetworkRequest request;
|
||||||
request.setUrl(QUrl(fileURL));
|
request.setUrl(QUrl(fileURL));
|
||||||
reply = manager->get(request);
|
this->reply_ = this->manager_->get(request);
|
||||||
|
|
||||||
file = new QFile;
|
this->file_ = new QFile;
|
||||||
file->setFileName(saveFilePath);
|
this->file_->setFileName(saveFilePath);
|
||||||
file->open(QIODevice::WriteOnly);
|
this->file_->open(QIODevice::WriteOnly);
|
||||||
|
|
||||||
connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this,
|
connect(this->reply_, SIGNAL(downloadProgress(qint64, qint64)), this,
|
||||||
SLOT(onDownloadProgress(qint64, qint64)));
|
SLOT(onDownloadProgress(qint64, qint64)));
|
||||||
connect(manager, SIGNAL(finished(QNetworkReply *)), this,
|
connect(this->manager_, SIGNAL(finished(QNetworkReply *)), this,
|
||||||
SLOT(onFinished(QNetworkReply *)));
|
SLOT(onFinished(QNetworkReply *)));
|
||||||
connect(reply, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
|
connect(this->reply_, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
|
||||||
connect(reply, SIGNAL(finished()), this, SLOT(onReplyFinished()));
|
connect(this->reply_, SIGNAL(finished()), this, SLOT(onReplyFinished()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::onDownloadProgress(qint64 bytesRead, qint64 bytesTotal)
|
void DownloadManager::onDownloadProgress(qint64 bytesRead, qint64 bytesTotal)
|
||||||
|
@ -58,25 +58,26 @@ void DownloadManager::onFinished(QNetworkReply *reply)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file->isOpen())
|
if (this->file_->isOpen())
|
||||||
{
|
{
|
||||||
file->close();
|
this->file_->close();
|
||||||
file->deleteLater();
|
this->file_->deleteLater();
|
||||||
}
|
}
|
||||||
emit downloadComplete();
|
emit downloadComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::onReadyRead()
|
void DownloadManager::onReadyRead()
|
||||||
{
|
{
|
||||||
file->write(reply->readAll());
|
this->file_->write(this->reply_->readAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::onReplyFinished()
|
void DownloadManager::onReplyFinished()
|
||||||
{
|
{
|
||||||
if (file->isOpen())
|
if (this->file_->isOpen())
|
||||||
{
|
{
|
||||||
file->close();
|
this->file_->close();
|
||||||
file->deleteLater();
|
this->file_->deleteLater();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Application.hpp"
|
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
@ -20,9 +18,9 @@ public:
|
||||||
void setFile(QString fileURL, const QString &channelName);
|
void setFile(QString fileURL, const QString &channelName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QNetworkAccessManager *manager;
|
QNetworkAccessManager *manager_;
|
||||||
QNetworkReply *reply;
|
QNetworkReply *reply_;
|
||||||
QFile *file;
|
QFile *file_;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDownloadProgress(qint64, qint64);
|
void onDownloadProgress(qint64, qint64);
|
||||||
|
@ -33,4 +31,5 @@ private slots:
|
||||||
signals:
|
signals:
|
||||||
void downloadComplete();
|
void downloadComplete();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
Loading…
Reference in a new issue