From a4db64082f556d9863db911bee9cb9b168565d91 Mon Sep 17 00:00:00 2001 From: loathingKernel <142770+loathingKernel@users.noreply.github.com> Date: Sun, 19 May 2024 13:11:56 +0300 Subject: [PATCH 1/4] RareLauncher: Fix word wrapping in console window --- rare/commands/launcher/__init__.py | 4 +- rare/commands/launcher/console_dialog.py | 47 ++++++++++++++---------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/rare/commands/launcher/__init__.py b/rare/commands/launcher/__init__.py index d075f62ca..2d73dca0e 100644 --- a/rare/commands/launcher/__init__.py +++ b/rare/commands/launcher/__init__.py @@ -174,13 +174,13 @@ def __init__(self, args: InitArgs): @pyqtSlot() def __proc_log_stdout(self): - self.console.log( + self.console.log_stdout( self.game_process.readAllStandardOutput().data().decode("utf-8", "ignore") ) @pyqtSlot() def __proc_log_stderr(self): - self.console.error( + self.console.log_stderr( self.game_process.readAllStandardError().data().decode("utf-8", "ignore") ) diff --git a/rare/commands/launcher/console_dialog.py b/rare/commands/launcher/console_dialog.py index 9df2c1370..a952bc5ef 100644 --- a/rare/commands/launcher/console_dialog.py +++ b/rare/commands/launcher/console_dialog.py @@ -1,3 +1,4 @@ +import os from typing import Union from PyQt5.QtCore import QProcessEnvironment, pyqtSignal, QSize, Qt @@ -31,8 +32,8 @@ def __init__(self, app_title: str, parent=None): self.setGeometry(0, 0, 640, 480) layout = QVBoxLayout() - self.console = ConsoleEdit(self) - layout.addWidget(self.console) + self.console_edit = ConsoleEdit(self) + layout.addWidget(self.console_edit) button_layout = QHBoxLayout() @@ -46,7 +47,7 @@ def __init__(self, app_title: str, parent=None): self.clear_button = QPushButton(self.tr("Clear console")) button_layout.addWidget(self.clear_button) - self.clear_button.clicked.connect(self.console.clear) + self.clear_button.clicked.connect(self.console_edit.clear) button_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Fixed)) @@ -102,7 +103,7 @@ def save(self): if "." not in file: file += ".log" with open(file, "w") as f: - f.write(self.console.toPlainText()) + f.write(self.console_edit.toPlainText()) f.close() self.save_button.setText(self.tr("Saved")) @@ -113,15 +114,21 @@ def show_env(self): self.env_variables.setTable(self.env) self.env_variables.show() - def log(self, text: str, end: str = "\n"): - self.console.log(text + end) + def log(self, text: str): + self.console_edit.log(f"Rare: {text}") - def error(self, text, end: str = "\n"): - self.console.error(text + end) + def log_stdout(self, text: str): + self.console_edit.log(text) + + def error(self, text): + self.console_edit.error(f"Rare: {text}") + + def log_stderr(self, text): + self.console_edit.error(text) def on_process_exit(self, app_title: str, status: Union[int, str]): self.error( - self.tr("Application \"{}\" finished with \"{}\"\n").format(app_title, status) + self.tr("Application finished with exit code \"{}\"").format(status) ) self.accept_close = True @@ -170,17 +177,6 @@ def __init__(self, parent=None): font = QFont("Monospace") font.setStyleHint(QFont.Monospace) self.setFont(font) - self._cursor_output = self.textCursor() - - def log(self, text): - html = f"
{text}
" - self._cursor_output.insertHtml(html) - self.scroll_to_last_line() - - def error(self, text): - html = f"{text}
" - self._cursor_output.insertHtml(html) - self.scroll_to_last_line() def scroll_to_last_line(self): cursor = self.textCursor() @@ -189,3 +185,14 @@ def scroll_to_last_line(self): QTextCursor.Up if cursor.atBlockStart() else QTextCursor.StartOfLine ) self.setTextCursor(cursor) + + def print_to_console(self, text: str, color: str): + html = f"{text}
" + self.appendHtml(html) + self.scroll_to_last_line() + + def log(self, text): + self.print_to_console(text, "#aaa") + + def error(self, text): + self.print_to_console(text, "#a33") From 6dd5d2f546044b3be502d9d2b0b454b4a015396d Mon Sep 17 00:00:00 2001 From: loathingKernel <142770+loathingKernel@users.noreply.github.com> Date: Sun, 19 May 2024 14:52:34 +0300 Subject: [PATCH 2/4] GameDetails: Fix form growth policy --- rare/ui/components/tabs/games/game_info/details.py | 10 +++++----- rare/ui/components/tabs/games/game_info/details.ui | 10 +++++----- rare/ui/components/tabs/store/details.py | 7 ++++++- rare/ui/components/tabs/store/details.ui | 8 +++++++- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/rare/ui/components/tabs/games/game_info/details.py b/rare/ui/components/tabs/games/game_info/details.py index 8321571ae..e47bad728 100644 --- a/rare/ui/components/tabs/games/game_info/details.py +++ b/rare/ui/components/tabs/games/game_info/details.py @@ -62,7 +62,7 @@ def setupUi(self, GameDetails): self.right_layout.setObjectName("right_layout") self.details_layout = QtWidgets.QFormLayout() self.details_layout.setSizeConstraint(QtWidgets.QLayout.SetFixedSize) - self.details_layout.setFieldGrowthPolicy(QtWidgets.QFormLayout.FieldsStayAtSizeHint) + self.details_layout.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow) self.details_layout.setLabelAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) self.details_layout.setContentsMargins(6, 6, 6, 6) self.details_layout.setSpacing(12) @@ -329,11 +329,11 @@ def retranslateUi(self, GameDetails): self.favorites_check.setText(_translate("GameDetails", "Favorites")) self.backlog_check.setText(_translate("GameDetails", "Backlog")) self.lbl_dev.setText(_translate("GameDetails", "Developer")) - self.lbl_app_name.setText(_translate("GameDetails", "Application Name")) + self.lbl_app_name.setText(_translate("GameDetails", "Application name")) self.lbl_version.setText(_translate("GameDetails", "Version")) - self.lbl_grade.setText(_translate("GameDetails", "ProtonDB Grade")) - self.lbl_install_size.setText(_translate("GameDetails", "Installation Size")) - self.lbl_install_path.setText(_translate("GameDetails", "Installation Path")) + self.lbl_grade.setText(_translate("GameDetails", "ProtonDB grade")) + self.lbl_install_size.setText(_translate("GameDetails", "Installation size")) + self.lbl_install_path.setText(_translate("GameDetails", "Installation path")) self.lbl_platform.setText(_translate("GameDetails", "Platform")) self.lbl_game_actions.setText(_translate("GameDetails", "Actions")) self.modify_button.setText(_translate("GameDetails", "Modify")) diff --git a/rare/ui/components/tabs/games/game_info/details.ui b/rare/ui/components/tabs/games/game_info/details.ui index 779bbac14..ce7f9ff09 100644 --- a/rare/ui/components/tabs/games/game_info/details.ui +++ b/rare/ui/components/tabs/games/game_info/details.ui @@ -92,7 +92,7 @@