diff --git a/gui/ConsoleWindow.ui b/gui/ConsoleWindow.ui
index e50fb520..344cf74d 100644
--- a/gui/ConsoleWindow.ui
+++ b/gui/ConsoleWindow.ui
@@ -52,7 +52,7 @@
-
- Upload Screenshots
+ Manage Screenshots
diff --git a/gui/MainWindow.ui b/gui/MainWindow.ui
index 67625ac8..2bd8ec22 100644
--- a/gui/MainWindow.ui
+++ b/gui/MainWindow.ui
@@ -532,7 +532,7 @@
- Upload Screenshots
+ Manage Screenshots
<html><head/><body><p>View and upload screenshots for this instance</p></body></html>
diff --git a/gui/dialogs/ScreenshotDialog.cpp b/gui/dialogs/ScreenshotDialog.cpp
index 3b4af5e5..c62e1d52 100644
--- a/gui/dialogs/ScreenshotDialog.cpp
+++ b/gui/dialogs/ScreenshotDialog.cpp
@@ -2,7 +2,7 @@
#include "ui_ScreenshotDialog.h"
#include
-#include
+#include
#include "ProgressDialog.h"
#include "CustomMessageBox.h"
@@ -71,3 +71,8 @@ void ScreenshotDialog::on_uploadBtn_clicked()
reject();
}
}
+
+void ScreenshotDialog::on_deleteBtn_clicked()
+{
+ m_list->deleteSelected(this);
+}
diff --git a/gui/dialogs/ScreenshotDialog.h b/gui/dialogs/ScreenshotDialog.h
index ac1494d6..a406d1fe 100644
--- a/gui/dialogs/ScreenshotDialog.h
+++ b/gui/dialogs/ScreenshotDialog.h
@@ -24,16 +24,17 @@ public:
};
QString message() const;
+ QList selected() const;
private
slots:
void on_uploadBtn_clicked();
+ void on_deleteBtn_clicked();
+
private:
Ui::ScreenshotDialog *ui;
ScreenshotList *m_list;
QList m_uploaded;
std::shared_ptr m_imgurAlbum;
-
- QList selected() const;
};
diff --git a/gui/dialogs/ScreenshotDialog.ui b/gui/dialogs/ScreenshotDialog.ui
index 9e4bd6f0..4e42a548 100644
--- a/gui/dialogs/ScreenshotDialog.ui
+++ b/gui/dialogs/ScreenshotDialog.ui
@@ -11,7 +11,7 @@
- Screenshots
+ Screenshot Manager
@@ -72,6 +72,13 @@
+ -
+
+
+ Delete
+
+
+
diff --git a/logic/lists/ScreenshotList.cpp b/logic/lists/ScreenshotList.cpp
index 6969549c..9f4ce6b5 100644
--- a/logic/lists/ScreenshotList.cpp
+++ b/logic/lists/ScreenshotList.cpp
@@ -1,7 +1,11 @@
#include "ScreenshotList.h"
+#include "gui/dialogs/ScreenshotDialog.h"
#include
#include
+#include
+#include "gui/dialogs/ProgressDialog.h"
+#include "gui/dialogs/CustomMessageBox.h"
ScreenshotList::ScreenshotList(BaseInstance *instance, QObject *parent)
: QAbstractListModel(parent), m_instance(instance)
@@ -15,7 +19,7 @@ int ScreenshotList::rowCount(const QModelIndex &) const
QVariant ScreenshotList::data(const QModelIndex &index, int role) const
{
- if (!index.isValid())
+ if (index.row() >= m_screenshots.size() || index.row() < 0)
return QVariant();
switch (role)
@@ -76,3 +80,33 @@ void ScreenshotLoadTask::executeTask()
m_list->loadShots(m_results);
emitSucceeded();
}
+void ScreenshotList::deleteSelected(ScreenshotDialog *dialog)
+{
+ auto screens = dialog->selected();
+ if (screens.isEmpty())
+ {
+ return;
+ }
+ beginResetModel();
+ QList::const_iterator it;
+ for (it = screens.cbegin(); it != screens.cend(); it++)
+ {
+ ScreenShot *shot = *it;
+ if (!QFile(shot->file).remove())
+ {
+ CustomMessageBox::selectable(dialog, tr("Error!"),
+ tr("Failed to delete screenshots!"),
+ QMessageBox::Warning)->exec();
+ break;
+ }
+ }
+ ProgressDialog refresh(dialog);
+ Task *t = load();
+ if (refresh.exec(t) != QDialog::Accepted)
+ {
+ CustomMessageBox::selectable(dialog, tr("Error!"),
+ tr("Unable to refresh list: %1").arg(t->failReason()),
+ QMessageBox::Warning)->exec();
+ }
+ endResetModel();
+}
diff --git a/logic/lists/ScreenshotList.h b/logic/lists/ScreenshotList.h
index 1d3e73ca..8e512ace 100644
--- a/logic/lists/ScreenshotList.h
+++ b/logic/lists/ScreenshotList.h
@@ -43,6 +43,8 @@ public:
return m_instance;
}
+ void deleteSelected(class ScreenshotDialog *dialog);
+
signals:
public