Skip to content

Commit 782be1e

Browse files
baremetalgoCopilot
andcommitted
Preserve dark theme for existing projects
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 014d8aa commit 782be1e

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

interface/core/project_state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def _default_project_state(self) -> dict[str, Any]:
2323
return {
2424
"schema": "drunkenbot_ide_project",
2525
"version": 1,
26-
"theme": "system",
26+
"theme": "dark",
2727
"project_name": "",
2828
"project_dir": "",
2929
"paths": {

interface/core/project_state_apply.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def _apply_project_state(self, data: dict[str, Any]) -> None:
1515
data: Project state loaded from JSON.
1616
"""
1717

18-
self.set_theme(data.get("theme", "system"), persist=False)
18+
self.set_theme(data.get("theme", "dark"), persist=False)
1919
self.search_box.setText(str(data.get("project_name", "")))
2020
paths = data.get("paths", {})
2121
dataset = data.get("dataset", {})

interface/theme.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,24 @@
99

1010
SYSTEM_THEME = "system"
1111
DARK_THEME = "dark"
12+
DEFAULT_THEME = DARK_THEME
1213
_THEME_PROPERTY = "application_theme"
1314
_RECENT_PROJECTS_PATH = Path.home() / ".drunkenbot_ide" / "recent_projects.json"
1415

1516

1617
def normalize_theme(theme: object) -> str:
17-
"""Return a supported theme name, defaulting to the system theme."""
18-
return DARK_THEME if theme == DARK_THEME else SYSTEM_THEME
18+
"""Return a supported theme name, defaulting to the application's Dark theme."""
19+
return SYSTEM_THEME if theme == SYSTEM_THEME else DARK_THEME
1920

2021

2122
def load_startup_theme() -> str:
2223
"""Load the theme selected for the most recently opened project."""
2324
try:
2425
recent_projects = json.loads(_RECENT_PROJECTS_PATH.read_text(encoding="utf-8"))
2526
except (OSError, json.JSONDecodeError):
26-
return SYSTEM_THEME
27+
return DEFAULT_THEME
2728
if not isinstance(recent_projects, list):
28-
return SYSTEM_THEME
29+
return DEFAULT_THEME
2930
for entry in recent_projects:
3031
if not isinstance(entry, dict):
3132
continue
@@ -36,13 +37,13 @@ def load_startup_theme() -> str:
3637
continue
3738
if isinstance(project_state, dict):
3839
return normalize_theme(project_state.get("theme"))
39-
return SYSTEM_THEME
40+
return DEFAULT_THEME
4041

4142

4243
def current_theme() -> str:
4344
"""Return the QApplication theme currently in effect."""
4445
app = QApplication.instance()
45-
return normalize_theme(app.property(_THEME_PROPERTY) if app is not None else SYSTEM_THEME)
46+
return normalize_theme(app.property(_THEME_PROPERTY) if app is not None else DEFAULT_THEME)
4647

4748

4849
def apply_theme(theme: object) -> str:

0 commit comments

Comments
 (0)