Imgur album creation
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
Reference in New Issue
Block a user