From e8731c5d013e67ee0153d5a49b38b0e914d14aa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 28 Jun 2014 17:07:08 +0200 Subject: Turn screenshot management into a page. --- gui/ConsoleWindow.cpp | 17 ------ gui/MainWindow.cpp | 29 +++-------- gui/dialogs/ScreenshotDialog.cpp | 78 --------------------------- gui/dialogs/ScreenshotDialog.h | 40 -------------- gui/dialogs/ScreenshotDialog.ui | 110 --------------------------------------- gui/pagedialog/PageDialog.cpp | 1 + gui/pages/BasePage.h | 4 ++ 7 files changed, 11 insertions(+), 268 deletions(-) delete mode 100644 gui/dialogs/ScreenshotDialog.cpp delete mode 100644 gui/dialogs/ScreenshotDialog.h delete mode 100644 gui/dialogs/ScreenshotDialog.ui (limited to 'gui') diff --git a/gui/ConsoleWindow.cpp b/gui/ConsoleWindow.cpp index ac3752c5..d4ce1581 100644 --- a/gui/ConsoleWindow.cpp +++ b/gui/ConsoleWindow.cpp @@ -24,7 +24,6 @@ #include #include #include -#include "dialogs/ScreenshotDialog.h" #include "logic/net/PasteUpload.h" #include "logic/icons/IconList.h" @@ -174,22 +173,6 @@ void ConsoleWindow::on_closeButton_clicked() void ConsoleWindow::on_btnScreenshots_clicked() { - ScreenshotList *list = new ScreenshotList(proc->instance()); - Task *task = list->load(); - ProgressDialog prog(this); - prog.exec(task); - if (!task->successful()) - { - CustomMessageBox::selectable(this, tr("Failed to load screenshots!"), - task->failReason(), QMessageBox::Warning)->exec(); - return; - } - ScreenshotDialog dialog(list, this); - if (dialog.exec() == ScreenshotDialog::Accepted) - { - CustomMessageBox::selectable(this, tr("Done uploading!"), dialog.message(), - QMessageBox::Information)->exec(); - } } void ConsoleWindow::setMayClose(bool mayclose) diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index e5c7dbb1..bee250c4 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -63,7 +63,6 @@ #include "gui/dialogs/UpdateDialog.h" #include "gui/dialogs/EditAccountDialog.h" #include "gui/dialogs/NotificationDialog.h" -#include "dialogs/ScreenshotDialog.h" #include "gui/ConsoleWindow.h" #include "pagedialog/PageDialog.h" @@ -969,6 +968,12 @@ void MainWindow::on_actionEditInstance_triggered() ShowPageDialog(m_selectedInstance, this); } +void MainWindow::on_actionScreenshots_triggered() +{ + ShowPageDialog(m_selectedInstance, this, "screenshots"); +} + + void MainWindow::on_actionManageAccounts_triggered() { AccountListDialog dialog(this); @@ -1510,25 +1515,3 @@ void MainWindow::checkSetDefaultJava() MMC->settings()->set("JavaPath", QString("java")); } } - -void MainWindow::on_actionScreenshots_triggered() -{ - if (!m_selectedInstance) - return; - ScreenshotList *list = new ScreenshotList(m_selectedInstance); - Task *task = list->load(); - ProgressDialog prog(this); - prog.exec(task); - if (!task->successful()) - { - CustomMessageBox::selectable(this, tr("Failed to load screenshots!"), - task->failReason(), QMessageBox::Warning)->exec(); - return; - } - ScreenshotDialog dialog(list, this); - if (dialog.exec() == ScreenshotDialog::Accepted) - { - CustomMessageBox::selectable(this, tr("Done uploading!"), dialog.message(), - QMessageBox::Information)->exec(); - } -} 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 -#include - -#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("Visit album
Delete hash: %2 (save " - "this if you want to be able to edit/delete the album)") - .arg(m_imgurAlbum->id(), m_imgurAlbum->deleteHash()); -} - -QList ScreenshotDialog::selected() const -{ - QList list; - QList 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 -#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 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; -}; 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 @@ - - - ScreenshotDialog - - - - 0 - 0 - 470 - 300 - - - - Screenshot Manager - - - - :/icons/multimc/scalable/apps/multimc.svg:/icons/multimc/scalable/apps/multimc.svg - - - - - - QAbstractItemView::ExtendedSelection - - - QAbstractItemView::SelectItems - - - - 120 - 90 - - - - QListView::LeftToRight - - - true - - - QListView::Adjust - - - QListView::IconMode - - - - - - - - - Upload - - - - - - - Delete - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Close - - - - - - - - - - - - - closeBtn - clicked() - ScreenshotDialog - reject() - - - 315 - 272 - - - 271 - 258 - - - - - diff --git a/gui/pagedialog/PageDialog.cpp b/gui/pagedialog/PageDialog.cpp index 4db5cd28..56bdfd14 100644 --- a/gui/pagedialog/PageDialog.cpp +++ b/gui/pagedialog/PageDialog.cpp @@ -159,6 +159,7 @@ void PageDialog::showPage(int row) m_pageStack->setCurrentIndex(m_currentPage->stackIndex); m_header->setText(m_currentPage->displayName()); m_iconHeader->setIcon(m_currentPage->icon()); + m_currentPage->opened(); } else { diff --git a/gui/pages/BasePage.h b/gui/pages/BasePage.h index bba4996d..09af3a59 100644 --- a/gui/pages/BasePage.h +++ b/gui/pages/BasePage.h @@ -36,6 +36,10 @@ public: virtual QString helpPage() { return QString(); + } + virtual void opened() + { + } int stackIndex = -1; int listIndex = -1; -- cgit v1.2.3