From ef88a913f9dea5d698e687bebe96c953a80a86ef Mon Sep 17 00:00:00 2001 From: loathingKernel <142770+loathingKernel@users.noreply.github.com> Date: Mon, 11 Jul 2022 22:02:57 +0300 Subject: [PATCH] LaunchHelper: Add terminate and kill button in the console (visible only in windows for now) --- rare/game_launch_helper/__init__.py | 2 ++ rare/game_launch_helper/console.py | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/rare/game_launch_helper/__init__.py b/rare/game_launch_helper/__init__.py index 5f94cff2..374950d6 100644 --- a/rare/game_launch_helper/__init__.py +++ b/rare/game_launch_helper/__init__.py @@ -102,6 +102,8 @@ class GameProcessApp(RareApp): self.game_process.readAllStandardError().data().decode("utf-8", "ignore") ) ) + self.console.term.connect(lambda: self.game_process.terminate()) + self.console.kill.connect(lambda: self.game_process.kill()) self.start_time = time.time() diff --git a/rare/game_launch_helper/console.py b/rare/game_launch_helper/console.py index c24f83a1..c0c93139 100644 --- a/rare/game_launch_helper/console.py +++ b/rare/game_launch_helper/console.py @@ -1,4 +1,6 @@ -from PyQt5.QtCore import QProcessEnvironment +import platform + +from PyQt5.QtCore import QProcessEnvironment, pyqtSignal from PyQt5.QtGui import QTextCursor, QFont from PyQt5.QtWidgets import ( QPlainTextEdit, @@ -15,6 +17,8 @@ from rare.ui.components.extra.console_env import Ui_ConsoleEnv class Console(QDialog): + term = pyqtSignal() + kill = pyqtSignal() env: QProcessEnvironment def __init__(self, parent=None): @@ -27,7 +31,6 @@ class Console(QDialog): layout.addWidget(self.console) button_layout = QHBoxLayout() - button_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Fixed)) self.env_button = QPushButton(self.tr("Show environment")) button_layout.addWidget(self.env_button) @@ -41,6 +44,18 @@ class Console(QDialog): button_layout.addWidget(self.clear_button) self.clear_button.clicked.connect(self.console.clear) + button_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Fixed)) + + self.terminate_button = QPushButton(self.tr("Terminate")) + self.terminate_button.setVisible(platform.system() == "Windows") + button_layout.addWidget(self.terminate_button) + self.terminate_button.clicked.connect(lambda: self.term.emit()) + + self.kill_button = QPushButton(self.tr("Kill")) + self.kill_button.setVisible(platform.system() == "Windows") + button_layout.addWidget(self.kill_button) + self.kill_button.clicked.connect(lambda: self.kill.emit()) + layout.addLayout(button_layout) self.setLayout(layout)