mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Improve theme window width setter handling
Previously, only the first width setter in WindowStyle was removed, which could leave conflicting width settings. Now, all width setters are removed before adding a new one based on user settings, ensuring the user's preferred window width is always applied.
This commit is contained in:
parent
913ef1a0bd
commit
1dcaf3d359
1 changed files with 17 additions and 8 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.Metrics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
@ -12,6 +12,7 @@ using System.Windows.Media;
|
||||||
using System.Windows.Media.Effects;
|
using System.Windows.Media.Effects;
|
||||||
using System.Windows.Shell;
|
using System.Windows.Shell;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
|
using System.Xml;
|
||||||
using Flow.Launcher.Infrastructure;
|
using Flow.Launcher.Infrastructure;
|
||||||
using Flow.Launcher.Infrastructure.UserSettings;
|
using Flow.Launcher.Infrastructure.UserSettings;
|
||||||
using Flow.Launcher.Plugin;
|
using Flow.Launcher.Plugin;
|
||||||
|
|
@ -217,13 +218,15 @@ namespace Flow.Launcher.Core.Resource
|
||||||
style.Setters.Add(new Setter(Control.FontStretchProperty, fontStretch));
|
style.Setters.Add(new Setter(Control.FontStretchProperty, fontStretch));
|
||||||
|
|
||||||
// Set caret brush (retain existing logic)
|
// Set caret brush (retain existing logic)
|
||||||
var caretBrushProperty = style.Setters.OfType<Setter>().Where(x => x.Property == TextBoxBase.CaretBrushProperty)?
|
var caretBrushPropertySetters = style.Setters.OfType<Setter>().Where(x => x.Property == TextBoxBase.CaretBrushProperty).ToList();
|
||||||
.FirstOrDefault();
|
|
||||||
var foregroundPropertyValue = style.Setters.OfType<Setter>().Where(x => x.Property == Control.ForegroundProperty)
|
var foregroundPropertyValue = style.Setters.OfType<Setter>().Where(x => x.Property == Control.ForegroundProperty)
|
||||||
.Select(x => x.Value).FirstOrDefault();
|
.Select(x => x.Value).FirstOrDefault();
|
||||||
if (caretBrushProperty != null && foregroundPropertyValue != null)
|
if (caretBrushPropertySetters.Count > 0 && foregroundPropertyValue != null)
|
||||||
{
|
{
|
||||||
style.Setters.Remove(caretBrushProperty);
|
foreach (var setter in caretBrushPropertySetters)
|
||||||
|
{
|
||||||
|
style.Setters.Remove(setter);
|
||||||
|
}
|
||||||
style.Setters.Add(new Setter(TextBoxBase.CaretBrushProperty, foregroundPropertyValue));
|
style.Setters.Add(new Setter(TextBoxBase.CaretBrushProperty, foregroundPropertyValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -273,11 +276,17 @@ namespace Flow.Launcher.Core.Resource
|
||||||
/* Ignore Theme Window Width and use setting */
|
/* Ignore Theme Window Width and use setting */
|
||||||
if (dict.Contains("WindowStyle") && dict["WindowStyle"] is Style windowStyle)
|
if (dict.Contains("WindowStyle") && dict["WindowStyle"] is Style windowStyle)
|
||||||
{
|
{
|
||||||
var windowStyleProperty = windowStyle.Setters.OfType<Setter>().FirstOrDefault(s => s.Property == FrameworkElement.WidthProperty);
|
// Remove all width setters
|
||||||
if (windowStyleProperty != null)
|
var widthSetters = windowStyle.Setters
|
||||||
|
.OfType<Setter>()
|
||||||
|
.Where(s => s.Property == FrameworkElement.WidthProperty)
|
||||||
|
.ToList();
|
||||||
|
foreach (var setter in widthSetters)
|
||||||
{
|
{
|
||||||
windowStyle.Setters.Remove(windowStyleProperty);
|
windowStyle.Setters.Remove(setter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add width setter based on user settings
|
||||||
windowStyle.Setters.Add(new Setter(FrameworkElement.WidthProperty, _settings.WindowSize));
|
windowStyle.Setters.Add(new Setter(FrameworkElement.WidthProperty, _settings.WindowSize));
|
||||||
}
|
}
|
||||||
return dict;
|
return dict;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue