Skip to content

Commit 4a0891c

Browse files
committed
revise theme structure to achieve the property update
1 parent f109fb8 commit 4a0891c

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,14 @@ public bool ChangeTheme(string theme)
8282
{
8383
if (string.IsNullOrEmpty(path))
8484
throw new DirectoryNotFoundException("Theme path can't be found <{path}>");
85-
86-
Settings.Theme = theme;
87-
85+
8886
// reload all resources even if the theme itself hasn't changed in order to pickup changes
8987
// to things like fonts
90-
UpdateResourceDictionary(GetResourceDictionary());
88+
UpdateResourceDictionary(GetResourceDictionary(theme));
89+
90+
Settings.Theme = theme;
9191

92+
9293
//always allow re-loading default theme, in case of failure of switching to a new theme from default theme
9394
if (_oldTheme != theme || theme == defaultTheme)
9495
{
@@ -134,9 +135,9 @@ private void UpdateResourceDictionary(ResourceDictionary dictionaryToUpdate)
134135
_oldResource = dictionaryToUpdate;
135136
}
136137

137-
private ResourceDictionary CurrentThemeResourceDictionary()
138+
private ResourceDictionary GetThemeResourceDictionary(string theme)
138139
{
139-
var uri = GetThemePath(Settings.Theme);
140+
var uri = GetThemePath(theme);
140141
var dict = new ResourceDictionary
141142
{
142143
Source = new Uri(uri, UriKind.Absolute)
@@ -145,10 +146,12 @@ private ResourceDictionary CurrentThemeResourceDictionary()
145146
return dict;
146147
}
147148

148-
public ResourceDictionary GetResourceDictionary()
149+
private ResourceDictionary CurrentThemeResourceDictionary() => GetThemeResourceDictionary(Settings.Theme);
150+
151+
public ResourceDictionary GetResourceDictionary(string theme)
149152
{
150-
var dict = CurrentThemeResourceDictionary();
151-
153+
var dict = GetThemeResourceDictionary(theme);
154+
152155
if (dict["QueryBoxStyle"] is Style queryBoxStyle &&
153156
dict["QuerySuggestionBoxStyle"] is Style querySuggestionBoxStyle)
154157
{
@@ -200,6 +203,11 @@ public ResourceDictionary GetResourceDictionary()
200203
return dict;
201204
}
202205

206+
private ResourceDictionary GetCurrentResourceDictionary( )
207+
{
208+
return GetResourceDictionary(Settings.Theme);
209+
}
210+
203211
public List<string> LoadAvailableThemes()
204212
{
205213
List<string> themes = new List<string>();
@@ -229,7 +237,7 @@ private string GetThemePath(string themeName)
229237

230238
public void AddDropShadowEffectToCurrentTheme()
231239
{
232-
var dict = GetResourceDictionary();
240+
var dict = GetCurrentResourceDictionary();
233241

234242
var windowBorderStyle = dict["WindowBorderStyle"] as Style;
235243

@@ -273,7 +281,7 @@ public void AddDropShadowEffectToCurrentTheme()
273281

274282
public void RemoveDropShadowEffectFromCurrentTheme()
275283
{
276-
var dict = CurrentThemeResourceDictionary();
284+
var dict = GetCurrentResourceDictionary();
277285
var windowBorderStyle = dict["WindowBorderStyle"] as Style;
278286

279287
var effectSetter = windowBorderStyle.Setters.FirstOrDefault(setterBase => setterBase is Setter setter && setter.Property == Border.EffectProperty) as Setter;

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,6 @@ public string SelectedTheme
407407
get { return Settings.Theme; }
408408
set
409409
{
410-
Settings.Theme = value;
411410
ThemeManager.Instance.ChangeTheme(value);
412411

413412
if (ThemeManager.Instance.BlurEnabled && Settings.UseDropShadowEffect)

0 commit comments

Comments
 (0)