aboutsummaryrefslogtreecommitdiff
path: root/launcher/screenshots
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2021-11-21 23:21:12 +0100
committerPetr Mrázek <peterix@gmail.com>2021-11-21 23:21:12 +0100
commit69213b1206e97f7d4db4270a4b3b0af41dc9e6fc (patch)
treeb53ca69422ce22cceee9e648171a678679075c1a /launcher/screenshots
parentc2c56a2f6ceaedb8a3fa88c848b345db0fec7f9c (diff)
downloadPrismLauncher-69213b1206e97f7d4db4270a4b3b0af41dc9e6fc.tar.gz
PrismLauncher-69213b1206e97f7d4db4270a4b3b0af41dc9e6fc.tar.bz2
PrismLauncher-69213b1206e97f7d4db4270a4b3b0af41dc9e6fc.zip
NOISSUE continue refactoring things to make tests pass
Diffstat (limited to 'launcher/screenshots')
-rw-r--r--launcher/screenshots/ImgurAlbumCreation.cpp10
-rw-r--r--launcher/screenshots/ImgurAlbumCreation.h11
-rw-r--r--launcher/screenshots/ImgurUpload.cpp10
-rw-r--r--launcher/screenshots/ImgurUpload.h22
-rw-r--r--launcher/screenshots/Screenshot.h10
5 files changed, 29 insertions, 34 deletions
diff --git a/launcher/screenshots/ImgurAlbumCreation.cpp b/launcher/screenshots/ImgurAlbumCreation.cpp
index d1b21f5f..d5de302a 100644
--- a/launcher/screenshots/ImgurAlbumCreation.cpp
+++ b/launcher/screenshots/ImgurAlbumCreation.cpp
@@ -5,18 +5,18 @@
#include <QJsonObject>
#include <QUrl>
#include <QStringList>
+#include <QDebug>
#include "BuildConfig.h"
-#include "Env.h"
-#include <QDebug>
+#include "Application.h"
-ImgurAlbumCreation::ImgurAlbumCreation(QList<ScreenshotPtr> screenshots) : NetAction(), m_screenshots(screenshots)
+ImgurAlbumCreation::ImgurAlbumCreation(QList<ScreenShot::Ptr> screenshots) : NetAction(), m_screenshots(screenshots)
{
m_url = BuildConfig.IMGUR_BASE_URL + "album.json";
m_status = Job_NotStarted;
}
-void ImgurAlbumCreation::start()
+void ImgurAlbumCreation::startImpl()
{
m_status = Job_InProgress;
QNetworkRequest request(m_url);
@@ -33,7 +33,7 @@ void ImgurAlbumCreation::start()
const QByteArray data = "deletehashes=" + hashes.join(',').toUtf8() + "&title=Minecraft%20Screenshots&privacy=hidden";
- QNetworkReply *rep = ENV->network().post(request, data);
+ QNetworkReply *rep = APPLICATION->network()->post(request, data);
m_reply.reset(rep);
connect(rep, &QNetworkReply::uploadProgress, this, &ImgurAlbumCreation::downloadProgress);
diff --git a/launcher/screenshots/ImgurAlbumCreation.h b/launcher/screenshots/ImgurAlbumCreation.h
index 954637e6..cb048a23 100644
--- a/launcher/screenshots/ImgurAlbumCreation.h
+++ b/launcher/screenshots/ImgurAlbumCreation.h
@@ -1,13 +1,14 @@
#pragma once
#include "net/NetAction.h"
#include "Screenshot.h"
+#include "QObjectPtr.h"
-typedef std::shared_ptr<class ImgurAlbumCreation> ImgurAlbumCreationPtr;
+typedef shared_qobject_ptr<class ImgurAlbumCreation> ImgurAlbumCreationPtr;
class ImgurAlbumCreation : public NetAction
{
public:
- explicit ImgurAlbumCreation(QList<ScreenshotPtr> screenshots);
- static ImgurAlbumCreationPtr make(QList<ScreenshotPtr> screenshots)
+ explicit ImgurAlbumCreation(QList<ScreenShot::Ptr> screenshots);
+ static ImgurAlbumCreationPtr make(QList<ScreenShot::Ptr> screenshots)
{
return ImgurAlbumCreationPtr(new ImgurAlbumCreation(screenshots));
}
@@ -32,10 +33,10 @@ slots:
public
slots:
- virtual void start();
+ virtual void startImpl();
private:
- QList<ScreenshotPtr> m_screenshots;
+ QList<ScreenShot::Ptr> m_screenshots;
QString m_deleteHash;
QString m_id;
diff --git a/launcher/screenshots/ImgurUpload.cpp b/launcher/screenshots/ImgurUpload.cpp
index dfdbf2e8..76a84947 100644
--- a/launcher/screenshots/ImgurUpload.cpp
+++ b/launcher/screenshots/ImgurUpload.cpp
@@ -1,4 +1,5 @@
#include "ImgurUpload.h"
+#include "BuildConfig.h"
#include <QNetworkRequest>
#include <QHttpMultiPart>
@@ -7,18 +8,15 @@
#include <QHttpPart>
#include <QFile>
#include <QUrl>
-
-#include "BuildConfig.h"
-#include "Env.h"
#include <QDebug>
-ImgurUpload::ImgurUpload(ScreenshotPtr shot) : NetAction(), m_shot(shot)
+ImgurUpload::ImgurUpload(ScreenShot::Ptr shot) : NetAction(), m_shot(shot)
{
m_url = BuildConfig.IMGUR_BASE_URL + "upload.json";
m_status = Job_NotStarted;
}
-void ImgurUpload::start()
+void ImgurUpload::startImpl()
{
finished = false;
m_status = Job_InProgress;
@@ -49,7 +47,7 @@ void ImgurUpload::start()
namePart.setBody(m_shot->m_file.baseName().toUtf8());
multipart->append(namePart);
- QNetworkReply *rep = ENV->network().post(request, multipart);
+ QNetworkReply *rep = m_network->post(request, multipart);
m_reply.reset(rep);
connect(rep, &QNetworkReply::uploadProgress, this, &ImgurUpload::downloadProgress);
diff --git a/launcher/screenshots/ImgurUpload.h b/launcher/screenshots/ImgurUpload.h
index 0507d499..ac57d1ba 100644
--- a/launcher/screenshots/ImgurUpload.h
+++ b/launcher/screenshots/ImgurUpload.h
@@ -1,15 +1,15 @@
#pragma once
+#include "QObjectPtr.h"
#include "net/NetAction.h"
#include "Screenshot.h"
-typedef std::shared_ptr<class ImgurUpload> ImgurUploadPtr;
-class ImgurUpload : public NetAction
-{
+class ImgurUpload : public NetAction {
public:
- explicit ImgurUpload(ScreenshotPtr shot);
- static ImgurUploadPtr make(ScreenshotPtr shot)
- {
- return ImgurUploadPtr(new ImgurUpload(shot));
+ using Ptr = shared_qobject_ptr<ImgurUpload>;
+
+ explicit ImgurUpload(ScreenShot::Ptr shot);
+ static Ptr make(ScreenShot::Ptr shot) {
+ return Ptr(new ImgurUpload(shot));
}
protected
@@ -17,15 +17,13 @@ slots:
virtual void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
virtual void downloadError(QNetworkReply::NetworkError error);
virtual void downloadFinished();
- virtual void downloadReadyRead()
- {
- }
+ virtual void downloadReadyRead() {}
public
slots:
- virtual void start();
+ void startImpl() override;
private:
- ScreenshotPtr m_shot;
+ ScreenShot::Ptr m_shot;
bool finished = true;
};
diff --git a/launcher/screenshots/Screenshot.h b/launcher/screenshots/Screenshot.h
index 9db3a8a1..ca45aabf 100644
--- a/launcher/screenshots/Screenshot.h
+++ b/launcher/screenshots/Screenshot.h
@@ -5,10 +5,10 @@
#include <QFileInfo>
#include <memory>
-struct ScreenShot
-{
- ScreenShot(QFileInfo file)
- {
+struct ScreenShot {
+ using Ptr = std::shared_ptr<ScreenShot>;
+
+ ScreenShot(QFileInfo file) {
m_file = file;
}
QFileInfo m_file;
@@ -16,5 +16,3 @@ struct ScreenShot
QString m_imgurId;
QString m_imgurDeleteHash;
};
-
-typedef std::shared_ptr<ScreenShot> ScreenshotPtr;