Made instace killing actually work
This commit is contained in:
parent
b44e70d58d
commit
f897a200e2
@ -40,7 +40,8 @@ FORMS += gui/mainwindow.ui \
|
|||||||
gui/settingsdialog.ui \
|
gui/settingsdialog.ui \
|
||||||
gui/modeditwindow.ui \
|
gui/modeditwindow.ui \
|
||||||
gui/instancesettings.ui \
|
gui/instancesettings.ui \
|
||||||
gui/logindialog.ui
|
gui/logindialog.ui \
|
||||||
|
gui/consolewindow.ui
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
multimc.qrc
|
multimc.qrc
|
||||||
|
@ -2,11 +2,13 @@
|
|||||||
#include "ui_consolewindow.h"
|
#include "ui_consolewindow.h"
|
||||||
|
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
ConsoleWindow::ConsoleWindow(QWidget *parent) :
|
ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::ConsoleWindow),
|
ui(new Ui::ConsoleWindow),
|
||||||
m_mayclose(true)
|
m_mayclose(true),
|
||||||
|
proc(mcproc)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
}
|
}
|
||||||
@ -40,6 +42,9 @@ void ConsoleWindow::write(QString data, MessageLevel::Enum mode)
|
|||||||
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)
|
||||||
|
while(iter.hasNext())
|
||||||
|
writeColor(iter.next(), "orange");
|
||||||
// TODO: implement other MessageLevels
|
// TODO: implement other MessageLevels
|
||||||
else
|
else
|
||||||
while(iter.hasNext())
|
while(iter.hasNext())
|
||||||
@ -72,3 +77,18 @@ void ConsoleWindow::closeEvent(QCloseEvent * event)
|
|||||||
else
|
else
|
||||||
QDialog::closeEvent(event);
|
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();
|
||||||
|
}
|
@ -13,7 +13,7 @@ class ConsoleWindow : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ConsoleWindow(QWidget *parent = 0);
|
explicit ConsoleWindow(MinecraftProcess *proc, QWidget *parent = 0);
|
||||||
~ConsoleWindow();
|
~ConsoleWindow();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,12 +48,14 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_closeButton_clicked();
|
void on_closeButton_clicked();
|
||||||
|
void on_btnKillMinecraft_clicked();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *);
|
void closeEvent(QCloseEvent *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ConsoleWindow *ui;
|
Ui::ConsoleWindow *ui;
|
||||||
|
MinecraftProcess *proc;
|
||||||
bool m_mayclose;
|
bool m_mayclose;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,6 +62,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btnKillMinecraft">
|
||||||
|
<property name="text">
|
||||||
|
<string>Kill Minecraft</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="closeButton">
|
<widget class="QPushButton" name="closeButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -538,7 +538,7 @@ void MainWindow::launchInstance(BaseInstance *instance, LoginResponse response)
|
|||||||
if(!proc)
|
if(!proc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
console = new ConsoleWindow();
|
console = new ConsoleWindow(proc);
|
||||||
console->show();
|
console->show();
|
||||||
connect(proc, SIGNAL(log(QString, MessageLevel::Enum)),
|
connect(proc, SIGNAL(log(QString, MessageLevel::Enum)),
|
||||||
console, SLOT(write(QString, MessageLevel::Enum)));
|
console, SLOT(write(QString, MessageLevel::Enum)));
|
||||||
|
@ -120,7 +120,12 @@ void MinecraftProcess::finish(int code, ExitStatus status)
|
|||||||
//TODO: error handling
|
//TODO: error handling
|
||||||
}
|
}
|
||||||
|
|
||||||
emit log("Minecraft exited.");
|
// TODO: Localization
|
||||||
|
|
||||||
|
if (!killed)
|
||||||
|
emit log("Minecraft exited.");
|
||||||
|
else
|
||||||
|
emit log("Minecraft was killed by user.", MessageLevel::Error);
|
||||||
|
|
||||||
m_prepostlaunchprocess.processEnvironment().insert("INST_EXITCODE", QString(code));
|
m_prepostlaunchprocess.processEnvironment().insert("INST_EXITCODE", QString(code));
|
||||||
|
|
||||||
@ -141,6 +146,7 @@ void MinecraftProcess::finish(int code, ExitStatus status)
|
|||||||
void MinecraftProcess::killMinecraft()
|
void MinecraftProcess::killMinecraft()
|
||||||
{
|
{
|
||||||
killed = true;
|
killed = true;
|
||||||
|
kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftProcess::launch()
|
void MinecraftProcess::launch()
|
||||||
|
2
main.cpp
2
main.cpp
@ -71,7 +71,7 @@ private slots:
|
|||||||
//FIXME: report error
|
//FIXME: report error
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console = new ConsoleWindow();
|
console = new ConsoleWindow(proc);
|
||||||
console->show();
|
console->show();
|
||||||
|
|
||||||
connect(proc, SIGNAL(ended()), SLOT(onTerminated()));
|
connect(proc, SIGNAL(ended()), SLOT(onTerminated()));
|
||||||
|
Loading…
Reference in New Issue
Block a user