mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
Merge 007ba4f818 into d2fa7cf7f7
This commit is contained in:
commit
ca87d853ca
2 changed files with 31 additions and 1 deletions
|
|
@ -42,6 +42,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "ui/widgets/PageContainer.h"
|
#include "ui/widgets/PageContainer.h"
|
||||||
|
|
||||||
|
|
@ -93,6 +94,12 @@ InstanceWindow::InstanceWindow(BaseInstance* instance, QWidget* parent) : QMainW
|
||||||
horizontalLayout->addWidget(m_launchButton);
|
horizontalLayout->addWidget(m_launchButton);
|
||||||
connect(m_launchButton, &QPushButton::clicked, this, [this] { APPLICATION->launch(m_instance); });
|
connect(m_launchButton, &QPushButton::clicked, this, [this] { APPLICATION->launch(m_instance); });
|
||||||
|
|
||||||
|
m_restartButton = new QPushButton(this);
|
||||||
|
m_restartButton->setText(tr("&Restart"));
|
||||||
|
m_restartButton->setToolTip(tr("Restart the running instance"));
|
||||||
|
horizontalLayout->addWidget(m_restartButton);
|
||||||
|
connect(m_restartButton, &QPushButton::clicked, this, &InstanceWindow::restartInstance);
|
||||||
|
|
||||||
m_killButton = new QPushButton(this);
|
m_killButton = new QPushButton(this);
|
||||||
m_killButton->setText(tr("&Kill"));
|
m_killButton->setText(tr("&Kill"));
|
||||||
m_killButton->setToolTip(tr("Kill the running instance"));
|
m_killButton->setToolTip(tr("Kill the running instance"));
|
||||||
|
|
@ -152,8 +159,11 @@ void InstanceWindow::on_instanceStatusChanged(BaseInstance::Status, BaseInstance
|
||||||
|
|
||||||
void InstanceWindow::updateButtons()
|
void InstanceWindow::updateButtons()
|
||||||
{
|
{
|
||||||
|
const bool running = m_instance->isRunning();
|
||||||
|
|
||||||
m_launchButton->setEnabled(m_instance->canLaunch());
|
m_launchButton->setEnabled(m_instance->canLaunch());
|
||||||
m_killButton->setEnabled(m_instance->isRunning());
|
m_restartButton->setEnabled(running && !m_restartQueued);
|
||||||
|
m_killButton->setEnabled(running);
|
||||||
|
|
||||||
QMenu* launchMenu = m_launchButton->menu();
|
QMenu* launchMenu = m_launchButton->menu();
|
||||||
if (launchMenu)
|
if (launchMenu)
|
||||||
|
|
@ -175,9 +185,26 @@ void InstanceWindow::runningStateChanged(bool running)
|
||||||
m_container->refreshContainer();
|
m_container->refreshContainer();
|
||||||
if (running) {
|
if (running) {
|
||||||
selectPage("log");
|
selectPage("log");
|
||||||
|
} else if (m_restartQueued) {
|
||||||
|
m_restartQueued = false;
|
||||||
|
// Wait until the current launch controller has handled the stopped instance before launching again.
|
||||||
|
QTimer::singleShot(0, this, [this] {
|
||||||
|
APPLICATION->launch(m_instance);
|
||||||
|
updateButtons();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstanceWindow::restartInstance()
|
||||||
|
{
|
||||||
|
if (!m_instance->isRunning()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_restartQueued = APPLICATION->kill(m_instance);
|
||||||
|
updateButtons();
|
||||||
|
}
|
||||||
|
|
||||||
void InstanceWindow::closeEvent(QCloseEvent* event)
|
void InstanceWindow::closeEvent(QCloseEvent* event)
|
||||||
{
|
{
|
||||||
bool proceed = true;
|
bool proceed = true;
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ class InstanceWindow : public QMainWindow, public BasePageContainer {
|
||||||
private slots:
|
private slots:
|
||||||
void instanceLaunchTaskChanged(LaunchTask* proc);
|
void instanceLaunchTaskChanged(LaunchTask* proc);
|
||||||
void runningStateChanged(bool running);
|
void runningStateChanged(bool running);
|
||||||
|
void restartInstance();
|
||||||
void on_instanceStatusChanged(BaseInstance::Status, BaseInstance::Status newStatus);
|
void on_instanceStatusChanged(BaseInstance::Status, BaseInstance::Status newStatus);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -86,8 +87,10 @@ class InstanceWindow : public QMainWindow, public BasePageContainer {
|
||||||
LaunchTask* m_proc;
|
LaunchTask* m_proc;
|
||||||
BaseInstance* m_instance;
|
BaseInstance* m_instance;
|
||||||
bool m_doNotSave = false;
|
bool m_doNotSave = false;
|
||||||
|
bool m_restartQueued = false;
|
||||||
PageContainer* m_container = nullptr;
|
PageContainer* m_container = nullptr;
|
||||||
QPushButton* m_closeButton = nullptr;
|
QPushButton* m_closeButton = nullptr;
|
||||||
QToolButton* m_launchButton = nullptr;
|
QToolButton* m_launchButton = nullptr;
|
||||||
|
QPushButton* m_restartButton = nullptr;
|
||||||
QPushButton* m_killButton = nullptr;
|
QPushButton* m_killButton = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue