55import gui .mainFrame
66from gui .bitmap_loader import BitmapLoader
77from gui .preferenceView import PreferenceView
8+ from gui .utils .colors import Colors
89from service .fit import Fit
9- from service .settings import SettingsProvider , LocaleSettings
10+ from service .settings import SettingsProvider , LocaleSettings , ThemeSettings
1011import eos .config
1112import 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.
0 commit comments