diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-11-23 01:41:28 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-11-23 01:41:28 +0100 |
commit | 4124faf474908e4d79d93b0f624bf8fd81bd9972 (patch) | |
tree | 335087d96ddab6b862c187969749134be6b4d96e /gui/ConsoleWindow.cpp | |
parent | 7f5eb5d61ad5c94da5e3a0443ffbcd9088285496 (diff) | |
download | MultiMC-4124faf474908e4d79d93b0f624bf8fd81bd9972.tar MultiMC-4124faf474908e4d79d93b0f624bf8fd81bd9972.tar.gz MultiMC-4124faf474908e4d79d93b0f624bf8fd81bd9972.tar.lz MultiMC-4124faf474908e4d79d93b0f624bf8fd81bd9972.tar.xz MultiMC-4124faf474908e4d79d93b0f624bf8fd81bd9972.zip |
Fix console window (now not a QDialog)
It now opens and coloses as expected, depending on user
preferences and the status of the various processes involved.
Console window geometry and state are remembered between runs.
Diffstat (limited to 'gui/ConsoleWindow.cpp')
-rw-r--r-- | gui/ConsoleWindow.cpp | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/gui/ConsoleWindow.cpp b/gui/ConsoleWindow.cpp index 1a888330..d8a1b69d 100644 --- a/gui/ConsoleWindow.cpp +++ b/gui/ConsoleWindow.cpp @@ -15,6 +15,7 @@ #include "ConsoleWindow.h" #include "ui_ConsoleWindow.h" +#include "MultiMC.h" #include <QScrollBar> #include <QMessageBox> @@ -23,13 +24,26 @@ #include <gui/dialogs/CustomMessageBox.h> ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) - : QDialog(parent), ui(new Ui::ConsoleWindow), m_mayclose(true), proc(mcproc) + : QMainWindow(parent), ui(new Ui::ConsoleWindow), proc(mcproc) { MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); - this->setWindowFlags(Qt::Window); + 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*))); + + restoreState(QByteArray::fromBase64(MMC->settings()->get("ConsoleWindowState").toByteArray())); + restoreGeometry(QByteArray::fromBase64(MMC->settings()->get("ConsoleWindowGeometry").toByteArray())); + + if (mcproc->instance()->settings().get("ShowConsole").toBool()) + { + show(); + } } ConsoleWindow::~ConsoleWindow() @@ -105,7 +119,13 @@ void ConsoleWindow::closeEvent(QCloseEvent *event) if (!m_mayclose) event->ignore(); else - QDialog::closeEvent(event); + { + MMC->settings()->set("ConsoleWindowState", saveState().toBase64()); + MMC->settings()->set("ConsoleWindowGeometry", saveGeometry().toBase64()); + + emit isClosing(); + QMainWindow::closeEvent(event); + } } void ConsoleWindow::on_btnKillMinecraft_clicked() @@ -131,6 +151,16 @@ void ConsoleWindow::onEnded(BaseInstance *instance, int code, QProcess::ExitStat if (code == 0 && status != QProcess::CrashExit) { this->close(); + return; } } + if(!isVisible()) + show(); +} + +void ConsoleWindow::onLaunchFailed(BaseInstance *instance) +{ + ui->btnKillMinecraft->setEnabled(false); + if(!isVisible()) + show(); } |