From d3ec0398b41e750de7358c6a23ceee66d2917fb4 Mon Sep 17 00:00:00 2001 From: Robert Honz Date: Tue, 21 Oct 2025 07:58:00 +0200 Subject: fix(gui): 🐛 integrate `ansi2html` for improved log message formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added `Ansi2HTMLConverter` to convert ANSI color codes in log messages to HTML. * Updated the `MainWindow` class to utilize the new converter for displaying logs. * Removed dependency on `coloredlogs.converter` for log message display. --- tidal_dl_ng/gui.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'tidal_dl_ng/gui.py') diff --git a/tidal_dl_ng/gui.py b/tidal_dl_ng/gui.py index d0ee637..9ffc444 100644 --- a/tidal_dl_ng/gui.py +++ b/tidal_dl_ng/gui.py @@ -89,7 +89,8 @@ except ImportError as e: print("Qt dependencies missing. Cannot start GUI. Please read the 'README.md' carefully.") sys.exit(1) -import coloredlogs.converter + +from ansi2html import Ansi2HTMLConverter from rich.progress import Progress from tidalapi import Album, Mix, Playlist, Quality, Track, UserPlaylist, Video from tidalapi.artist import Artist @@ -143,6 +144,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): s_queue_download_item_finished: QtCore.Signal = QtCore.Signal(object) s_queue_download_item_failed: QtCore.Signal = QtCore.Signal(object) s_queue_download_item_skipped: QtCore.Signal = QtCore.Signal(object) + converter_ansi_html: Ansi2HTMLConverter def __init__(self, tidal: Tidal | None = None) -> None: """Initialize the main window and all components. @@ -187,6 +189,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.settings.data.window_h, ) self.spinners: dict[QtWidgets.QWidget, QtWaitingSpinner] = {} + self.converter_ansi_html: Ansi2HTMLConverter = Ansi2HTMLConverter() def init_tidal(self, tidal: Tidal | None = None): """Initialize Tidal session and handle login flow. @@ -297,12 +300,11 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): Args: text (str): Log message. """ - display_msg = coloredlogs.converter.convert(text) - cursor: QtGui.QTextCursor = self.te_debug.textCursor() - cursor.movePosition(QtGui.QTextCursor.End) - cursor.insertHtml(display_msg) + html = self.converter_ansi_html.convert(text) + cursor.movePosition(QtGui.QTextCursor.End) + cursor.insertHtml(html) self.te_debug.setTextCursor(cursor) self.te_debug.ensureCursorVisible() -- cgit v1.3.1