You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add a System / Light / Dark appearance choice - #47
Adds View > Appearance with System / Light / Dark, saved in QSettings (appearance, default system). Dark mode is something people have asked for, and on Qt 6 the native style can already draw a dark palette. The app only has to ask for it and fix the few widgets that hardcode light colours.
Context
@ascensionra wrote the original toggle on PySide2: a View > Dark Mode action, a Fusion + QSS dark theme, and the work to find and fix the widgets with hardcoded colours. Since then master has moved to PySide6 6.9 / Python 3.13. On Qt 6 the native Windows style follows the OS colour scheme, so on a dark desktop the toggle's "off" state was not light. @mogglemoss suggested the same move in review: use Qt's colour scheme instead of a hand-made stylesheet.
Approach
Master is merged into this branch rather than rebased onto it, so the contributor's commit stays unchanged. The maintainer's commits after it:
Asks Qt for the chosen scheme with QGuiApplication.styleHints().setColorScheme(...). "System" passes Unknown, which leaves the choice to the OS and follows a live OS switch. It uses the native style in both schemes rather than Fusion plus a dark stylesheet.
Keeps the contributor's per-widget fixes and has them follow the palette Qt actually draws (Window lightness), re-applied when the window's palette changes. The requested scheme isn't enough, because on Windows 10's default style a Dark request reports Dark but still draws light:
Priority spinboxes set only background-color, so text colour and disabled greying come from the palette. The light backgrounds still come from gui_main.ui; only the dark ones are defined in Python.
Status labels: OK and ERROR get colours that suit the scheme, and INFO uses the palette text colour.
Path table rows keep black text on their fixed pastel backgrounds.
Removes the inline color:#0000ff from the links in gui_main.ui, gui_tripwire.ui and gui_wanderer.ui (regenerated with the pinned uic), so links use the palette link colour. The [?] label's text is set again on a scheme change, because a rich-text label fixes its link colour when its text is set. An open Tripwire/Wanderer dialog keeps its old link colour through a live OS switch until it is reopened (they are modal, so only System + an OS switch can hit this).
Testing
Python 3.13 / PySide6 6.9.3: full suite passes (154 tests). New test_appearance.py covers reading the saved setting, that choosing Dark / System requests the matching colour scheme and saves it, that a dark palette darkens the spinboxes and a light one restores the .ui background, that a Dark request the style can't draw keeps the light colours, that a dark palette already present at start-up is applied without a palette event, and that OK / ERROR / INFO status messages already shown recolour on each light/dark switch with their text unchanged. Each test was checked to fail when its code is removed.
Screenshots on the real Windows platform (main window, Tripwire and Wanderer dialogs, Light and Dark, plus Dark with Security/Avoidance unchecked to show disabled greying, plus Dark under -style windowsvista) were checked for readability. Every option was checked with both the windows11 and windowsvista styles.
Manual checks
View > Appearance > Dark / Light switch the window immediately, and the choice survives a restart
System follows a live Windows light/dark switch
Priority spinboxes are readable in both schemes, and greyed out when Security prioritization is unchecked
Path results, OK/ERROR messages and the [?] / dialog links are readable in both schemes
Windows 10: Dark does nothing and everything stays readable
macOS: same checks
Risks
Low. Pathfinding and networking are unchanged. On Windows 10 the native style can't draw dark, so Dark there keeps the light look; the app's own colours follow what is drawn, so nothing becomes unreadable.
On Linux without a theme plugin, as on Windows 10's windowsvista, Dark/Light may not change the look, but nothing becomes unreadable.
Short Circuit only ever rendered with the OS's light/native widget
style. Several widgets also hardcode light-theme-only colors (status
message text, the four security-priority spinbox backgrounds, and the
path-table row highlighting), so simply applying a dark QApplication
stylesheet on top would leave those specific widgets unreadable
(e.g. black status text on a dark background).
This adds a View > Dark Mode checkable menu action that applies a
QSS dark theme app-wide, persisted via QSettings like the other
preferences. On Windows, Qt style sheets don't fully restyle some
native-style controls (combo box/spin box arrows, checkboxes), so
enabling dark mode also switches the base QStyle to Fusion, which is
stylesheet-driven, and restores the original style when toggled off.
The hardcoded-color widgets are made theme-aware individually rather
than through the global stylesheet: a widget's own setStyleSheet()
call takes precedence over an ancestor/application stylesheet for the
same widget in Qt's cascade, regardless of selector specificity, so
the four priority spinboxes (whose colors are set directly in the
generated gui_main.py from the .ui file) needed explicit light/dark
variants rather than relying on inheritance. The path-table row colors
are intentionally fixed light pastels for security-class coding in
both themes, so their text is now pinned to black instead of
inheriting the theme's (light) default foreground color.
Thanks for this. The write-up is great, and handling the three hard-coded-color widgets individually (rather than hoping the global stylesheet wins) is the right call. I've been doing light/dark work on my fork, so a few notes in case they're useful:
Needs a small rebase for PySide6. This was opened against the PySide2 code, and master moved to PySide6 a week later (#48). GitHub still says "mergeable" because there's no text conflict, but two lines would fail on current master:
view/theme.py: from PySide2 import QtWidgets → from PySide6 import QtWidgets (master no longer has PySide2 at all).
app.py: QtWidgets.QAction("&Dark Mode", self) → QtGui.QAction("&Dark Mode", self). In Qt 6, QAction moved from QtWidgets to QtGui.
(I checked this against master's dependencies and the PySide6 API rather than by running the branch, so worth a quick launch after the rebase.)
Following the OS is now cheap. On the trade-off you mention, not auto-following the system setting: Qt 6 exposes it directly. QGuiApplication.styleHints().colorScheme() returns Dark/Light/Unknown, and colorSchemeChanged fires when the user flips it. So a three-way View › Appearance (Auto / Light / Dark) is a small addition, if you want it now or later.
Contrast numbers, in case they help. The dark palette reads well: body text is 10.3:1, and the dark OK/error status colors are 7.0:1 and 4.7:1. Two optional nits:
Disabled button text (#777777 on #3a3a3a) is 2.5:1. WCAG exempts disabled controls, so it's a judgment call, but something like #8d94a1 reads noticeably better while still looking off.
The light-mode status colors this PR keeps (green, red) are 4.4:1 and 3.4:1 on the default light window, a little under the usual 4.5:1. That predates this PR, but since _label_message is being touched anyway, something like #276b2b / #c62828 would bring both above it.
Nice work. Happy to test the rebased branch on macOS if that's useful.
Master moved to PySide6 and gained the Wanderer mapper since this
branch was cut; merging (rather than rebasing) keeps the contributor's
commit intact on their fork. The only conflict was the view imports in
app.py, where both sides' imports are kept.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On Qt 6 the native Windows style already follows the OS colour scheme,
so the original toggle's "off" state was not light on a dark desktop,
and its Fusion + QSS theme fought the native look instead of reusing
it. Asking Qt for a colour scheme (styleHints().setColorScheme) keeps
the native style in both schemes and lets "System" track the OS live.
mogglemoss suggested the same direction on the PR.
What still needs per-widget help is only what hardcodes colours: the
priority spinboxes get dark backgrounds (their light ones stay owned
by gui_main.ui, restored from what setupUi set), the OK/ERROR status
labels pick scheme-appropriate colours while INFO text falls back to
the palette, and the .ui links drop their inline #0000ff so they use
the palette link colour. The [?] link label is re-set on a scheme
change because a rich-text label bakes its link colour at setText.
The qapp fixture moves to conftest.py so the new tests can share it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
secondfry
changed the title
Add a dark mode toggle
Add a System / Light / Dark appearance choice
Nov 23, 2026
On Windows 10 Qt's default style is windowsvista, which cannot draw
dark: asking for Dark makes colorScheme() report Dark while the palette
stays light. Keying the spinbox and status colours off colorScheme()
gave a light window with dark spinbox backgrounds and pale status text.
Judging by the palette's Window lightness keeps them matched to what is
actually drawn, so Dark there simply leaves the light look.
The colours are re-applied on the window's PaletteChange rather than
colorSchemeChanged, because the palette is what they now depend on and
the window only sees PaletteChange once the new palette is in place.
(ApplicationPaletteChange never reaches changeEvent.)
Test upkeep from review: the QSettings helper moves into conftest.py
next to qapp, the appearance fixture restores the global QSettings path
and app palette it changes, and the appearance block no longer splits
the wormhole-size helpers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Native platform validation remains outstanding because offscreen tests synthesize palette events, leaving live System-mode switching, macOS behavior, and readability during real OS scheme changes unverified.
No open issues 🎉
What changed in this PR
Adds a persistent View > Appearance > System / Light / Dark choice to Short Circuit using Qt’s native colour schemes, with widget colours adjusted to the palette actually displayed.
Changes:
Saves the appearance preference in QSettings and updates custom colours when the palette changes.
Improves readability of priority spinboxes, status messages, route rows, and help links.
Adds appearance tests and shared headless Qt/settings fixtures.
File
Description
src/shortcircuit/view/gui_wanderer.py
Regenerates the Wanderer help link without a fixed blue colour.
src/shortcircuit/view/gui_tripwire.py
Regenerates the Tripwire link using the pinned UI compiler.
src/shortcircuit/view/gui_main.py
Regenerates the security help link without a fixed colour.
src/shortcircuit/model/test_generated_ui.py
Uses the shared Qt application fixture.
src/shortcircuit/model/test_appearance.py
Tests appearance settings, scheme requests, and palette-dependent backgrounds.
src/shortcircuit/model/test_app_settings.py
Uses the shared settings fixture.
src/shortcircuit/model/conftest.py
Provides shared headless Qt and temporary settings fixtures.
src/shortcircuit/app.py
Adds appearance controls, persistence, and palette-aware widget styling.
The palette test sent PaletteChange by hand on the belief that offscreen
setPalette skips it. It does not: the event is posted, so the test now
lets it arrive and fails if changeEvent stops re-applying colours. The
direct _apply_scheme_colors() call in set_appearance had no test at all;
it is what colours the UI under System on an already-dark OS, where no
palette change ever comes, so that case now has one.
The annotations and the split line bring app.py in line with the typed
attributes around it and with the 80-column limit in .style.yapf.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The appearance tests cover only spinbox styles, leaving existing status-message colours and text preservation across light/dark palette switches without regression coverage.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Add palette-switch regression coverage for status message colors
src/shortcircuit/app.py:626
The appearance tests only inspect spinbox styles, so deleting this loop would leave them passing while existing OK/ERROR messages retain their old colours after a palette switch. Add regression coverage that displays status messages before switching light → dark → light, then checks both their colours and unchanged text; include INFO to verify that it returns to the palette text colour.
Copilot noted the appearance tests only looked at spinbox styles, so the
loop in _apply_scheme_colors that re-applies stored label states could be
deleted with every test still green, leaving OK/ERROR messages in their
old colours after a light/dark switch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude Code: re Copilot's review — coverage for existing OK/ERROR/INFO status messages recolouring (and keeping their text) across light → dark → light palette switches was added in c82c6b9 (test_status_messages_recolour_on_palette_switch); it fails when the _label_states loop in _apply_scheme_colors is removed.
…he fork's
Upstream added View > Appearance (System / Light / Dark), asking Qt for a
colour scheme and recolouring a few widgets by hand. The fork already has
its own Appearance menu (Auto / Light / Dark plus brand packs) on its
token-based theme, so the fork's wins where the two overlap:
- app.py: the fork's. Upstream's appearance code (APPEARANCE_KEY,
set_appearance, _apply_scheme_colors) lives in its own window code,
which the fork replaces.
- test_appearance.py: dropped. It tests that upstream code; the fork's
theme is covered by test_theme.py.
- Upstream's motivating bug, Qt 6's native Windows style drawing dark on a
dark desktop whatever the app wants, doesn't arise here: the fork sets
the Fusion style and its own palette (theme.install).
Taken from secondfry#47 because it helps the fork too:
- gui_main/gui_tripwire/gui_wanderer .ui and views drop the hard-coded
link colour #0000ff, so links follow the palette. Rendered in the
fork's themes: #00aaff on dark, #0a72c2 on light, both legible; the
old blue was close to invisible on dark.
- conftest.py shares the qapp and make_settings fixtures, and
test_app_settings uses them.
262 tests pass; the generated views match their .ui sources.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The PKCE login keeps the refresh token in memory only, so every launch
of Short Circuit requires a full browser round trip to EVE SSO even
though CCP hands us a long-lived refresh token precisely so clients can
resume sessions. For a tool people open at the start of every play
session, that is the single most repeated piece of friction in the app.
The refresh token is functionally a password — anyone holding it can
act as the character within the granted scopes — so it goes in the OS
keychain (macOS Keychain, Windows Credential Manager, Linux Secret
Service) via the keyring library, never a plaintext file. The only
thing written to disk is the last-used character_id, which is public
information (killboards, ESI URLs), stored under appdirs user_data_dir
without version scoping so the session survives app upgrades. If no
keyring backend exists (headless Linux without Secret Service), we
degrade to exactly the old behaviour: re-auth each session, nothing
secret ever on disk in the clear.
Startup now calls try_silent_login() in a background thread: it loads
the persisted token, exchanges it for a fresh access token, decodes the
character from the JWT, and fires login_response exactly like an
interactive login, so the UI needs no new states.
Two behaviours worth calling out:
- CCP rotates the refresh token on every successful refresh and the old
value is single-use, so the rotated token is persisted on every
refresh, not just at login. Skipping this bricks the next silent
login with invalid_grant.
- Any refresh failure (rejected token, network error, undecodable JWT)
logs out AND purges the persisted session. Purging on network blips
is deliberately conservative: it trades an occasional extra re-auth
for never looping on a dead token at startup and never showing a
"connected" UI backed by an expired access token. The network-error
handling also fixes a pre-existing crash: an offline refresh
previously raised ConnectionError and silently killed the timer
thread, leaving the UI claiming to be logged in.
Explicit Logout also purges, so logging out now means staying logged
out across restarts.
Tests fake the keyring module and the char_id meta path — they never
touch the real OS keychain, which can prompt interactively on macOS.
The appearance tests (secondfry#47) build the real MainWindow, which now starts
a silent login. Left alone they would read the developer's keychain and
spend their single-use refresh token, or, without keyring, delete the
saved character id. The window fixture stubs the silent login.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds View > Appearance with System / Light / Dark, saved in
QSettings(appearance, defaultsystem). Dark mode is something people have asked for, and on Qt 6 the native style can already draw a dark palette. The app only has to ask for it and fix the few widgets that hardcode light colours.Context
@ascensionra wrote the original toggle on PySide2: a View > Dark Mode action, a Fusion + QSS dark theme, and the work to find and fix the widgets with hardcoded colours. Since then master has moved to PySide6 6.9 / Python 3.13. On Qt 6 the native Windows style follows the OS colour scheme, so on a dark desktop the toggle's "off" state was not light. @mogglemoss suggested the same move in review: use Qt's colour scheme instead of a hand-made stylesheet.
Approach
Master is merged into this branch rather than rebased onto it, so the contributor's commit stays unchanged. The maintainer's commits after it:
QGuiApplication.styleHints().setColorScheme(...). "System" passesUnknown, which leaves the choice to the OS and follows a live OS switch. It uses the native style in both schemes rather than Fusion plus a dark stylesheet.background-color, so text colour and disabled greying come from the palette. The light backgrounds still come fromgui_main.ui; only the dark ones are defined in Python.color:#0000fffrom the links ingui_main.ui,gui_tripwire.uiandgui_wanderer.ui(regenerated with the pinned uic), so links use the palette link colour. The[?]label's text is set again on a scheme change, because a rich-text label fixes its link colour when its text is set. An open Tripwire/Wanderer dialog keeps its old link colour through a live OS switch until it is reopened (they are modal, so only System + an OS switch can hit this).Testing
test_appearance.pycovers reading the saved setting, that choosing Dark / System requests the matching colour scheme and saves it, that a dark palette darkens the spinboxes and a light one restores the.uibackground, that a Dark request the style can't draw keeps the light colours, that a dark palette already present at start-up is applied without a palette event, and that OK / ERROR / INFO status messages already shown recolour on each light/dark switch with their text unchanged. Each test was checked to fail when its code is removed.-style windowsvista) were checked for readability. Every option was checked with both the windows11 and windowsvista styles.Manual checks
[?]/ dialog links are readable in both schemesRisks
Low. Pathfinding and networking are unchanged. On Windows 10 the native style can't draw dark, so Dark there keeps the light look; the app's own colours follow what is drawn, so nothing becomes unreadable.
On Linux without a theme plugin, as on Windows 10's windowsvista, Dark/Light may not change the look, but nothing becomes unreadable.
🤖 Generated with Claude Code