From 7883b8865b1cf46368a0a60e633748e3c89cfaff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deniz=20=C5=9Eafak?= Date: Mon, 27 Oct 2025 17:43:54 +0300 Subject: [PATCH] Fixed light theme slider colors in voice mixer --- CHANGELOG.md | 1 + abogen/voice_formula_gui.py | 58 ++++++++++++++++++++++++++++--------- 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94691bd..d084ec1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Added tooltip indicators in queue manager to display book handler options (`Save chapters separately` and `Merge chapters at the end`) for queued items. - Added `Open processed file` and `Open input file` options for items in the queue manager, instead of just `Open file` option. - Added loading gif animation to book handler window. +- Fixed light theme slider colors in voice mixer for better visibility (for non-Windows users). - Fixed subtitle word-count splitting logic for more accurate segmentation. # 1.2.0 diff --git a/abogen/voice_formula_gui.py b/abogen/voice_formula_gui.py index 33cc2b0..73fa167 100644 --- a/abogen/voice_formula_gui.py +++ b/abogen/voice_formula_gui.py @@ -242,20 +242,8 @@ class VoiceMixer(QWidget): ) self.slider.setFixedWidth(SLIDER_WIDTH) - # Fix slider in Windows - if platform.system() == "Windows": - appstyle = QApplication.instance().style().objectName().lower() - if appstyle != "windowsvista": - # Set custom groove color for disabled state using COLORS["GREY_BACKGROUND"] - self.slider.setStyleSheet( - f""" - QSlider::groove:vertical:disabled {{ - background: {COLORS.get("GREY_BACKGROUND")}; - width: 4px; - border-radius: 4px; - }} - """ - ) + # Apply slider styling after widget is added to window (see showEvent) + self._slider_style_applied = False # Connect controls self.slider.valueChanged.connect(lambda val: self.spin_box.setValue(val / 100)) @@ -285,6 +273,48 @@ class VoiceMixer(QWidget): self.setLayout(layout) self.toggle_inputs() + def showEvent(self, event): + super().showEvent(event) + # Apply slider styling once when widget is shown and has access to parent + if not self._slider_style_applied: + self._slider_style_applied = True + + # Fix slider in Windows + if platform.system() == "Windows": + appstyle = QApplication.instance().style().objectName().lower() + if appstyle != "windowsvista": + # Set custom groove color for disabled state using COLORS["GREY_BACKGROUND"] + self.slider.setStyleSheet( + f""" + QSlider::groove:vertical:disabled {{ + background: {COLORS.get("GREY_BACKGROUND")}; + width: 4px; + border-radius: 4px; + }} + """ + ) + else: + # Apply same fix for Light theme on non-Windows systems + # Get theme from parent window's config + parent_window = self.window() + theme = "system" + while parent_window: + if hasattr(parent_window, "config"): + theme = parent_window.config.get("theme", "system") + break + parent_window = parent_window.parent() + + if theme == "light": + self.slider.setStyleSheet( + f""" + QSlider::groove:vertical:disabled {{ + background: {COLORS.get("GREY_BACKGROUND")}; + width: 4px; + border-radius: 4px; + }} + """ + ) + def toggle_inputs(self): is_enabled = self.checkbox.isChecked() self.spin_box.setEnabled(is_enabled)