diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-06-28 17:07:08 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-06-28 17:07:08 +0200 |
commit | e8731c5d013e67ee0153d5a49b38b0e914d14aa0 (patch) | |
tree | ab3611681ec35ea8f10aa7b9a7770c1356b3ef22 /gui/dialogs | |
parent | 30b1f5e5cf935689fc628e37016e650655153d00 (diff) | |
download | MultiMC-e8731c5d013e67ee0153d5a49b38b0e914d14aa0.tar MultiMC-e8731c5d013e67ee0153d5a49b38b0e914d14aa0.tar.gz MultiMC-e8731c5d013e67ee0153d5a49b38b0e914d14aa0.tar.lz MultiMC-e8731c5d013e67ee0153d5a49b38b0e914d14aa0.tar.xz MultiMC-e8731c5d013e67ee0153d5a49b38b0e914d14aa0.zip |
Turn screenshot management into a page.
Diffstat (limited to 'gui/dialogs')
-rw-r--r-- | gui/dialogs/ScreenshotDialog.cpp | 78 | ||||
-rw-r--r-- | gui/dialogs/ScreenshotDialog.h | 40 | ||||
-rw-r--r-- | gui/dialogs/ScreenshotDialog.ui | 110 |
3 files changed, 0 insertions, 228 deletions
diff --git a/gui/dialogs/ScreenshotDialog.cpp b/gui/dialogs/ScreenshotDialog.cpp deleted file mode 100644 index a88c8dfd..00000000 --- a/gui/dialogs/ScreenshotDialog.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "ScreenshotDialog.h" -#include "ui_ScreenshotDialog.h" - -#include <QModelIndex> -#include <QMutableListIterator> - -#include "ProgressDialog.h" -#include "CustomMessageBox.h" -#include "logic/net/NetJob.h" -#include "logic/screenshots/ImgurUpload.h" -#include "logic/screenshots/ImgurAlbumCreation.h" -#include "logic/tasks/SequentialTask.h" - -ScreenshotDialog::ScreenshotDialog(ScreenshotList *list, QWidget *parent) - : QDialog(parent), ui(new Ui::ScreenshotDialog), m_list(list) -{ - ui->setupUi(this); - ui->listView->setModel(m_list); -} - -ScreenshotDialog::~ScreenshotDialog() -{ - delete ui; -} - -QString ScreenshotDialog::message() const -{ - 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<ScreenshotPtr> ScreenshotDialog::selected() const -{ - QList<ScreenshotPtr> list; - QList<ScreenshotPtr> first = m_list->screenshots(); - for (QModelIndex index : ui->listView->selectionModel()->selectedRows()) - { - list.append(first.at(index.row())); - } - return list; -} - -void ScreenshotDialog::on_uploadBtn_clicked() -{ - m_uploaded = selected(); - if (m_uploaded.isEmpty()) - { - done(NothingDone); - return; - } - SequentialTask *task = new SequentialTask(this); - NetJob *job = new NetJob("Screenshot Upload"); - for (auto shot : m_uploaded) - { - job->addNetAction(ImgurUpload::make(shot)); - } - NetJob *albumTask = new NetJob("Imgur Album Creation"); - albumTask->addNetAction(m_imgurAlbum = ImgurAlbumCreation::make(m_uploaded)); - task->addTask(NetJobPtr(job)); - task->addTask(NetJobPtr(albumTask)); - ProgressDialog prog(this); - if (prog.exec(task) == QDialog::Accepted) - { - accept(); - } - else - { - CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), - tr("Unknown error"), QMessageBox::Warning)->exec(); - reject(); - } -} - -void ScreenshotDialog::on_deleteBtn_clicked() -{ - m_list->deleteSelected(this); -} diff --git a/gui/dialogs/ScreenshotDialog.h b/gui/dialogs/ScreenshotDialog.h deleted file mode 100644 index 29dd6765..00000000 --- a/gui/dialogs/ScreenshotDialog.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include <QDialog> -#include "logic/screenshots/ScreenshotList.h" - -class ImgurAlbumCreation; - -namespace Ui -{ -class ScreenshotDialog; -} - -class ScreenshotDialog : public QDialog -{ - Q_OBJECT - -public: - explicit ScreenshotDialog(ScreenshotList *list, QWidget *parent = 0); - ~ScreenshotDialog(); - - enum - { - NothingDone = 0x42 - }; - - QString message() const; - QList<ScreenshotPtr> selected() const; - -private -slots: - void on_uploadBtn_clicked(); - - void on_deleteBtn_clicked(); - -private: - Ui::ScreenshotDialog *ui; - ScreenshotList *m_list; - QList<ScreenshotPtr> m_uploaded; - std::shared_ptr<ImgurAlbumCreation> m_imgurAlbum; -}; diff --git a/gui/dialogs/ScreenshotDialog.ui b/gui/dialogs/ScreenshotDialog.ui deleted file mode 100644 index eb3dafba..00000000 --- a/gui/dialogs/ScreenshotDialog.ui +++ /dev/null @@ -1,110 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ScreenshotDialog</class> - <widget class="QDialog" name="ScreenshotDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>470</width> - <height>300</height> - </rect> - </property> - <property name="windowTitle"> - <string>Screenshot Manager</string> - </property> - <property name="windowIcon"> - <iconset resource="../../resources/multimc/multimc.qrc"> - <normaloff>:/icons/multimc/scalable/apps/multimc.svg</normaloff>:/icons/multimc/scalable/apps/multimc.svg</iconset> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QListView" name="listView"> - <property name="selectionMode"> - <enum>QAbstractItemView::ExtendedSelection</enum> - </property> - <property name="selectionBehavior"> - <enum>QAbstractItemView::SelectItems</enum> - </property> - <property name="iconSize"> - <size> - <width>120</width> - <height>90</height> - </size> - </property> - <property name="flow"> - <enum>QListView::LeftToRight</enum> - </property> - <property name="isWrapping" stdset="0"> - <bool>true</bool> - </property> - <property name="resizeMode"> - <enum>QListView::Adjust</enum> - </property> - <property name="viewMode"> - <enum>QListView::IconMode</enum> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="uploadBtn"> - <property name="text"> - <string>Upload</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="deleteBtn"> - <property name="text"> - <string>Delete</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="closeBtn"> - <property name="text"> - <string>Close</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources> - <include location="../../resources/multimc/multimc.qrc"/> - </resources> - <connections> - <connection> - <sender>closeBtn</sender> - <signal>clicked()</signal> - <receiver>ScreenshotDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>315</x> - <y>272</y> - </hint> - <hint type="destinationlabel"> - <x>271</x> - <y>258</y> - </hint> - </hints> - </connection> - </connections> -</ui> |