Skip to content

GUI: add dark/light theme toggle (default dark) - #91

Merged
Anthony Sligar (sligara7) merged 2 commits into
NSLS2:mainfrom
sligara7:hex-gui-theme-toggle
Oct 6, 2026
Merged

Anthony Sligar (sligara7) merged 2 commits into
NSLS2:mainfrom
sligara7:hex-gui-theme-toggle

Conversation

@sligara7

@sligara7 Anthony Sligar (sligara7) commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Split the BNL stylesheet into a shared template plus dark and light surface palettes. A 'Dark mode' switch in the status bar restyles the app live; the choice is remembered per user via QSettings. Light mode uses teal instead of cerulean for accent text, for contrast on white. Every window's switch follows one application-wide theme-changed signal (gui/theme_switch.py), so multiple windows stay in step.

How it was verified: mock

  • pixi run -e gui-dev pytest tests/test_gui_theme.py: 6 passed, including test_every_switch_follows_a_theme_change (observed failing before the review fix).
  • Full window rendered offscreen with a local RunEngine in mock mode (HEXTOOLS_RUNNING_IN_CI=YES): both themes captured, and a two-window check confirms both switches follow one change.
  • Not tried on the TST or real beamline.

CI

The red checks match main's current baseline, measured with CI's own commands on main (60acf66) and this branch in the same env:

  • Unit tests: the same 9 failures on both (phantom, dclm, germ, radiography).
  • Lint: 418 on both.
  • Type check: 71 on main, 77 here. Every added diagnostic is an unresolved qtpy import, the same as 50 of main's 71: CI type-checks in the dev env, which has no GUI packages. For the same reason the Qt test in tests/test_gui_theme.py skips in CI.

Assisted-by: copilot:claude-opus-5-5

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Multiple open windows can display theme controls inconsistent with the application-wide theme.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds persistent dark/light GUI theming with live switching.

Changes:

  • Splits shared styling from theme-specific palettes.
  • Adds a status-bar theme toggle backed by QSettings.
  • Adds theme construction and persistence tests.
File Description
src/​hextools/​gui/​_theme.py Defines palettes, stylesheet generation, and persistence.
src/​hextools/​gui/​__main__.py Adds and initializes the theme toggle.
tests/​test_gui_theme.py Tests theme generation, application, and storage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/hextools/gui/__main__.py Outdated
Copilot AI balanced review requested due to automatic review settings October 5, 2026 21:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation is coherent, synchronized across windows, and adequately covered by focused tests.

Review effort: Balanced
Findings: None

Resolved since last review (1)

Split the BNL stylesheet into a shared template plus dark and light surface palettes. A 'Dark mode' switch in the status bar restyles the app live; the choice is remembered per user via QSettings. Light mode uses teal instead of cerulean for accent text, for contrast on white.

Assisted-by: copilot:claude-opus-4-8
Addresses PR 91 review. The stylesheet is application-wide but each window built its own checkbox, read the theme once, and heard nothing later, so with two windows the second showed the old theme (reproduced offscreen: theme=light, second switch still checked). QtThemeSwitch (gui/theme_switch.py) changes the theme through set_theme(), which emits one per-application signal every switch follows; Qt drops a closed window's connection. test_every_switch_follows_a_theme_change was observed failing before the fix.

Assisted-by: copilot:claude-opus-4-8
Copilot AI balanced review requested due to automatic review settings October 6, 2026 20:39
@sligara7
Anthony Sligar (sligara7) merged commit 198ea35 into NSLS2:main Oct 6, 2026
0 of 5 checks passed
@sligara7
Anthony Sligar (sligara7) deleted the hex-gui-theme-toggle branch October 6, 2026 20:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The Qt-dependent behavior tests are skipped by every current CI environment.

Review effort: Balanced
Findings: 1 Low severity

Open (1)

Comment thread tests/test_gui_theme.py

@pytest.fixture
def qt_app(monkeypatch, tmp_path):
pytest.importorskip("qtpy")
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.

2 participants