Skip to content

Commit fd1bbf6

Browse files
committed
feat(theme): add theme selector and gauge colors
Add theme dropdown to General preferences (System Default, Pyfa Dark, Light). Prompt user to restart when theme changes. Apply Colors.gaugeBackground() to PyGauge and AttributeGauge.
1 parent d5f58e0 commit fd1bbf6

File tree

3 files changed

+49
-6
lines changed

3 files changed

+49
-6
lines changed

gui/attribute_gauge.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import wx
44

55
from gui.utils import anim_effects
6+
from gui.utils.colors import Colors
67

78

89
# todo: clean class up. Took from pyfa gauge, has a bunch of extra shit we don't need
@@ -50,7 +51,7 @@ def __init__(
5051
self._old_percentage = 0
5152
self._show_remaining = False
5253

53-
self.SetBackgroundColour(wx.Colour(51, 51, 51))
54+
self.SetBackgroundColour(Colors.gaugeBackground())
5455

5556
self._tooltip = wx.ToolTip("0.00/100.00")
5657
self.SetToolTip(self._tooltip)
@@ -169,10 +170,10 @@ def OnPaint(self, event):
169170
dc = wx.AutoBufferedPaintDC(self)
170171
rect = self.GetClientRect()
171172

172-
dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
173+
dc.SetBackground(wx.Brush(Colors.gaugeBackground()))
173174
dc.Clear()
174175

175-
colour = self.GetBackgroundColour()
176+
colour = Colors.gaugeBackground()
176177

177178
dc.SetBrush(wx.Brush(colour))
178179
dc.SetPen(wx.Pen(colour))

gui/builtinPreferenceViews/pyfaGeneralPreferences.py

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
import gui.mainFrame
66
from gui.bitmap_loader import BitmapLoader
77
from gui.preferenceView import PreferenceView
8+
from gui.utils.colors import Colors
89
from service.fit import Fit
9-
from service.settings import SettingsProvider, LocaleSettings
10+
from service.settings import SettingsProvider, LocaleSettings, ThemeSettings
1011
import eos.config
1112
import wx.lib.agw.hyperlink as hl
1213

@@ -54,6 +55,7 @@ def langDisplay(langInfo):
5455
return langInfo.Description + progress_display
5556

5657
self.chLang = wx.Choice(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [langDisplay(x) for x in self.langChoices], 0)
58+
Colors.styleInput(self.chLang)
5759
self.chLang.Bind(wx.EVT_CHOICE, self.onLangSelection)
5860

5961
selectedIndex = self.langChoices.index(next((x for x in self.langChoices if x.CanonicalName == self.localeSettings.get('locale')), None))
@@ -72,7 +74,6 @@ def langDisplay(langInfo):
7274
langBox.Add(langSizer)
7375

7476
eosLangSizer = wx.BoxSizer(wx.HORIZONTAL)
75-
7677
self.stEosLangLabel = wx.StaticText(panel, wx.ID_ANY, _t("EVE Data:"), wx.DefaultPosition, wx.DefaultSize, 0)
7778
self.stEosLangLabel.Wrap(-1)
7879
eosLangSizer.Add(self.stEosLangLabel, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
@@ -81,6 +82,7 @@ def langDisplay(langInfo):
8182
sorted([(wx.Locale.FindLanguageInfo(x).Description, x) for x in eos.config.translation_mapping.keys()], key=lambda x: x[0])
8283

8384
self.chEosLang = wx.Choice(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, [x[0] for x in self.eosLangChoices], 0)
85+
Colors.styleInput(self.chEosLang)
8486
self.chEosLang.Bind(wx.EVT_CHOICE, self.onEosLangSelection)
8587

8688
selectedIndex = self.eosLangChoices.index(
@@ -95,6 +97,24 @@ def langDisplay(langInfo):
9597
wx.DefaultPosition,
9698
wx.DefaultSize, 0), 0, wx.LEFT, 15)
9799

100+
self.themeSettings = ThemeSettings.getInstance()
101+
themeBox = wx.StaticBoxSizer(wx.VERTICAL, panel, _t("Theme (requires restart)"))
102+
mainSizer.Add(themeBox, 0, wx.EXPAND | wx.TOP | wx.RIGHT | wx.BOTTOM, 10)
103+
104+
themeSizer = wx.BoxSizer(wx.HORIZONTAL)
105+
self.stThemeLabel = wx.StaticText(panel, wx.ID_ANY, _t("Appearance:"), wx.DefaultPosition, wx.DefaultSize, 0)
106+
self.stThemeLabel.Wrap(-1)
107+
themeSizer.Add(self.stThemeLabel, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
108+
109+
self.themeChoices = [_t("System Default"), _t("Pyfa Dark"), _t("Light")]
110+
self.chTheme = wx.Choice(panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, self.themeChoices, 0)
111+
Colors.styleInput(self.chTheme)
112+
self.chTheme.SetSelection(self.themeSettings.get('theme_mode'))
113+
self.chTheme.Bind(wx.EVT_CHOICE, self.onThemeSelection)
114+
themeSizer.Add(self.chTheme, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
115+
116+
themeBox.Add(themeSizer)
117+
98118
self.cbGlobalChar = wx.CheckBox(panel, wx.ID_ANY, _t("Use global character"), wx.DefaultPosition, wx.DefaultSize,
99119
0)
100120
mainSizer.Add(self.cbGlobalChar, 0, wx.ALL | wx.EXPAND, 5)
@@ -210,6 +230,27 @@ def onEosLangSelection(self, event):
210230
locale = self.eosLangChoices[selection]
211231
self.localeSettings.set('eos_locale', locale[1])
212232

233+
def onThemeSelection(self, event):
234+
selection = self.chTheme.GetSelection()
235+
self.themeSettings.set('theme_mode', selection)
236+
dlg = wx.MessageDialog(
237+
self.mainFrame,
238+
_t("Theme changed. Close pyfa now to apply?"),
239+
_t("Restart Required"),
240+
wx.YES_NO | wx.ICON_QUESTION
241+
)
242+
result = dlg.ShowModal()
243+
dlg.Destroy()
244+
if result == wx.ID_YES:
245+
# Save settings explicitly before closing
246+
SettingsProvider.getInstance().saveAll()
247+
# Find the PreferenceDialog parent and close it first
248+
# to avoid hanging (can't close mainFrame while modal is open)
249+
prefDialog = self.chTheme.GetTopLevelParent()
250+
if prefDialog and hasattr(prefDialog, 'EndModal'):
251+
prefDialog.EndModal(wx.ID_OK)
252+
wx.CallAfter(self.mainFrame.Close)
253+
213254
def onCBGlobalColorBySlot(self, event):
214255
# todo: maybe create a SettingChanged event that we can fire, and have other things hook into, instead of having the preference panel itself handle the
215256
# updating of things related to settings.

gui/pyfa_gauge.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import wx
1919

2020
from gui.utils import anim_effects, color as color_utils, draw
21+
from gui.utils.colors import Colors
2122

2223

2324
_t = wx.GetTranslation
@@ -68,7 +69,7 @@ def __init__(self, parent, font, max_range=100, size=(-1, 30), *args,
6869

6970
self.font = font
7071

71-
self.SetBackgroundColour(wx.Colour(51, 51, 51))
72+
self.SetBackgroundColour(Colors.gaugeBackground())
7273

7374
self._tooltip = wx.ToolTip("0.00/100.00")
7475
self.SetToolTip(self._tooltip)

0 commit comments

Comments
 (0)