From 911ac19a56fa1a5f8dd4798385022813cd0b9d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 18 May 2014 19:07:01 +0200 Subject: Screenshot upload dialog(s) now have the console window as parent. --- gui/ConsoleWindow.cpp | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'gui/ConsoleWindow.cpp') diff --git a/gui/ConsoleWindow.cpp b/gui/ConsoleWindow.cpp index 18a617e0..ac3752c5 100644 --- a/gui/ConsoleWindow.cpp +++ b/gui/ConsoleWindow.cpp @@ -24,9 +24,11 @@ #include #include #include +#include "dialogs/ScreenshotDialog.h" #include "logic/net/PasteUpload.h" #include "logic/icons/IconList.h" +#include ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) : QMainWindow(parent), ui(new Ui::ConsoleWindow), proc(mcproc) @@ -35,14 +37,12 @@ ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) ui->setupUi(this); connect(mcproc, SIGNAL(log(QString, MessageLevel::Enum)), this, SLOT(write(QString, MessageLevel::Enum))); - connect(mcproc, SIGNAL(ended(BaseInstance *, int, QProcess::ExitStatus)), this, - SLOT(onEnded(BaseInstance *, int, QProcess::ExitStatus))); - connect(mcproc, SIGNAL(prelaunch_failed(BaseInstance *, int, QProcess::ExitStatus)), this, - SLOT(onEnded(BaseInstance *, int, QProcess::ExitStatus))); - connect(mcproc, SIGNAL(launch_failed(BaseInstance *)), this, - SLOT(onLaunchFailed(BaseInstance *))); - - connect(ui->btnScreenshots, &QPushButton::clicked, this, &ConsoleWindow::uploadScreenshots); + connect(mcproc, SIGNAL(ended(InstancePtr, int, QProcess::ExitStatus)), this, + SLOT(onEnded(InstancePtr, int, QProcess::ExitStatus))); + connect(mcproc, SIGNAL(prelaunch_failed(InstancePtr, int, QProcess::ExitStatus)), this, + SLOT(onEnded(InstancePtr, int, QProcess::ExitStatus))); + connect(mcproc, SIGNAL(launch_failed(InstancePtr)), this, + SLOT(onLaunchFailed(InstancePtr))); restoreState( QByteArray::fromBase64(MMC->settings()->get("ConsoleWindowState").toByteArray())); @@ -172,6 +172,26 @@ void ConsoleWindow::on_closeButton_clicked() close(); } +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) { if(mayclose) @@ -242,7 +262,7 @@ void ConsoleWindow::on_btnKillMinecraft_clicked() ui->btnKillMinecraft->setEnabled(true); } -void ConsoleWindow::onEnded(BaseInstance *instance, int code, QProcess::ExitStatus status) +void ConsoleWindow::onEnded(InstancePtr instance, int code, QProcess::ExitStatus status) { bool peacefulExit = code == 0 && status != QProcess::CrashExit; ui->btnKillMinecraft->setEnabled(false); @@ -274,7 +294,7 @@ void ConsoleWindow::onEnded(BaseInstance *instance, int code, QProcess::ExitStat } } -void ConsoleWindow::onLaunchFailed(BaseInstance *instance) +void ConsoleWindow::onLaunchFailed(InstancePtr instance) { ui->btnKillMinecraft->setEnabled(false); -- cgit v1.2.3