summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-02-25 00:51:24 +0100
committerPetr Mrázek <peterix@gmail.com>2014-02-25 00:51:24 +0100
commitcb5cfe724208beb7d506868fc4e50d9f13e28a53 (patch)
tree527bfd30ef74d5edef055ae6b4258dd2526162d8
parentb1cddb4600db2aa54c9d274466b393fc1e03eba9 (diff)
downloadMultiMC-cb5cfe724208beb7d506868fc4e50d9f13e28a53.tar
MultiMC-cb5cfe724208beb7d506868fc4e50d9f13e28a53.tar.gz
MultiMC-cb5cfe724208beb7d506868fc4e50d9f13e28a53.tar.lz
MultiMC-cb5cfe724208beb7d506868fc4e50d9f13e28a53.tar.xz
MultiMC-cb5cfe724208beb7d506868fc4e50d9f13e28a53.zip
Reorganize all the screenshot files
-rw-r--r--CMakeLists.txt15
-rw-r--r--gui/dialogs/ScreenshotDialog.cpp16
-rw-r--r--gui/dialogs/ScreenshotDialog.h6
-rw-r--r--logic/screenshots/ImgurAlbumCreation.cpp (renamed from logic/net/ImgurAlbumCreation.cpp)6
-rw-r--r--logic/screenshots/ImgurAlbumCreation.h (renamed from logic/net/ImgurAlbumCreation.h)10
-rw-r--r--logic/screenshots/ImgurUpload.cpp (renamed from logic/net/ImgurUpload.cpp)6
-rw-r--r--logic/screenshots/ImgurUpload.h (renamed from logic/net/ImgurUpload.h)10
-rw-r--r--logic/screenshots/Screenshot.h15
-rw-r--r--logic/screenshots/ScreenshotList.cpp (renamed from logic/lists/ScreenshotList.cpp)6
-rw-r--r--logic/screenshots/ScreenshotList.h (renamed from logic/lists/ScreenshotList.h)19
10 files changed, 60 insertions, 49 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 12a673e3..da7b0e0b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -372,10 +372,6 @@ logic/net/HttpMetaCache.cpp
logic/net/PasteUpload.h
logic/net/PasteUpload.cpp
logic/net/URLConstants.h
-logic/net/ImgurUpload.h
-logic/net/ImgurUpload.cpp
-logic/net/ImgurAlbumCreation.h
-logic/net/ImgurAlbumCreation.cpp
# Yggdrasil login stuff
logic/auth/AuthSession.h
@@ -466,8 +462,15 @@ logic/lists/ForgeVersionList.h
logic/lists/ForgeVersionList.cpp
logic/lists/JavaVersionList.h
logic/lists/JavaVersionList.cpp
-logic/lists/ScreenshotList.h
-logic/lists/ScreenshotList.cpp
+
+# the screenshots feature
+logic/screenshots/Screenshot.h
+logic/screenshots/ScreenshotList.h
+logic/screenshots/ScreenshotList.cpp
+logic/screenshots/ImgurUpload.h
+logic/screenshots/ImgurUpload.cpp
+logic/screenshots/ImgurAlbumCreation.h
+logic/screenshots/ImgurAlbumCreation.cpp
# Icons
logic/icons/MMCIcon.h
diff --git a/gui/dialogs/ScreenshotDialog.cpp b/gui/dialogs/ScreenshotDialog.cpp
index 76f87283..a88c8dfd 100644
--- a/gui/dialogs/ScreenshotDialog.cpp
+++ b/gui/dialogs/ScreenshotDialog.cpp
@@ -7,8 +7,8 @@
#include "ProgressDialog.h"
#include "CustomMessageBox.h"
#include "logic/net/NetJob.h"
-#include "logic/net/ImgurUpload.h"
-#include "logic/net/ImgurAlbumCreation.h"
+#include "logic/screenshots/ImgurUpload.h"
+#include "logic/screenshots/ImgurAlbumCreation.h"
#include "logic/tasks/SequentialTask.h"
ScreenshotDialog::ScreenshotDialog(ScreenshotList *list, QWidget *parent)
@@ -30,10 +30,10 @@ QString ScreenshotDialog::message() const
.arg(m_imgurAlbum->id(), m_imgurAlbum->deleteHash());
}
-QList<ScreenShot *> ScreenshotDialog::selected() const
+QList<ScreenshotPtr> ScreenshotDialog::selected() const
{
- QList<std::shared_ptr<ScreenShot>> list;
- QList<std::shared_ptr<ScreenShot>> first = m_list->screenshots();
+ QList<ScreenshotPtr> list;
+ QList<ScreenshotPtr> first = m_list->screenshots();
for (QModelIndex index : ui->listView->selectionModel()->selectedRows())
{
list.append(first.at(index.row()));
@@ -51,14 +51,14 @@ void ScreenshotDialog::on_uploadBtn_clicked()
}
SequentialTask *task = new SequentialTask(this);
NetJob *job = new NetJob("Screenshot Upload");
- for (std::shared_ptr<ScreenShot> shot : m_uploaded)
+ for (auto shot : m_uploaded)
{
job->addNetAction(ImgurUpload::make(shot));
}
NetJob *albumTask = new NetJob("Imgur Album Creation");
albumTask->addNetAction(m_imgurAlbum = ImgurAlbumCreation::make(m_uploaded));
- task->addTask(std::shared_ptr<NetJob>(job));
- task->addTask(std::shared_ptr<NetJob>(albumTask));
+ task->addTask(NetJobPtr(job));
+ task->addTask(NetJobPtr(albumTask));
ProgressDialog prog(this);
if (prog.exec(task) == QDialog::Accepted)
{
diff --git a/gui/dialogs/ScreenshotDialog.h b/gui/dialogs/ScreenshotDialog.h
index ac95b4f0..29dd6765 100644
--- a/gui/dialogs/ScreenshotDialog.h
+++ b/gui/dialogs/ScreenshotDialog.h
@@ -1,7 +1,7 @@
#pragma once
#include <QDialog>
-#include "logic/lists/ScreenshotList.h"
+#include "logic/screenshots/ScreenshotList.h"
class ImgurAlbumCreation;
@@ -24,7 +24,7 @@ public:
};
QString message() const;
- QList<std::shared_ptr<ScreenShot>> selected() const;
+ QList<ScreenshotPtr> selected() const;
private
slots:
@@ -35,6 +35,6 @@ slots:
private:
Ui::ScreenshotDialog *ui;
ScreenshotList *m_list;
- QList<std::shared_ptr<ScreenShot>> m_uploaded;
+ QList<ScreenshotPtr> m_uploaded;
std::shared_ptr<ImgurAlbumCreation> m_imgurAlbum;
};
diff --git a/logic/net/ImgurAlbumCreation.cpp b/logic/screenshots/ImgurAlbumCreation.cpp
index 0d8c4dc1..e473952e 100644
--- a/logic/net/ImgurAlbumCreation.cpp
+++ b/logic/screenshots/ImgurAlbumCreation.cpp
@@ -5,12 +5,12 @@
#include <QJsonObject>
#include <QUrl>
-#include "logic/lists/ScreenshotList.h"
-#include "URLConstants.h"
+#include "logic/screenshots//ScreenshotList.h"
+#include "logic/net/URLConstants.h"
#include "MultiMC.h"
#include "logger/QsLog.h"
-ImgurAlbumCreation::ImgurAlbumCreation(QList<ScreenShot *> screenshots) : NetAction(), m_screenshots(screenshots)
+ImgurAlbumCreation::ImgurAlbumCreation(QList<ScreenshotPtr> screenshots) : NetAction(), m_screenshots(screenshots)
{
m_url = URLConstants::IMGUR_BASE_URL + "album.json";
m_status = Job_NotStarted;
diff --git a/logic/net/ImgurAlbumCreation.h b/logic/screenshots/ImgurAlbumCreation.h
index 7be255df..6e8fbe94 100644
--- a/logic/net/ImgurAlbumCreation.h
+++ b/logic/screenshots/ImgurAlbumCreation.h
@@ -1,13 +1,13 @@
#pragma once
-#include "NetAction.h"
+#include "logic/net/NetAction.h"
+#include "Screenshot.h"
-class ScreenShot;
typedef std::shared_ptr<class ImgurAlbumCreation> ImgurAlbumCreationPtr;
class ImgurAlbumCreation : public NetAction
{
public:
- explicit ImgurAlbumCreation(QList<ScreenShot *> screenshots);
- static ImgurAlbumCreationPtr make(QList<ScreenShot *> screenshots)
+ explicit ImgurAlbumCreation(QList<ScreenshotPtr> screenshots);
+ static ImgurAlbumCreationPtr make(QList<ScreenshotPtr> screenshots)
{
return ImgurAlbumCreationPtr(new ImgurAlbumCreation(screenshots));
}
@@ -35,7 +35,7 @@ slots:
virtual void start();
private:
- QList<ScreenShot *> m_screenshots;
+ QList<ScreenshotPtr> m_screenshots;
QString m_deleteHash;
QString m_id;
diff --git a/logic/net/ImgurUpload.cpp b/logic/screenshots/ImgurUpload.cpp
index 4992ee65..62033ef5 100644
--- a/logic/net/ImgurUpload.cpp
+++ b/logic/screenshots/ImgurUpload.cpp
@@ -8,12 +8,12 @@
#include <QFile>
#include <QUrl>
-#include "logic/lists/ScreenshotList.h"
-#include "URLConstants.h"
+#include "logic/screenshots/ScreenshotList.h"
+#include "logic/net/URLConstants.h"
#include "MultiMC.h"
#include "logger/QsLog.h"
-ImgurUpload::ImgurUpload(ScreenShot *shot) : NetAction(), m_shot(shot)
+ImgurUpload::ImgurUpload(ScreenshotPtr shot) : NetAction(), m_shot(shot)
{
m_url = URLConstants::IMGUR_BASE_URL + "upload.json";
m_status = Job_NotStarted;
diff --git a/logic/net/ImgurUpload.h b/logic/screenshots/ImgurUpload.h
index e5e79587..1111a8d0 100644
--- a/logic/net/ImgurUpload.h
+++ b/logic/screenshots/ImgurUpload.h
@@ -1,13 +1,13 @@
#pragma once
-#include "NetAction.h"
+#include "logic/net/NetAction.h"
+#include "Screenshot.h"
-class ScreenShot;
typedef std::shared_ptr<class ImgurUpload> ImgurUploadPtr;
class ImgurUpload : public NetAction
{
public:
- explicit ImgurUpload(ScreenShot *shot);
- static ImgurUploadPtr make(ScreenShot *shot)
+ explicit ImgurUpload(ScreenshotPtr shot);
+ static ImgurUploadPtr make(ScreenshotPtr shot)
{
return ImgurUploadPtr(new ImgurUpload(shot));
}
@@ -26,5 +26,5 @@ slots:
virtual void start();
private:
- ScreenShot *m_shot;
+ ScreenshotPtr m_shot;
};
diff --git a/logic/screenshots/Screenshot.h b/logic/screenshots/Screenshot.h
new file mode 100644
index 00000000..194e70e5
--- /dev/null
+++ b/logic/screenshots/Screenshot.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#include <QDateTime>
+#include <QString>
+#include <memory>
+
+struct ScreenShot
+{
+ QDateTime timestamp;
+ QString file;
+ QString url;
+ QString imgurId;
+};
+
+typedef std::shared_ptr<ScreenShot> ScreenshotPtr;
diff --git a/logic/lists/ScreenshotList.cpp b/logic/screenshots/ScreenshotList.cpp
index eda57a03..def1bdf7 100644
--- a/logic/lists/ScreenshotList.cpp
+++ b/logic/screenshots/ScreenshotList.cpp
@@ -69,13 +69,13 @@ void ScreenshotLoadTask::executeTask()
return;
}
dir.setNameFilters(QStringList() << "*.png");
- this->m_results = QList<ScreenShot *>();
+ this->m_results.clear();
for (auto file : dir.entryList())
{
ScreenShot *shot = new ScreenShot();
shot->timestamp = QDateTime::fromString(file, "yyyy-MM-dd_HH.mm.ss.png");
shot->file = dir.absoluteFilePath(file);
- m_results.append(shot);
+ m_results.append(ScreenshotPtr(shot));
}
m_list->loadShots(m_results);
emitSucceeded();
@@ -91,7 +91,7 @@ void ScreenshotList::deleteSelected(ScreenshotDialog *dialog)
QList<std::shared_ptr<ScreenShot>>::const_iterator it;
for (it = screens.cbegin(); it != screens.cend(); it++)
{
- std::shared_ptr<ScreenShot> = *it;
+ auto shot = *it;
if (!QFile(shot->file).remove())
{
CustomMessageBox::selectable(dialog, tr("Error!"),
diff --git a/logic/lists/ScreenshotList.h b/logic/screenshots/ScreenshotList.h
index 8e512ace..ca6314e9 100644
--- a/logic/lists/ScreenshotList.h
+++ b/logic/screenshots/ScreenshotList.h
@@ -4,14 +4,7 @@
#include "logic/BaseInstance.h"
#include "logic/tasks/Task.h"
-class ScreenShot
-{
-public:
- QDateTime timestamp;
- QString file;
- QString url;
- QString imgurId;
-};
+#include "Screenshot.h"
class ScreenshotList : public QAbstractListModel
{
@@ -28,12 +21,12 @@ public:
Task *load();
- void loadShots(QList<ScreenShot *> shots)
+ void loadShots(QList<ScreenshotPtr> shots)
{
m_screenshots = shots;
}
- QList<ScreenShot *> screenshots() const
+ QList<ScreenshotPtr> screenshots() const
{
return m_screenshots;
}
@@ -51,7 +44,7 @@ public
slots:
private:
- QList<ScreenShot *> m_screenshots;
+ QList<ScreenshotPtr> m_screenshots;
BaseInstance *m_instance;
};
@@ -63,7 +56,7 @@ public:
explicit ScreenshotLoadTask(ScreenshotList *list);
~ScreenshotLoadTask();
- QList<ScreenShot *> screenShots() const
+ QList<ScreenshotPtr> screenShots() const
{
return m_results;
}
@@ -73,5 +66,5 @@ protected:
private:
ScreenshotList *m_list;
- QList<ScreenShot *> m_results;
+ QList<ScreenshotPtr> m_results;
};