aboutsummaryrefslogtreecommitdiff
path: root/launcher/screenshots/ImgurAlbumCreation.cpp
diff options
context:
space:
mode:
authorflow <thiagodonato300@gmail.com>2022-04-21 22:12:14 -0300
committerflow <thiagodonato300@gmail.com>2022-05-12 18:11:49 -0300
commit8c8eabf7ac1920b47792b26790f3646cb6693ec0 (patch)
tree4cb5fca254ad911b52f7aaf4b5af6009ea6f6329 /launcher/screenshots/ImgurAlbumCreation.cpp
parent649b8ac7c6e12fcf91d204f908e027d3bfbb6a2a (diff)
downloadPrismLauncher-8c8eabf7ac1920b47792b26790f3646cb6693ec0.tar.gz
PrismLauncher-8c8eabf7ac1920b47792b26790f3646cb6693ec0.tar.bz2
PrismLauncher-8c8eabf7ac1920b47792b26790f3646cb6693ec0.zip
refactor: organize a little more the code in launcher/net/
This also reduces some code duplication by using some Task logic in NetAction.
Diffstat (limited to 'launcher/screenshots/ImgurAlbumCreation.cpp')
-rw-r--r--launcher/screenshots/ImgurAlbumCreation.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/launcher/screenshots/ImgurAlbumCreation.cpp b/launcher/screenshots/ImgurAlbumCreation.cpp
index d5de302a..81fac929 100644
--- a/launcher/screenshots/ImgurAlbumCreation.cpp
+++ b/launcher/screenshots/ImgurAlbumCreation.cpp
@@ -13,12 +13,12 @@
ImgurAlbumCreation::ImgurAlbumCreation(QList<ScreenShot::Ptr> screenshots) : NetAction(), m_screenshots(screenshots)
{
m_url = BuildConfig.IMGUR_BASE_URL + "album.json";
- m_status = Job_NotStarted;
+ m_state = State::Inactive;
}
-void ImgurAlbumCreation::startImpl()
+void ImgurAlbumCreation::executeTask()
{
- m_status = Job_InProgress;
+ m_state = State::Running;
QNetworkRequest request(m_url);
request.setHeader(QNetworkRequest::UserAgentHeader, BuildConfig.USER_AGENT_UNCACHED);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
@@ -43,11 +43,11 @@ void ImgurAlbumCreation::startImpl()
void ImgurAlbumCreation::downloadError(QNetworkReply::NetworkError error)
{
qDebug() << m_reply->errorString();
- m_status = Job_Failed;
+ m_state = State::Failed;
}
void ImgurAlbumCreation::downloadFinished()
{
- if (m_status != Job_Failed)
+ if (m_state != State::Failed)
{
QByteArray data = m_reply->readAll();
m_reply.reset();
@@ -68,7 +68,7 @@ void ImgurAlbumCreation::downloadFinished()
}
m_deleteHash = object.value("data").toObject().value("deletehash").toString();
m_id = object.value("data").toObject().value("id").toString();
- m_status = Job_Finished;
+ m_state = State::Succeeded;
emit succeeded(m_index_within_job);
return;
}
@@ -82,7 +82,6 @@ void ImgurAlbumCreation::downloadFinished()
}
void ImgurAlbumCreation::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
- m_total_progress = bytesTotal;
- m_progress = bytesReceived;
+ setProgress(bytesReceived, bytesTotal);
emit netActionProgress(m_index_within_job, bytesReceived, bytesTotal);
}