diff options
author | Jan Dalheimer <jan@dalheimer.de> | 2014-02-24 11:30:27 +0100 |
---|---|---|
committer | Jan Dalheimer <jan@dalheimer.de> | 2014-02-24 11:30:27 +0100 |
commit | da33fa4090b4510267d06b3fd3ec439ff563b80e (patch) | |
tree | 31e167a82193b607c57c1c94b05ff22d14f4b44d /gui/dialogs | |
parent | a8811a27f78698f1ab2acad47e90f3b16274e221 (diff) | |
download | MultiMC-da33fa4090b4510267d06b3fd3ec439ff563b80e.tar MultiMC-da33fa4090b4510267d06b3fd3ec439ff563b80e.tar.gz MultiMC-da33fa4090b4510267d06b3fd3ec439ff563b80e.tar.lz MultiMC-da33fa4090b4510267d06b3fd3ec439ff563b80e.tar.xz MultiMC-da33fa4090b4510267d06b3fd3ec439ff563b80e.zip |
Imgur album creation
Diffstat (limited to 'gui/dialogs')
-rw-r--r-- | gui/dialogs/CustomMessageBox.cpp | 1 | ||||
-rw-r--r-- | gui/dialogs/ScreenshotDialog.cpp | 38 | ||||
-rw-r--r-- | gui/dialogs/ScreenshotDialog.h | 5 |
3 files changed, 26 insertions, 18 deletions
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; }; |