[PATCH 2 of 8 DarkThemeSeries 2] cmdui, docklog: apply dark theme to console and log widgets

29 views
Skip to first unread message

Peter Demcak

unread,
Mar 6, 2026, 2:42:48 PM (4 days ago) Mar 6
to thg...@googlegroups.com
# HG changeset patch
# User Peter Demcak <majs...@gmail.com>
# Date 1772737138 -3600
# Thu Mar 05 19:58:58 2026 +0100
# Node ID 14c976e0c44030e3eb9c560d0428411a07888a3d
# Parent 4ff067cd6020d6635b8237f57912512d9feb0482
cmdui, docklog: apply dark theme to console and log widgets

Add _apply_dark_console_markers() in cmdui.LogWidget to override
error/warning/control marker colors.
Apply THEME colors to docklog console Scintilla paper, text, selection, caret,
prompt marker.

diff -r 4ff067cd6020 -r 14c976e0c440 tortoisehg/hgqt/cmdui.py
--- a/tortoisehg/hgqt/cmdui.py Thu Mar 05 19:58:41 2026 +0100
+++ b/tortoisehg/hgqt/cmdui.py Thu Mar 05 19:58:58 2026 +0100
@@ -52,6 +52,8 @@
qscilib,
)

+from .theme import THEME
+

def startProgress(topic, status):
topic, item, pos, total, unit = topic, '...', status, None, ''
@@ -229,6 +231,10 @@
self.setWrapMode(QsciScintilla.WrapMode.WrapCharacter)
self._initfont()
self._initmarkers()
+
+ if THEME.enabled:
+ self._apply_dark_console_markers()
+
qscilib.unbindConflictedKeys(self)

def _initfont(self):
@@ -250,6 +256,12 @@
# NOTE: self.setMarkerForegroundColor() doesn't take effect,
# because it's a *Background* marker.

+ def _apply_dark_console_markers(self):
+ self.setMarkerBackgroundColor(THEME.ui_error, self._markers.get('ui.error'))
+ self.setMarkerBackgroundColor(THEME.ui_warning, self._markers.get('ui.warning'))
+ self.setMarkerBackgroundColor(THEME.ui_control, self._markers.get('control'))
+
+
@pyqtSlot(str, str)
def appendLog(self, msg: str, label: str):
"""Append log text to the last line; scrolls down to there"""
diff -r 4ff067cd6020 -r 14c976e0c440 tortoisehg/hgqt/docklog.py
--- a/tortoisehg/hgqt/docklog.py Thu Mar 05 19:58:41 2026 +0100
+++ b/tortoisehg/hgqt/docklog.py Thu Mar 05 19:58:58 2026 +0100
@@ -45,6 +45,8 @@
qtlib,
)

+from .theme import THEME
+
class _LogWidgetForConsole(cmdui.LogWidget):
"""Wrapped LogWidget for ConsoleWidget"""

@@ -57,8 +59,52 @@

