From 4a77524b059c12165e20b38de6c0d4ed08e56419 Mon Sep 17 00:00:00 2001 From: robotbrain Date: Sun, 23 Feb 2014 16:14:24 -0500 Subject: Initial stuff. It doesnt work. --- gui/MainWindow.cpp | 71 +++++++++++++++++++++++++++++- gui/MainWindow.h | 14 ++++-- gui/MainWindow.ui | 13 +++++- gui/dialogs/ScreenshotDialog.cpp | 28 ++++++++++++ gui/dialogs/ScreenshotDialog.h | 29 +++++++++++++ gui/dialogs/ScreenshotDialog.ui | 93 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 240 insertions(+), 8 deletions(-) create mode 100644 gui/dialogs/ScreenshotDialog.cpp create mode 100644 gui/dialogs/ScreenshotDialog.h create mode 100644 gui/dialogs/ScreenshotDialog.ui (limited to 'gui') diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 29f7c8e8..5a22f678 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -43,7 +43,6 @@ #include "gui/Platform.h" - #include "gui/widgets/LabeledToolButton.h" #include "gui/dialogs/SettingsDialog.h" @@ -61,6 +60,7 @@ #include "gui/dialogs/AccountSelectDialog.h" #include "gui/dialogs/UpdateDialog.h" #include "gui/dialogs/EditAccountDialog.h" +#include "gui/dialogs/ScreenshotDialog.h" #include "gui/ConsoleWindow.h" @@ -80,6 +80,8 @@ #include "logic/status/StatusChecker.h" #include "logic/net/URLConstants.h" +#include "logic/net/NetJob.h" +#include "logic/net/ScreenshotUploader.h" #include "logic/BaseInstance.h" #include "logic/InstanceFactory.h" @@ -143,7 +145,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi { view = new GroupView(ui->centralWidget); - view->setSelectionMode(QAbstractItemView::SingleSelection); // view->setCategoryDrawer(drawer); // view->setCollapsibleBlocks(true); @@ -1499,3 +1500,69 @@ 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() == QDialog::Accepted) + { + QList screenshots = dialog.selected(); + if (screenshots.size() == 0) + return; + NetJob *job = new NetJob("Screenshot Upload"); + for (ScreenShot *shot : screenshots) + job->addNetAction(ScreenShotUpload::make(shot)); + ProgressDialog prog2(this); + prog2.exec(job); + connect(job, &NetJob::failed, [this] + { + CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), + tr("Unknown error"), QMessageBox::Warning)->exec(); + }); + connect(job, &NetJob::succeeded, [this, screenshots] + { screenshotsUploaded(screenshots); }); + } +} + +void MainWindow::screenshotsUploaded(QList screenshots) +{ + NetJob *job2 = new NetJob("Screenshot Data"); + for (ScreenShot *shot : screenshots) + { + job2->addNetAction(ScreenShotGet::make(shot)); + } + ProgressDialog prog3(this); + prog3.exec(job2); + connect(job2, &NetJob::failed, [this] + { + CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), + tr("Unknown error"), QMessageBox::Warning)->exec(); + }); + connect(job2, &NetJob::succeeded, [this, screenshots] + { screenShotsGotten(screenshots); }); +} + +void MainWindow::screenShotsGotten(QList screenshots) +{ + + QStringList urls; + for (ScreenShot *shot : screenshots) + { + urls << QString("url + "\">Image %s") + .arg(QString::number(shot->imgurIndex)); + } + CustomMessageBox::selectable(this, tr("Done uploading!"), urls.join("\n"), + QMessageBox::Information)->exec(); +} diff --git a/gui/MainWindow.h b/gui/MainWindow.h index 4d9e165d..b57afcf5 100644 --- a/gui/MainWindow.h +++ b/gui/MainWindow.h @@ -138,7 +138,9 @@ slots: // called when an icon is changed in the icon model. void iconUpdated(QString); - void showInstanceContextMenu(const QPoint&); + void showInstanceContextMenu(const QPoint &); + + void on_actionScreenshots_triggered(); public slots: @@ -167,11 +169,15 @@ slots: void updateStatusFailedUI(); void reloadStatus(); - + + void screenshotsUploaded(QList screenshots); + + void screenShotsGotten(QList screenshots); + /*! * Runs the DownloadUpdateTask and installs updates. */ - void downloadUpdates(QString repo, int versionId, bool installOnExit=false); + void downloadUpdates(QString repo, int versionId, bool installOnExit = false); protected: bool eventFilter(QObject *obj, QEvent *ev); @@ -188,7 +194,7 @@ private: ConsoleWindow *console; LabeledToolButton *renameButton; QToolButton *changeIconButton; - QToolButton* newsLabel; + QToolButton *newsLabel; BaseInstance *m_selectedInstance; QString m_currentInstIcon; diff --git a/gui/MainWindow.ui b/gui/MainWindow.ui index 8cf26d18..67625ac8 100644 --- a/gui/MainWindow.ui +++ b/gui/MainWindow.ui @@ -112,6 +112,8 @@ + + @@ -528,12 +530,19 @@ Launch the selected instance. + + + Upload 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 new file mode 100644 index 00000000..662c9e84 --- /dev/null +++ b/gui/dialogs/ScreenshotDialog.cpp @@ -0,0 +1,28 @@ +#include "ScreenshotDialog.h" +#include "ui_ScreenshotDialog.h" +#include "QModelIndex" + +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; +} + +QList ScreenshotDialog::selected() +{ + QList list; + QList first = m_list->screenshots(); + for (QModelIndex index : ui->listView->selectionModel()->selectedIndexes()) + { + list.append(first.at(index.row())); + } + return list; +} diff --git a/gui/dialogs/ScreenshotDialog.h b/gui/dialogs/ScreenshotDialog.h new file mode 100644 index 00000000..d3f629e7 --- /dev/null +++ b/gui/dialogs/ScreenshotDialog.h @@ -0,0 +1,29 @@ +#pragma once + +#include +#include "logic/lists/ScreenshotList.h" + +class BaseInstance; + +namespace Ui +{ +class ScreenshotDialog; +} + +class ScreenshotDialog : public QDialog +{ + Q_OBJECT + +public: + explicit ScreenshotDialog(ScreenshotList *list, QWidget *parent = 0); + ~ScreenshotDialog(); + + QList selected(); + +private +slots: + +private: + Ui::ScreenshotDialog *ui; + ScreenshotList *m_list; +}; diff --git a/gui/dialogs/ScreenshotDialog.ui b/gui/dialogs/ScreenshotDialog.ui new file mode 100644 index 00000000..c912dffe --- /dev/null +++ b/gui/dialogs/ScreenshotDialog.ui @@ -0,0 +1,93 @@ + + + ScreenshotDialog + + + + 0 + 0 + 470 + 300 + + + + Dialog + + + + + 10 + 260 + 441 + 31 + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + 10 + 10 + 439 + 241 + + + + QAbstractItemView::MultiSelection + + + + 480 + 360 + + + + QListView::LeftToRight + + + true + + + QListView::ListMode + + + + + + + buttonBox + accepted() + ScreenshotDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ScreenshotDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + -- cgit v1.2.3 From 5e33da258c3b5159dba854eb4792d0852a1ca363 Mon Sep 17 00:00:00 2001 From: robotbrain Date: Sun, 23 Feb 2014 19:45:59 -0500 Subject: Close to finished. Need to fix the upload part. Viewing works (in grayscale) --- gui/MainWindow.cpp | 19 ------------------- gui/MainWindow.h | 2 -- gui/dialogs/ScreenshotDialog.cpp | 2 +- gui/dialogs/ScreenshotDialog.ui | 21 +++++++++++++++------ 4 files changed, 16 insertions(+), 28 deletions(-) (limited to 'gui') diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 5a22f678..87c65601 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -1538,25 +1538,6 @@ void MainWindow::on_actionScreenshots_triggered() void MainWindow::screenshotsUploaded(QList screenshots) { - NetJob *job2 = new NetJob("Screenshot Data"); - for (ScreenShot *shot : screenshots) - { - job2->addNetAction(ScreenShotGet::make(shot)); - } - ProgressDialog prog3(this); - prog3.exec(job2); - connect(job2, &NetJob::failed, [this] - { - CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), - tr("Unknown error"), QMessageBox::Warning)->exec(); - }); - connect(job2, &NetJob::succeeded, [this, screenshots] - { screenShotsGotten(screenshots); }); -} - -void MainWindow::screenShotsGotten(QList screenshots) -{ - QStringList urls; for (ScreenShot *shot : screenshots) { diff --git a/gui/MainWindow.h b/gui/MainWindow.h index b57afcf5..0a474ef1 100644 --- a/gui/MainWindow.h +++ b/gui/MainWindow.h @@ -172,8 +172,6 @@ slots: void screenshotsUploaded(QList screenshots); - void screenShotsGotten(QList screenshots); - /*! * Runs the DownloadUpdateTask and installs updates. */ diff --git a/gui/dialogs/ScreenshotDialog.cpp b/gui/dialogs/ScreenshotDialog.cpp index 662c9e84..8900f15b 100644 --- a/gui/dialogs/ScreenshotDialog.cpp +++ b/gui/dialogs/ScreenshotDialog.cpp @@ -20,7 +20,7 @@ QList ScreenshotDialog::selected() { QList list; QList first = m_list->screenshots(); - for (QModelIndex index : ui->listView->selectionModel()->selectedIndexes()) + for (QModelIndex index : ui->listView->selectionModel()->selectedRows()) { list.append(first.at(index.row())); } diff --git a/gui/dialogs/ScreenshotDialog.ui b/gui/dialogs/ScreenshotDialog.ui index c912dffe..af73e5ec 100644 --- a/gui/dialogs/ScreenshotDialog.ui +++ b/gui/dialogs/ScreenshotDialog.ui @@ -11,7 +11,11 @@ - Dialog + Screenshots + + + + :/icons/multimc/scalable/apps/multimc.svg:/icons/multimc/scalable/apps/multimc.svg @@ -36,12 +40,15 @@ - QAbstractItemView::MultiSelection + QAbstractItemView::ExtendedSelection + + + QAbstractItemView::SelectItems - 480 - 360 + 120 + 90 @@ -51,11 +58,13 @@ true - QListView::ListMode + QListView::IconMode - + + + buttonBox -- cgit v1.2.3 From 226c1bdae5ec615381965b6731f6496dffa3299e Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Mon, 24 Feb 2014 09:34:21 +0100 Subject: Screenshot fixes, move some code around, fix some stuff --- gui/ConsoleWindow.cpp | 3 +++ gui/ConsoleWindow.h | 1 + gui/ConsoleWindow.ui | 7 +++++++ gui/MainWindow.cpp | 36 +++++++++------------------------- gui/MainWindow.h | 2 -- gui/dialogs/ScreenshotDialog.cpp | 42 ++++++++++++++++++++++++++++++++++++++-- gui/dialogs/ScreenshotDialog.h | 11 ++++++++++- gui/dialogs/ScreenshotDialog.ui | 16 --------------- 8 files changed, 70 insertions(+), 48 deletions(-) (limited to 'gui') diff --git a/gui/ConsoleWindow.cpp b/gui/ConsoleWindow.cpp index ccc037f2..d11e8aff 100644 --- a/gui/ConsoleWindow.cpp +++ b/gui/ConsoleWindow.cpp @@ -42,6 +42,8 @@ ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) connect(mcproc, SIGNAL(launch_failed(BaseInstance *)), this, SLOT(onLaunchFailed(BaseInstance *))); + connect(ui->btnScreenshots, &QPushButton::clicked, this, &ConsoleWindow::uploadScreenshots); + restoreState( QByteArray::fromBase64(MMC->settings()->get("ConsoleWindowState").toByteArray())); restoreGeometry( @@ -52,6 +54,7 @@ ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) auto icon = MMC->icons()->getIcon(iconKey); setWindowIcon(icon); m_trayIcon = new QSystemTrayIcon(icon, this); + // TODO add screenshot upload as a menu item in the tray icon QString consoleTitle = tr("Console window for ") + name; m_trayIcon->setToolTip(consoleTitle); setWindowTitle(consoleTitle); diff --git a/gui/ConsoleWindow.h b/gui/ConsoleWindow.h index 7fe90c52..e21da33c 100644 --- a/gui/ConsoleWindow.h +++ b/gui/ConsoleWindow.h @@ -51,6 +51,7 @@ private: signals: void isClosing(); + void uploadScreenshots(); public slots: diff --git a/gui/ConsoleWindow.ui b/gui/ConsoleWindow.ui index c2307ecc..e50fb520 100644 --- a/gui/ConsoleWindow.ui +++ b/gui/ConsoleWindow.ui @@ -49,6 +49,13 @@ + + + + Upload Screenshots + + + diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 87c65601..f79b981a 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -1235,6 +1235,7 @@ void MainWindow::launchInstance(BaseInstance *instance, AuthSessionPtr session) console = new ConsoleWindow(proc); connect(console, SIGNAL(isClosing()), this, SLOT(instanceEnded())); + connect(console, &ConsoleWindow::uploadScreenshots, this, &MainWindow::on_actionScreenshots_triggered); proc->setLogin(session); proc->launch(); @@ -1516,34 +1517,15 @@ void MainWindow::on_actionScreenshots_triggered() return; } ScreenshotDialog dialog(list, this); - if (dialog.exec() == QDialog::Accepted) + if (dialog.exec() == ScreenshotDialog::Accepted) { - QList screenshots = dialog.selected(); - if (screenshots.size() == 0) - return; - NetJob *job = new NetJob("Screenshot Upload"); - for (ScreenShot *shot : screenshots) - job->addNetAction(ScreenShotUpload::make(shot)); - ProgressDialog prog2(this); - prog2.exec(job); - connect(job, &NetJob::failed, [this] + QStringList urls; + for (ScreenShot *shot : dialog.uploaded()) { - CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), - tr("Unknown error"), QMessageBox::Warning)->exec(); - }); - connect(job, &NetJob::succeeded, [this, screenshots] - { screenshotsUploaded(screenshots); }); - } -} - -void MainWindow::screenshotsUploaded(QList screenshots) -{ - QStringList urls; - for (ScreenShot *shot : screenshots) - { - urls << QString("url + "\">Image %s") - .arg(QString::number(shot->imgurIndex)); + urls << QString("url + "\">Image %s") + .arg(QString::number(shot->imgurIndex)); + } + CustomMessageBox::selectable(this, tr("Done uploading!"), urls.join("\n"), + QMessageBox::Information)->exec(); } - CustomMessageBox::selectable(this, tr("Done uploading!"), urls.join("\n"), - QMessageBox::Information)->exec(); } diff --git a/gui/MainWindow.h b/gui/MainWindow.h index 0a474ef1..5911d175 100644 --- a/gui/MainWindow.h +++ b/gui/MainWindow.h @@ -170,8 +170,6 @@ slots: void reloadStatus(); - void screenshotsUploaded(QList screenshots); - /*! * Runs the DownloadUpdateTask and installs updates. */ diff --git a/gui/dialogs/ScreenshotDialog.cpp b/gui/dialogs/ScreenshotDialog.cpp index 8900f15b..02764fa3 100644 --- a/gui/dialogs/ScreenshotDialog.cpp +++ b/gui/dialogs/ScreenshotDialog.cpp @@ -1,6 +1,13 @@ #include "ScreenshotDialog.h" #include "ui_ScreenshotDialog.h" -#include "QModelIndex" + +#include +#include + +#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 ScreenshotDialog::selected() +QList ScreenshotDialog::uploaded() const +{ + return m_uploaded; +} + +QList ScreenshotDialog::selected() const { QList list; QList first = m_list->screenshots(); @@ -26,3 +38,29 @@ QList ScreenshotDialog::selected() } return list; } + +void ScreenshotDialog::on_buttonBox_accepted() +{ + QList 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); +} diff --git a/gui/dialogs/ScreenshotDialog.h b/gui/dialogs/ScreenshotDialog.h index d3f629e7..1ca27bdd 100644 --- a/gui/dialogs/ScreenshotDialog.h +++ b/gui/dialogs/ScreenshotDialog.h @@ -18,12 +18,21 @@ public: explicit ScreenshotDialog(ScreenshotList *list, QWidget *parent = 0); ~ScreenshotDialog(); - QList selected(); + enum + { + NothingDone = 0x42 + }; + + QList uploaded() const; private slots: + void on_buttonBox_accepted(); private: Ui::ScreenshotDialog *ui; ScreenshotList *m_list; + QList m_uploaded; + + QList selected() const; }; diff --git a/gui/dialogs/ScreenshotDialog.ui b/gui/dialogs/ScreenshotDialog.ui index af73e5ec..7eeab859 100644 --- a/gui/dialogs/ScreenshotDialog.ui +++ b/gui/dialogs/ScreenshotDialog.ui @@ -66,22 +66,6 @@ - - buttonBox - accepted() - ScreenshotDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - buttonBox rejected() -- cgit v1.2.3 From a8811a27f78698f1ab2acad47e90f3b16274e221 Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Mon, 24 Feb 2014 10:34:51 +0100 Subject: Working screenshot upload --- gui/MainWindow.cpp | 4 +- gui/dialogs/ScreenshotDialog.cpp | 15 +++--- gui/dialogs/ScreenshotDialog.h | 2 +- gui/dialogs/ScreenshotDialog.ui | 114 ++++++++++++++++++++++----------------- 4 files changed, 75 insertions(+), 60 deletions(-) (limited to 'gui') diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index f79b981a..93608a0e 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -1522,8 +1522,8 @@ void MainWindow::on_actionScreenshots_triggered() QStringList urls; for (ScreenShot *shot : dialog.uploaded()) { - urls << QString("url + "\">Image %s") - .arg(QString::number(shot->imgurIndex)); + urls << QString("url + "\">Image %1") + .arg(shot->timestamp.toString()); } CustomMessageBox::selectable(this, tr("Done uploading!"), urls.join("\n"), QMessageBox::Information)->exec(); diff --git a/gui/dialogs/ScreenshotDialog.cpp b/gui/dialogs/ScreenshotDialog.cpp index 02764fa3..33e93162 100644 --- a/gui/dialogs/ScreenshotDialog.cpp +++ b/gui/dialogs/ScreenshotDialog.cpp @@ -39,7 +39,7 @@ QList ScreenshotDialog::selected() const return list; } -void ScreenshotDialog::on_buttonBox_accepted() +void ScreenshotDialog::on_uploadBtn_clicked() { QList screenshots = selected(); if (screenshots.isEmpty()) @@ -50,17 +50,18 @@ void ScreenshotDialog::on_buttonBox_accepted() NetJob *job = new NetJob("Screenshot Upload"); for (ScreenShot *shot : screenshots) { - qDebug() << shot->file; job->addNetAction(ScreenShotUpload::make(shot)); } + m_uploaded = screenshots; ProgressDialog prog(this); - prog.exec(job); - connect(job, &NetJob::failed, [this] + if (prog.exec(job) == QDialog::Accepted) + { + accept(); + } + else { 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); + } } diff --git a/gui/dialogs/ScreenshotDialog.h b/gui/dialogs/ScreenshotDialog.h index 1ca27bdd..104814f1 100644 --- a/gui/dialogs/ScreenshotDialog.h +++ b/gui/dialogs/ScreenshotDialog.h @@ -27,7 +27,7 @@ public: private slots: - void on_buttonBox_accepted(); + void on_uploadBtn_clicked(); private: Ui::ScreenshotDialog *ui; diff --git a/gui/dialogs/ScreenshotDialog.ui b/gui/dialogs/ScreenshotDialog.ui index 7eeab859..9e4bd6f0 100644 --- a/gui/dialogs/ScreenshotDialog.ui +++ b/gui/dialogs/ScreenshotDialog.ui @@ -17,68 +17,82 @@ :/icons/multimc/scalable/apps/multimc.svg:/icons/multimc/scalable/apps/multimc.svg - - - - 10 - 260 - 441 - 31 - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - 10 - 10 - 439 - 241 - - - - QAbstractItemView::ExtendedSelection - - - QAbstractItemView::SelectItems - - - - 120 - 90 - - - - QListView::LeftToRight - - - true - - - QListView::IconMode - - + + + + + QAbstractItemView::ExtendedSelection + + + QAbstractItemView::SelectItems + + + + 120 + 90 + + + + QListView::LeftToRight + + + true + + + QListView::IconMode + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Close + + + + + + + Upload + + + + + + - buttonBox - rejected() + closeBtn + clicked() ScreenshotDialog reject() - 316 - 260 + 315 + 272 - 286 - 274 + 271 + 258 -- cgit v1.2.3 From da33fa4090b4510267d06b3fd3ec439ff563b80e Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Mon, 24 Feb 2014 11:30:27 +0100 Subject: Imgur album creation --- gui/MainWindow.cpp | 9 +-------- gui/dialogs/CustomMessageBox.cpp | 1 + gui/dialogs/ScreenshotDialog.cpp | 38 ++++++++++++++++++++++---------------- gui/dialogs/ScreenshotDialog.h | 5 +++-- 4 files changed, 27 insertions(+), 26 deletions(-) (limited to 'gui') diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 93608a0e..559c2f48 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -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("url + "\">Image %1") - .arg(shot->timestamp.toString()); - } - CustomMessageBox::selectable(this, tr("Done uploading!"), urls.join("\n"), + CustomMessageBox::selectable(this, tr("Done uploading!"), dialog.message(), QMessageBox::Information)->exec(); } } diff --git a/gui/dialogs/CustomMessageBox.cpp b/gui/dialogs/CustomMessageBox.cpp index 1d2ab58a..4013db60 100644 --- a/gui/dialogs/CustomMessageBox.cpp +++ b/gui/dialogs/CustomMessageBox.cpp @@ -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; } diff --git a/gui/dialogs/ScreenshotDialog.cpp b/gui/dialogs/ScreenshotDialog.cpp index 33e93162..3b4af5e5 100644 --- a/gui/dialogs/ScreenshotDialog.cpp +++ b/gui/dialogs/ScreenshotDialog.cpp @@ -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 ScreenshotDialog::uploaded() const +QString ScreenshotDialog::message() const { - return m_uploaded; + 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 ScreenshotDialog::selected() const { - QList list; - QList first = m_list->screenshots(); + QList list; + QList first = m_list->screenshots(); for (QModelIndex index : ui->listView->selectionModel()->selectedRows()) { list.append(first.at(index.row())); @@ -41,20 +43,24 @@ QList ScreenshotDialog::selected() const void ScreenshotDialog::on_uploadBtn_clicked() { - QList 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(job)); + task->addTask(std::shared_ptr(albumTask)); ProgressDialog prog(this); - if (prog.exec(job) == QDialog::Accepted) + if (prog.exec(task) == QDialog::Accepted) { accept(); } diff --git a/gui/dialogs/ScreenshotDialog.h b/gui/dialogs/ScreenshotDialog.h index 104814f1..ac1494d6 100644 --- a/gui/dialogs/ScreenshotDialog.h +++ b/gui/dialogs/ScreenshotDialog.h @@ -3,7 +3,7 @@ #include #include "logic/lists/ScreenshotList.h" -class BaseInstance; +class ImgurAlbumCreation; namespace Ui { @@ -23,7 +23,7 @@ public: NothingDone = 0x42 }; - QList uploaded() const; + QString message() const; private slots: @@ -33,6 +33,7 @@ private: Ui::ScreenshotDialog *ui; ScreenshotList *m_list; QList m_uploaded; + std::shared_ptr m_imgurAlbum; QList selected() const; }; -- cgit v1.2.3 From 55e21737dd7d30c1922615c575384b41cc77985f Mon Sep 17 00:00:00 2001 From: robotbrain Date: Mon, 24 Feb 2014 17:40:05 -0500 Subject: Deleting screenshots. Needs fixing. --- gui/ConsoleWindow.ui | 2 +- gui/MainWindow.ui | 2 +- gui/dialogs/ScreenshotDialog.cpp | 7 ++++++- gui/dialogs/ScreenshotDialog.h | 5 +++-- gui/dialogs/ScreenshotDialog.ui | 9 ++++++++- 5 files changed, 19 insertions(+), 6 deletions(-) (limited to 'gui') 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 + + + -- cgit v1.2.3 From b1cddb4600db2aa54c9d274466b393fc1e03eba9 Mon Sep 17 00:00:00 2001 From: robotbrain Date: Mon, 24 Feb 2014 17:49:18 -0500 Subject: Fix memory leak in system --- gui/dialogs/ScreenshotDialog.cpp | 6 +++--- gui/dialogs/ScreenshotDialog.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'gui') diff --git a/gui/dialogs/ScreenshotDialog.cpp b/gui/dialogs/ScreenshotDialog.cpp index c62e1d52..76f87283 100644 --- a/gui/dialogs/ScreenshotDialog.cpp +++ b/gui/dialogs/ScreenshotDialog.cpp @@ -32,8 +32,8 @@ QString ScreenshotDialog::message() const QList ScreenshotDialog::selected() const { - QList list; - QList first = m_list->screenshots(); + QList> list; + QList> first = m_list->screenshots(); for (QModelIndex index : ui->listView->selectionModel()->selectedRows()) { list.append(first.at(index.row())); @@ -51,7 +51,7 @@ void ScreenshotDialog::on_uploadBtn_clicked() } SequentialTask *task = new SequentialTask(this); NetJob *job = new NetJob("Screenshot Upload"); - for (ScreenShot *shot : m_uploaded) + for (std::shared_ptr shot : m_uploaded) { job->addNetAction(ImgurUpload::make(shot)); } diff --git a/gui/dialogs/ScreenshotDialog.h b/gui/dialogs/ScreenshotDialog.h index a406d1fe..ac95b4f0 100644 --- a/gui/dialogs/ScreenshotDialog.h +++ b/gui/dialogs/ScreenshotDialog.h @@ -24,7 +24,7 @@ public: }; QString message() const; - QList selected() const; + QList> selected() const; private slots: @@ -35,6 +35,6 @@ slots: private: Ui::ScreenshotDialog *ui; ScreenshotList *m_list; - QList m_uploaded; + QList> m_uploaded; std::shared_ptr m_imgurAlbum; }; -- cgit v1.2.3 From cb5cfe724208beb7d506868fc4e50d9f13e28a53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 25 Feb 2014 00:51:24 +0100 Subject: Reorganize all the screenshot files --- gui/dialogs/ScreenshotDialog.cpp | 16 ++++++++-------- gui/dialogs/ScreenshotDialog.h | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'gui') diff --git a/gui/dialogs/ScreenshotDialog.cpp b/gui/dialogs/ScreenshotDialog.cpp index 76f87283..a88c8dfd 100644 --- a/gui/dialogs/ScreenshotDialog.cpp +++ b/gui/dialogs/ScreenshotDialog.cpp @@ -7,8 +7,8 @@ #include "ProgressDialog.h" #include "CustomMessageBox.h" #include "logic/net/NetJob.h" -#include "logic/net/ImgurUpload.h" -#include "logic/net/ImgurAlbumCreation.h" +#include "logic/screenshots/ImgurUpload.h" +#include "logic/screenshots/ImgurAlbumCreation.h" #include "logic/tasks/SequentialTask.h" ScreenshotDialog::ScreenshotDialog(ScreenshotList *list, QWidget *parent) @@ -30,10 +30,10 @@ QString ScreenshotDialog::message() const .arg(m_imgurAlbum->id(), m_imgurAlbum->deleteHash()); } -QList ScreenshotDialog::selected() const +QList ScreenshotDialog::selected() const { - QList> list; - QList> first = m_list->screenshots(); + QList list; + QList first = m_list->screenshots(); for (QModelIndex index : ui->listView->selectionModel()->selectedRows()) { list.append(first.at(index.row())); @@ -51,14 +51,14 @@ void ScreenshotDialog::on_uploadBtn_clicked() } SequentialTask *task = new SequentialTask(this); NetJob *job = new NetJob("Screenshot Upload"); - for (std::shared_ptr shot : m_uploaded) + 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(std::shared_ptr(job)); - task->addTask(std::shared_ptr(albumTask)); + task->addTask(NetJobPtr(job)); + task->addTask(NetJobPtr(albumTask)); ProgressDialog prog(this); if (prog.exec(task) == QDialog::Accepted) { diff --git a/gui/dialogs/ScreenshotDialog.h b/gui/dialogs/ScreenshotDialog.h index ac95b4f0..29dd6765 100644 --- a/gui/dialogs/ScreenshotDialog.h +++ b/gui/dialogs/ScreenshotDialog.h @@ -1,7 +1,7 @@ #pragma once #include -#include "logic/lists/ScreenshotList.h" +#include "logic/screenshots/ScreenshotList.h" class ImgurAlbumCreation; @@ -24,7 +24,7 @@ public: }; QString message() const; - QList> selected() const; + QList selected() const; private slots: @@ -35,6 +35,6 @@ slots: private: Ui::ScreenshotDialog *ui; ScreenshotList *m_list; - QList> m_uploaded; + QList m_uploaded; std::shared_ptr m_imgurAlbum; }; -- cgit v1.2.3 From 9d4e840a6e1a7169a2863fa1ff1812f8fe19e615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 25 Feb 2014 01:21:46 +0100 Subject: Screenshots: Optimize image loading and memory use, fix list and button layout. --- gui/dialogs/ScreenshotDialog.ui | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'gui') diff --git a/gui/dialogs/ScreenshotDialog.ui b/gui/dialogs/ScreenshotDialog.ui index 4e42a548..eb3dafba 100644 --- a/gui/dialogs/ScreenshotDialog.ui +++ b/gui/dialogs/ScreenshotDialog.ui @@ -38,6 +38,9 @@ true + + QListView::Adjust + QListView::IconMode @@ -45,6 +48,20 @@ + + + + Upload + + + + + + + Delete + + + @@ -65,20 +82,6 @@ - - - - Upload - - - - - - - Delete - - - -- cgit v1.2.3