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 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) (limited to 'gui/MainWindow.cpp') 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(); +} -- 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 ------------------- 1 file changed, 19 deletions(-) (limited to 'gui/MainWindow.cpp') 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) { -- 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/MainWindow.cpp | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) (limited to 'gui/MainWindow.cpp') 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(); } -- 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 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gui/MainWindow.cpp') 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(); -- 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 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'gui/MainWindow.cpp') 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(); } } -- cgit v1.2.3