def __init__(self, parent=None):
super().__init__(parent)
- self._prompt_marker = self.markerDefine(QsciScintilla.MarkerSymbol.Background)
- self.setMarkerBackgroundColor(QColor('#e8f3fe'), self._prompt_marker)
+
+ if THEME.enabled:
+ # Override light 'control' marker from cmdui.LogWidget
+ if hasattr(self, '_markers') and 'control' in self._markers:
+ self.setMarkerBackgroundColor(THEME.background, self._markers['control'])
+ # Make sure the existing 'control' marker used by _setmarker(..., 'control')
+ # has dark background.
+ m = None
+ for attr in ('_markers', '_markerids', '_markermap'):
+ d = getattr(self, attr, None)
+ if isinstance(d, dict) and 'control' in d:
+ m = d['control']
+ break
+ if m is not None:
+ self.setMarkerBackgroundColor(THEME.background, m)
+
+ control_marker = self.markerDefine(QsciScintilla.MarkerSymbol.Background)
+ self.setMarkerBackgroundColor(THEME.background, control_marker)
+
+ # LogWidget-specific styles (used by appendLog labels)
+ for style in (
+ QsciScintilla.STYLE_LINENUMBER,
+ QsciScintilla.STYLE_BRACELIGHT,
+ QsciScintilla.STYLE_BRACEBAD,
+ QsciScintilla.STYLE_CONTROLCHAR,
+ QsciScintilla.STYLE_INDENTGUIDE,
+ ):
+ self.SendScintilla(QsciScintilla.SCI_STYLESETBACK, style, THEME.background)
+ self.SendScintilla(QsciScintilla.SCI_STYLESETFORE, style, THEME.text)
+
+ # Basic widget colors
+ self.setPaper(THEME.background)
+ self.setColor(THEME.text)
+ self.setSelectionBackgroundColor(THEME.selection_background)
+ self.setSelectionForegroundColor(THEME.selection_text)
+ self.setCaretForegroundColor(THEME.caret_foreground)
+
+ # Prompt line marker background (was light blue)
+ # We'll set it after marker is created (see below)
+ self._prompt_marker = self.markerDefine(QsciScintilla.MarkerSymbol.Background)
+ self.setMarkerBackgroundColor(THEME.backgroundLighter, self._prompt_marker)
+ else:
+ self._prompt_marker = self.markerDefine(QsciScintilla.MarkerSymbol.Background)
+ self.setMarkerBackgroundColor(QColor('#e8f3fe'), self._prompt_marker)
+
+
self.cursorPositionChanged.connect(self._updatePrompt)
# ensure not moving prompt line even if completion list get shorter,
# by allowing to scroll one page below the last line

Yuya Nishihara

unread,
Mar 7, 2026, 5:46:49 AM (3 days ago) Mar 7
to Peter Demcak, thg...@googlegroups.com
On Fri, 06 Mar 2026 20:38:11 +0100, Peter Demcak wrote:
> # HG changeset patch
> # User Peter Demcak <majs...@gmail.com>
> # Date 1772737138 -3600
> # Thu Mar 05 19:58:58 2026 +0100
> # Node ID 14c976e0c44030e3eb9c560d0428411a07888a3d
> # Parent 4ff067cd6020d6635b8237f57912512d9feb0482
> cmdui, docklog: apply dark theme to console and log widgets

> +from .theme import THEME

This "theme" module doesn't exist. Maybe you missed some preceding
patches?

I'm not sure what this theme.THEME would achieve, but I think you can
use qtlib.isDarkTheme() to test if dark theme should be used. On Qt6,
maybe we can forward this function to
QGuiApplication::styleHints().colorScheme().

https://doc.qt.io/qt-6/qguiapplication.html#styleHints

Peter Demcak

unread,
Mar 7, 2026, 1:26:20 PM (3 days ago) Mar 7
to TortoiseHg Developers

Hi,

Yes, Series 1 patches need to be reviewed first.

I sent Series 1, including a cover letter and the first 8 commits, but it did not appear on the thg-dev group:
https://groups.google.com/g/thg-dev

It may have been caught by a spam filter or held for moderation.

The next day, I sent Series 2 with the next 8 commits, and those emails did appear.

On the third day, I resent Series 1 unchanged, but it still did not appear.

One of the patches includes a new file with about 800 lines of code, so perhaps that, or the cover letter, caused the problem.

Should I resend those first 8 patches without the cover letter?

Thank you.


Here is the original cover letter:

This patch series introduces dark theme support for TortoiseHg, including six built-in dark themes and support for custom user-defined themes.

The original project and older screenshots are available here:
https://github.com/majster64/tortoisehg-dark-themes

Scope:

- 24 commits in 3 patch series (to be emailed over 3 days)
- 34 modified files, 1 new file
- ~1700 lines of code added

Tested on Windows 10/11 and Ubuntu 22.04 with both PyQt5 and PyQt6.
The code path remains unchanged when the dark theme is not enabled via Settings / Workbench / Theme.
Dark theme is applied to all windows and widgets.
No known bugs.

Reply all
Reply to author
Forward
0 new messages