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 <QPushButton>
|
||||
#include <QScrollBar>
|
||||
#include <QTimer>
|
||||
|
||||
#include "ui/widgets/PageContainer.h"
|
||||
|
||||
|
|
@ -93,6 +94,12 @@ InstanceWindow::InstanceWindow(BaseInstance* instance, QWidget* parent) : QMainW
|
|||
horizontalLayout->addWidget(m_launchButton);
|
||||
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->setText(tr("&Kill"));
|
||||
m_killButton->setToolTip(tr("Kill the running instance"));
|
||||
|
|
@ -152,8 +159,11 @@ void InstanceWindow::on_instanceStatusChanged(BaseInstance::Status, BaseInstance
|
|||
|
||||
void InstanceWindow::updateButtons()
|
||||
{
|
||||
const bool running = m_instance->isRunning();
|
||||
|
||||
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();
|
||||
if (launchMenu)
|
||||
|
|
@ -175,9 +185,26 @@ void InstanceWindow::runningStateChanged(bool running)
|
|||
m_container->refreshContainer();
|
||||
if (running) {
|
||||
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)
|
||||
{
|
||||
bool proceed = true;
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ class InstanceWindow : public QMainWindow, public BasePageContainer {
|
|||
private slots:
|
||||
void instanceLaunchTaskChanged(LaunchTask* proc);
|
||||
void runningStateChanged(bool running);
|
||||
void restartInstance();
|
||||
void on_instanceStatusChanged(BaseInstance::Status, BaseInstance::Status newStatus);
|
||||
|
||||
protected:
|
||||
|
|
@ -86,8 +87,10 @@ class InstanceWindow : public QMainWindow, public BasePageContainer {
|
|||
LaunchTask* m_proc;
|
||||
BaseInstance* m_instance;
|
||||
bool m_doNotSave = false;
|
||||
bool m_restartQueued = false;
|
||||
PageContainer* m_container = nullptr;
|
||||
QPushButton* m_closeButton = nullptr;
|
||||
QToolButton* m_launchButton = nullptr;
|
||||
QPushButton* m_restartButton = nullptr;
|
||||
QPushButton* m_killButton = nullptr;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue