diff options
Diffstat (limited to 'gui/consolewindow.cpp')
-rw-r--r-- | gui/consolewindow.cpp | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/gui/consolewindow.cpp b/gui/consolewindow.cpp index 811900a2..8ea90d45 100644 --- a/gui/consolewindow.cpp +++ b/gui/consolewindow.cpp @@ -2,13 +2,16 @@ #include "ui_consolewindow.h" #include <QScrollBar> +#include <QMessageBox> -ConsoleWindow::ConsoleWindow(QWidget *parent) : +ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) : QDialog(parent), ui(new Ui::ConsoleWindow), - m_mayclose(true) + m_mayclose(true), + proc(mcproc) { ui->setupUi(this); + connect(mcproc, SIGNAL(ended()), this, SLOT(onEnded())); } ConsoleWindow::~ConsoleWindow() @@ -20,7 +23,7 @@ void ConsoleWindow::writeColor(QString text, const char *color) { // append a paragraph if (color != nullptr) - ui->text->appendHtml(QString("<font color=%1>%2</font>").arg(color).arg(text)); + ui->text->appendHtml(QString("<font color=\"%1\">%2</font>").arg(color).arg(text)); else ui->text->appendPlainText(text); // scroll down @@ -40,6 +43,15 @@ void ConsoleWindow::write(QString data, MessageLevel::Enum mode) else if (mode == MessageLevel::Error) while(iter.hasNext()) writeColor(iter.next(), "red"); + else if (mode == MessageLevel::Warning) + while(iter.hasNext()) + writeColor(iter.next(), "orange"); + else if (mode == MessageLevel::Fatal) + while(iter.hasNext()) + writeColor(iter.next(), "pink"); + else if (mode == MessageLevel::Debug) + while(iter.hasNext()) + writeColor(iter.next(), "green"); // TODO: implement other MessageLevels else while(iter.hasNext()) @@ -72,3 +84,25 @@ void ConsoleWindow::closeEvent(QCloseEvent * event) else QDialog::closeEvent(event); } + +void ConsoleWindow::on_btnKillMinecraft_clicked() +{ + ui->btnKillMinecraft->setEnabled(false); + QMessageBox r_u_sure; + r_u_sure.setText("Kill Minecraft?"); + r_u_sure.setInformativeText("This can cause the instance to get corrupted and should only be used if Minecraft is frozen for some reason"); + r_u_sure.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + r_u_sure.setDefaultButton(QMessageBox::Yes); + if (r_u_sure.exec() == QMessageBox::Yes) + proc->killMinecraft(); + else + ui->btnKillMinecraft->setEnabled(true); + r_u_sure.close(); +} + +void ConsoleWindow::onEnded() +{ + ui->btnKillMinecraft->setEnabled(false); + // TODO: Check why this doesn't work + if (!proc->exitCode()) this->close(); +} |