Skip to content

feat!: theme config system refactor - #4

Merged
BugCodeX merged 9 commits into
masterfrom
theme-config-system-refactor
Aug 13, 2026
Merged

BugCodeX merged 9 commits into
masterfrom
theme-config-system-refactor

Conversation

@BugCodeX

Copy link
Copy Markdown
Owner

Summary

Replace the stateless apply_theme() API with a persistent three-concept configuration system inspired by PyQt-Fluent-Widgets:

  • Theme mode: setThemeMode, toggleThemeMode, themeMode, isDarkTheme
  • Color theme: setTheme, getTheme
  • Additional stylesheet: setStyleSheet, getStyleSheet

Add a manual SystemThemeListener for OS theme reactivity and a qsettings singleton (QtShadcnSettings) with ConfigItem descriptors and atomic per-file persistence under QStandardPaths.AppDataLocation/config/.

Breaking Changes

apply_theme() and get_theme() are removed entirely. The old cache system (qtshadcn/common/cache.py) and theme_mode.py are deleted.

Migration

# Before (removed)
from qtshadcn import apply_theme
apply_theme(app, "themes/default.xml", theme_mode="dark", additional_qss="custom.qss")

# After
from qtshadcn import qsettings, setThemeMode, setTheme, setStyleSheet
qsettings.load()
setThemeMode("dark", save=True)
setTheme("themes/default.xml", save=True)
setStyleSheet("custom.qss", save=True)

What's New

  • qtshadcn/common/config.py — QtShadcnSettings, ConfigItem, ThemeMode, qsettings
  • qtshadcn/common/stylesheet.py — global stylesheet rendering + 3-concept API
  • qtshadcn/common/theme_watcher.py — manual SystemThemeListener(QThread)
  • Direct imports in qtshadcn/__init__.py (no __getattr__) for better DX
  • JSON primary palette source with XML fallback
  • Gallery, basic example, generator example, docs, and CI updated

Verification

  • make test: 145 passed
  • make lint: clean
  • make type-check: clean

Commits

  • feat: add persistent config system with qsettings singleton
  • feat: add 3-concept stylesheet API with rendering pipeline
  • feat: add SystemThemeListener for OS theme reactivity
  • feat!: remove apply_theme/get_theme and cache.py
  • feat: export new public API and migrate examples/docs

Add QtShadcnSettings, ConfigItem, ThemeMode enum, and atomic
per-file persistence under QStandardPaths.AppDataLocation/config/.
Add setThemeMode, setTheme, setStyleSheet, getTheme, getStyleSheet,
and global QSS rendering pipeline. Mode resolution moves here from
the deleted theme_mode.py.
Manual QThread listener with darkdetect on Windows and polling
fallback on macOS/Linux. Emits themeChanged signal on OS theme
change.
BREAKING CHANGE: apply_theme() and get_theme() are removed entirely.
Migrate to qsettings.load(), setThemeMode(), setTheme(),
setStyleSheet(), and getTheme(). Remove obsolete theme_mode.py and
cache.py.
Replace __getattr__ with direct imports for DX. Update gallery,
basic example, generator example, docs, CI, and issue templates to
the new three-concept API.
toggleThemeMode now cycles auto -> light -> dark -> auto regardless of
OS detection. Apply ruff format to generator example and watcher tests.
test_set_xml_theme now sets ThemeMode.LIGHT before asserting light
tokens, making it independent of OS theme detection or leftover state.
@BugCodeX
BugCodeX enabled auto-merge August 13, 2026 01:25
PySide2 is not stable on Python 3.12 and crashes with exit code 139
(SIGSEGV). Run it on 3.11 instead.
Remove pyside2 from the binding matrix because pytest-qt does not
support it and it crashes on CI. Expand pyside6 and pyqt6 to run on
ubuntu-latest and windows-latest with Python 3.11, 3.12, and 3.13.
@BugCodeX
BugCodeX disabled auto-merge August 13, 2026 02:25
@BugCodeX
BugCodeX merged commit d837262 into master Aug 13, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant