Merge branch 'master' of https://github.com/Stiepen22/MultiMC5 into develop
Conflicts: AppSettings.cpp MultiMC.pro main.cpp
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ class ConsoleWindow : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConsoleWindow(QWidget *parent = 0);
|
||||
explicit ConsoleWindow(MinecraftProcess *proc, QWidget *parent = 0);
|
||||
~ConsoleWindow();
|
||||
|
||||
/**
|
||||
@ -48,12 +48,15 @@ public slots:
|
||||
|
||||
private slots:
|
||||
void on_closeButton_clicked();
|
||||
void on_btnKillMinecraft_clicked();
|
||||
void onEnded();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *);
|
||||
|
||||
private:
|
||||
Ui::ConsoleWindow *ui;
|
||||
MinecraftProcess *proc;
|
||||
bool m_mayclose;
|
||||
};
|
||||
|
||||
|
@ -62,6 +62,13 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnKillMinecraft">
|
||||
<property name="text">
|
||||
<string>Kill Minecraft</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="closeButton">
|
||||
<property name="text">
|
||||
|
@ -488,7 +488,10 @@ void MainWindow::doLogin(const QString& errorMsg)
|
||||
}
|
||||
else
|
||||
{
|
||||
m_activeLogin = {loginDlg->getUsername(), QString("Offline"), qint64(-1)};
|
||||
QString user = loginDlg->getUsername();
|
||||
if (user.length() == 0)
|
||||
user = QString("Offline");
|
||||
m_activeLogin = {user, QString("Offline"), qint64(-1)};
|
||||
m_activeInst = m_selectedInstance;
|
||||
launchInstance(m_activeInst, m_activeLogin);
|
||||
}
|
||||
@ -534,10 +537,22 @@ void MainWindow::launchInstance(BaseInstance *instance, LoginResponse response)
|
||||
if(!proc)
|
||||
return;
|
||||
|
||||
console = new ConsoleWindow();
|
||||
// Prepare GUI: If it shall stay open disable the required parts
|
||||
if (MMC->settings()->get("NoHide").toBool())
|
||||
{
|
||||
ui->actionLaunchInstance->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->hide();
|
||||
}
|
||||
|
||||
console = new ConsoleWindow(proc);
|
||||
console->show();
|
||||
connect(proc, SIGNAL(log(QString, MessageLevel::Enum)),
|
||||
console, SLOT(write(QString, MessageLevel::Enum)));
|
||||
connect(proc, SIGNAL(ended()), this, SLOT(instanceEnded()));
|
||||
proc->setLogin(m_activeLogin.username, m_activeLogin.sessionID);
|
||||
proc->launch();
|
||||
}
|
||||
|
||||
@ -664,3 +679,9 @@ void MainWindow::on_actionEditInstNotes_triggered()
|
||||
linst->setNotes(noteedit.getText());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::instanceEnded()
|
||||
{
|
||||
this->show();
|
||||
ui->actionLaunchInstance->setEnabled(m_selectedInstance);
|
||||
}
|
||||
|
@ -111,6 +111,8 @@ private slots:
|
||||
|
||||
void on_actionChangeInstLWJGLVersion_triggered();
|
||||
|
||||
void instanceEnded();
|
||||
|
||||
void on_actionInstanceSettings_triggered();
|
||||
|
||||
public slots:
|
||||
@ -128,6 +130,7 @@ protected:
|
||||
bool eventFilter(QObject *obj, QEvent *ev);
|
||||
void setCatBackground(bool enabled);
|
||||
private:
|
||||
|
||||
Ui::MainWindow *ui;
|
||||
KCategoryDrawer * drawer;
|
||||
KCategorizedView * view;
|
||||
|
Reference in New Issue
Block a user