Merge branch 'develop'

This commit is contained in:
Petr Mrázek 2013-11-13 00:25:57 +01:00
commit 662b4bc8cb
3 changed files with 24 additions and 24 deletions

View File

@ -22,16 +22,14 @@
#include <gui/Platform.h> #include <gui/Platform.h>
#include <gui/dialogs/CustomMessageBox.h> #include <gui/dialogs/CustomMessageBox.h>
ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) : ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent)
QDialog(parent), : QDialog(parent), ui(new Ui::ConsoleWindow), m_mayclose(true), proc(mcproc)
ui(new Ui::ConsoleWindow),
m_mayclose(true),
proc(mcproc)
{ {
MultiMCPlatform::fixWM_CLASS(this); MultiMCPlatform::fixWM_CLASS(this);
ui->setupUi(this); ui->setupUi(this);
this->setWindowFlags(Qt::Window); this->setWindowFlags(Qt::Window);
connect(mcproc, SIGNAL(ended(BaseInstance*)), this, SLOT(onEnded(BaseInstance*))); connect(mcproc, SIGNAL(ended(BaseInstance *, int, ExitStatus)), this,
SLOT(onEnded(BaseInstance *, int, QProcess::ExitStatus)));
} }
ConsoleWindow::~ConsoleWindow() ConsoleWindow::~ConsoleWindow()
@ -54,32 +52,32 @@ void ConsoleWindow::writeColor(QString text, const char *color)
void ConsoleWindow::write(QString data, MessageLevel::Enum mode) void ConsoleWindow::write(QString data, MessageLevel::Enum mode)
{ {
if (data.endsWith('\n')) if (data.endsWith('\n'))
data = data.left(data.length()-1); data = data.left(data.length() - 1);
QStringList paragraphs = data.split('\n'); QStringList paragraphs = data.split('\n');
for(QString &paragraph : paragraphs) for (QString &paragraph : paragraphs)
{ {
paragraph = paragraph.trimmed(); paragraph = paragraph.trimmed();
} }
QListIterator<QString> iter(paragraphs); QListIterator<QString> iter(paragraphs);
if (mode == MessageLevel::MultiMC) if (mode == MessageLevel::MultiMC)
while(iter.hasNext()) while (iter.hasNext())
writeColor(iter.next(), "blue"); writeColor(iter.next(), "blue");
else if (mode == MessageLevel::Error) else if (mode == MessageLevel::Error)
while(iter.hasNext()) while (iter.hasNext())
writeColor(iter.next(), "red"); writeColor(iter.next(), "red");
else if (mode == MessageLevel::Warning) else if (mode == MessageLevel::Warning)
while(iter.hasNext()) while (iter.hasNext())
writeColor(iter.next(), "orange"); writeColor(iter.next(), "orange");
else if (mode == MessageLevel::Fatal) else if (mode == MessageLevel::Fatal)
while(iter.hasNext()) while (iter.hasNext())
writeColor(iter.next(), "pink"); writeColor(iter.next(), "pink");
else if (mode == MessageLevel::Debug) else if (mode == MessageLevel::Debug)
while(iter.hasNext()) while (iter.hasNext())
writeColor(iter.next(), "green"); writeColor(iter.next(), "green");
// TODO: implement other MessageLevels // TODO: implement other MessageLevels
else else
while(iter.hasNext()) while (iter.hasNext())
writeColor(iter.next()); writeColor(iter.next());
} }
@ -102,9 +100,9 @@ void ConsoleWindow::setMayClose(bool mayclose)
ui->closeButton->setEnabled(false); ui->closeButton->setEnabled(false);
} }
void ConsoleWindow::closeEvent(QCloseEvent * event) void ConsoleWindow::closeEvent(QCloseEvent *event)
{ {
if(!m_mayclose) if (!m_mayclose)
event->ignore(); event->ignore();
else else
QDialog::closeEvent(event); QDialog::closeEvent(event);
@ -113,8 +111,10 @@ void ConsoleWindow::closeEvent(QCloseEvent * event)
void ConsoleWindow::on_btnKillMinecraft_clicked() void ConsoleWindow::on_btnKillMinecraft_clicked()
{ {
ui->btnKillMinecraft->setEnabled(false); ui->btnKillMinecraft->setEnabled(false);
auto response = CustomMessageBox::selectable(this, tr("Kill Minecraft?"), auto response = CustomMessageBox::selectable(
tr("This can cause the instance to get corrupted and should only be used if Minecraft is frozen for some reason"), this, tr("Kill Minecraft?"),
tr("This can cause the instance to get corrupted and should only be used if Minecraft "
"is frozen for some reason"),
QMessageBox::Question, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)->exec(); QMessageBox::Question, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)->exec();
if (response == QMessageBox::Yes) if (response == QMessageBox::Yes)
proc->killMinecraft(); proc->killMinecraft();
@ -122,11 +122,11 @@ void ConsoleWindow::on_btnKillMinecraft_clicked()
ui->btnKillMinecraft->setEnabled(true); ui->btnKillMinecraft->setEnabled(true);
} }
void ConsoleWindow::onEnded(BaseInstance* instance, int code, QProcess::ExitStatus status) void ConsoleWindow::onEnded(BaseInstance *instance, int code, QProcess::ExitStatus status)
{ {
ui->btnKillMinecraft->setEnabled(false); ui->btnKillMinecraft->setEnabled(false);
if(instance->settings().get("AutoCloseConsole").toBool()) if (instance->settings().get("AutoCloseConsole").toBool())
{ {
if (code == 0 && status != QProcess::CrashExit) if (code == 0 && status != QProcess::CrashExit)
{ {

View File

@ -725,8 +725,8 @@ void MainWindow::launchInstance(BaseInstance *instance, LoginResponse response)
connect(proc, SIGNAL(log(QString, MessageLevel::Enum)), console, connect(proc, SIGNAL(log(QString, MessageLevel::Enum)), console,
SLOT(write(QString, MessageLevel::Enum))); SLOT(write(QString, MessageLevel::Enum)));
connect(proc, SIGNAL(ended(BaseInstance *, int, ExitStatus)), this, connect(proc, SIGNAL(ended(BaseInstance*,int,QProcess::ExitStatus)), this,
SLOT(instanceEnded(BaseInstance *, int, ExitStatus))); SLOT(instanceEnded(BaseInstance*,int,QProcess::ExitStatus)));
if (instance->settings().get("ShowConsole").toBool()) if (instance->settings().get("ShowConsole").toBool())
{ {

View File

@ -74,7 +74,7 @@ signals:
/** /**
* @brief emitted when mc has finished and the PostLaunchCommand was run * @brief emitted when mc has finished and the PostLaunchCommand was run
*/ */
void ended(BaseInstance *, int code, ExitStatus status); void ended(BaseInstance *, int code, QProcess::ExitStatus status);
/** /**
* @brief emitted when we want to log something * @brief emitted when we want to log something