Screenshot fixes, move some code around, fix some stuff
This commit is contained in:
@ -1,6 +1,13 @@
|
||||
#include "ScreenshotDialog.h"
|
||||
#include "ui_ScreenshotDialog.h"
|
||||
#include "QModelIndex"
|
||||
|
||||
#include <QModelIndex>
|
||||
#include <QDebug>
|
||||
|
||||
#include "ProgressDialog.h"
|
||||
#include "CustomMessageBox.h"
|
||||
#include "logic/net/NetJob.h"
|
||||
#include "logic/net/ScreenshotUploader.h"
|
||||
|
||||
ScreenshotDialog::ScreenshotDialog(ScreenshotList *list, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
@ -16,7 +23,12 @@ ScreenshotDialog::~ScreenshotDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QList<ScreenShot*> ScreenshotDialog::selected()
|
||||
QList<ScreenShot *> ScreenshotDialog::uploaded() const
|
||||
{
|
||||
return m_uploaded;
|
||||
}
|
||||
|
||||
QList<ScreenShot*> ScreenshotDialog::selected() const
|
||||
{
|
||||
QList<ScreenShot*> list;
|
||||
QList<ScreenShot*> first = m_list->screenshots();
|
||||
@ -26,3 +38,29 @@ QList<ScreenShot*> ScreenshotDialog::selected()
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
void ScreenshotDialog::on_buttonBox_accepted()
|
||||
{
|
||||
QList<ScreenShot *> screenshots = selected();
|
||||
if (screenshots.isEmpty())
|
||||
{
|
||||
done(NothingDone);
|
||||
return;
|
||||
}
|
||||
NetJob *job = new NetJob("Screenshot Upload");
|
||||
for (ScreenShot *shot : screenshots)
|
||||
{
|
||||
qDebug() << shot->file;
|
||||
job->addNetAction(ScreenShotUpload::make(shot));
|
||||
}
|
||||
ProgressDialog prog(this);
|
||||
prog.exec(job);
|
||||
connect(job, &NetJob::failed, [this]
|
||||
{
|
||||
CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"),
|
||||
tr("Unknown error"), QMessageBox::Warning)->exec();
|
||||
reject();
|
||||
});
|
||||
m_uploaded = screenshots;
|
||||
connect(job, &NetJob::succeeded, this, &ScreenshotDialog::accept);
|
||||
}
|
||||
|
@ -18,12 +18,21 @@ public:
|
||||
explicit ScreenshotDialog(ScreenshotList *list, QWidget *parent = 0);
|
||||
~ScreenshotDialog();
|
||||
|
||||
QList<ScreenShot *> selected();
|
||||
enum
|
||||
{
|
||||
NothingDone = 0x42
|
||||
};
|
||||
|
||||
QList<ScreenShot *> uploaded() const;
|
||||
|
||||
private
|
||||
slots:
|
||||
void on_buttonBox_accepted();
|
||||
|
||||
private:
|
||||
Ui::ScreenshotDialog *ui;
|
||||
ScreenshotList *m_list;
|
||||
QList<ScreenShot *> m_uploaded;
|
||||
|
||||
QList<ScreenShot *> selected() const;
|
||||
};
|
||||
|
@ -66,22 +66,6 @@
|
||||
<include location="../../resources/multimc/multimc.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ScreenshotDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
|
Reference in New Issue
Block a user