summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2014-02-24 11:30:27 +0100
committerJan Dalheimer <jan@dalheimer.de>2014-02-24 11:30:27 +0100
commitda33fa4090b4510267d06b3fd3ec439ff563b80e (patch)
tree31e167a82193b607c57c1c94b05ff22d14f4b44d /gui
parenta8811a27f78698f1ab2acad47e90f3b16274e221 (diff)
downloadMultiMC-da33fa4090b4510267d06b3fd3ec439ff563b80e.tar
MultiMC-da33fa4090b4510267d06b3fd3ec439ff563b80e.tar.gz
MultiMC-da33fa4090b4510267d06b3fd3ec439ff563b80e.tar.lz
MultiMC-da33fa4090b4510267d06b3fd3ec439ff563b80e.tar.xz
MultiMC-da33fa4090b4510267d06b3fd3ec439ff563b80e.zip
Imgur album creation
Diffstat (limited to 'gui')
-rw-r--r--gui/MainWindow.cpp9
-rw-r--r--gui/dialogs/CustomMessageBox.cpp1
-rw-r--r--gui/dialogs/ScreenshotDialog.cpp38
-rw-r--r--gui/dialogs/ScreenshotDialog.h5
4 files changed, 27 insertions, 26 deletions
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp
index 93608a0e..559c2f48 100644
--- a/gui/MainWindow.cpp
+++ b/gui/MainWindow.cpp
@@ -81,7 +81,6 @@
#include "logic/net/URLConstants.h"
#include "logic/net/NetJob.h"
-#include "logic/net/ScreenshotUploader.h"
#include "logic/BaseInstance.h"
#include "logic/InstanceFactory.h"
@@ -1519,13 +1518,7 @@ void MainWindow::on_actionScreenshots_triggered()
ScreenshotDialog dialog(list, this);
if (dialog.exec() == ScreenshotDialog::Accepted)
{
- QStringList urls;
- for (ScreenShot *shot : dialog.uploaded())
- {
- urls << QString("<a href=\"" + shot->url + "\">Image %1</a>")
- .arg(shot->timestamp.toString());
- }
- CustomMessageBox::selectable(this, tr("Done uploading!"), urls.join("\n"),
+ CustomMessageBox::selectable(this, tr("Done uploading!"), dialog.message(),
QMessageBox::Information)->exec();
}
}
diff --git a/gui/dialogs/CustomMessageBox.cpp b/gui/dialogs/CustomMessageBox.cpp
index 1d2ab58a..4013db60 100644
--- a/gui/dialogs/CustomMessageBox.cpp
+++ b/gui/dialogs/CustomMessageBox.cpp
@@ -28,6 +28,7 @@ QMessageBox *selectable(QWidget *parent, const QString &title, const QString &te
messageBox->setDefaultButton(defaultButton);
messageBox->setTextInteractionFlags(Qt::TextSelectableByMouse);
messageBox->setIcon(icon);
+ messageBox->setTextInteractionFlags(Qt::TextBrowserInteraction);
return messageBox;
}
diff --git a/gui/dialogs/ScreenshotDialog.cpp b/gui/dialogs/ScreenshotDialog.cpp
index 33e93162..3b4af5e5 100644
--- a/gui/dialogs/ScreenshotDialog.cpp
+++ b/gui/dialogs/ScreenshotDialog.cpp
@@ -7,12 +7,12 @@
#include "ProgressDialog.h"
#include "CustomMessageBox.h"
#include "logic/net/NetJob.h"
-#include "logic/net/ScreenshotUploader.h"
+#include "logic/net/ImgurUpload.h"
+#include "logic/net/ImgurAlbumCreation.h"
+#include "logic/tasks/SequentialTask.h"
-ScreenshotDialog::ScreenshotDialog(ScreenshotList *list, QWidget *parent) :
- QDialog(parent),
- ui(new Ui::ScreenshotDialog),
- m_list(list)
+ScreenshotDialog::ScreenshotDialog(ScreenshotList *list, QWidget *parent)
+ : QDialog(parent), ui(new Ui::ScreenshotDialog), m_list(list)
{
ui->setupUi(this);
ui->listView->setModel(m_list);
@@ -23,15 +23,17 @@ ScreenshotDialog::~ScreenshotDialog()
delete ui;
}
-QList<ScreenShot *> ScreenshotDialog::uploaded() const
+QString ScreenshotDialog::message() const
{
- return m_uploaded;
+ return tr("<a href=\"https://imgur.com/a/%1\">Visit album</a><br/>Delete hash: %2 (save "
+ "this if you want to be able to edit/delete the album)")
+ .arg(m_imgurAlbum->id(), m_imgurAlbum->deleteHash());
}
-QList<ScreenShot*> ScreenshotDialog::selected() const
+QList<ScreenShot *> ScreenshotDialog::selected() const
{
- QList<ScreenShot*> list;
- QList<ScreenShot*> first = m_list->screenshots();
+ QList<ScreenShot *> list;
+ QList<ScreenShot *> first = m_list->screenshots();
for (QModelIndex index : ui->listView->selectionModel()->selectedRows())
{
list.append(first.at(index.row()));
@@ -41,20 +43,24 @@ QList<ScreenShot*> ScreenshotDialog::selected() const
void ScreenshotDialog::on_uploadBtn_clicked()
{
- QList<ScreenShot *> screenshots = selected();
- if (screenshots.isEmpty())
+ m_uploaded = selected();
+ if (m_uploaded.isEmpty())
{
done(NothingDone);
return;
}
+ SequentialTask *task = new SequentialTask(this);
NetJob *job = new NetJob("Screenshot Upload");
- for (ScreenShot *shot : screenshots)
+ for (ScreenShot *shot : m_uploaded)
{
- job->addNetAction(ScreenShotUpload::make(shot));
+ job->addNetAction(ImgurUpload::make(shot));
}
- m_uploaded = screenshots;
+ 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));
ProgressDialog prog(this);
- if (prog.exec(job) == QDialog::Accepted)
+ if (prog.exec(task) == QDialog::Accepted)
{
accept();
}
diff --git a/gui/dialogs/ScreenshotDialog.h b/gui/dialogs/ScreenshotDialog.h
index 104814f1..ac1494d6 100644
--- a/gui/dialogs/ScreenshotDialog.h
+++ b/gui/dialogs/ScreenshotDialog.h
@@ -3,7 +3,7 @@
#include <QDialog>
#include "logic/lists/ScreenshotList.h"
-class BaseInstance;
+class ImgurAlbumCreation;
namespace Ui
{
@@ -23,7 +23,7 @@ public:
NothingDone = 0x42
};
- QList<ScreenShot *> uploaded() const;
+ QString message() const;
private
slots:
@@ -33,6 +33,7 @@ private:
Ui::ScreenshotDialog *ui;
ScreenshotList *m_list;
QList<ScreenShot *> m_uploaded;
+ std::shared_ptr<ImgurAlbumCreation> m_imgurAlbum;
QList<ScreenShot *> selected() const;
};