Add Import Function

This commit is contained in:
DB P 2025-04-13 07:37:55 +09:00
parent 49e00555fa
commit 2cf7f97a8b
4 changed files with 66 additions and 4 deletions

View file

@ -324,7 +324,7 @@ namespace Flow.Launcher.Core.Resource
return dict;
}
private ResourceDictionary GetCurrentResourceDictionary()
public ResourceDictionary GetCurrentResourceDictionary()
{
return GetResourceDictionary(_settings.Theme);
}

View file

@ -199,6 +199,9 @@
<system:String x:Key="resultItemFont">Result Title Font</system:String>
<system:String x:Key="resultSubItemFont">Result Subtitle Font</system:String>
<system:String x:Key="resetCustomize">Reset</system:String>
<system:String x:Key="resetCustomizeToolTip">Reset to the recommended font and size settings.</system:String>
<system:String x:Key="ImportThemeSize">Import Theme Size</system:String>
<system:String x:Key="ImportThemeSizeToolTip">If a size value intended by the theme designer is available, it will be retrieved and applied.</system:String>
<system:String x:Key="CustomizeToolTip">Customize</system:String>
<system:String x:Key="windowMode">Window Mode</system:String>
<system:String x:Key="opacity">Opacity</system:String>

View file

@ -17,6 +17,7 @@ using Flow.Launcher.Plugin.SharedModels;
using Flow.Launcher.ViewModel;
using ModernWpf;
using ThemeManagerForColorSchemeSwitch = ModernWpf.ThemeManager;
using System.Windows.Controls;
namespace Flow.Launcher.SettingPages.ViewModels;
@ -508,5 +509,56 @@ public partial class SettingsPaneThemeViewModel : BaseModel
WindowHeightSize = 42;
ItemHeightSize = 58;
}
[RelayCommand]
private void Import()
{
var resourceDictionary = _theme.GetCurrentResourceDictionary();
if (resourceDictionary["QueryBoxStyle"] is Style queryBoxStyle)
{
var fontSizeSetter = queryBoxStyle.Setters
.OfType<Setter>()
.FirstOrDefault(setter => setter.Property == TextBox.FontSizeProperty);
if (fontSizeSetter?.Value is double fontSize)
{
QueryBoxFontSize = fontSize;
}
var heightSetter = queryBoxStyle.Setters
.OfType<Setter>()
.FirstOrDefault(setter => setter.Property == FrameworkElement.HeightProperty);
if (heightSetter?.Value is double height)
{
WindowHeightSize = height;
}
}
if (resourceDictionary["ResultItemHeight"] is double resultItemHeight)
{
ItemHeightSize = resultItemHeight;
}
if (resourceDictionary["ItemTitleStyle"] is Style itemTitleStyle)
{
var fontSizeSetter = itemTitleStyle.Setters
.OfType<Setter>()
.FirstOrDefault(setter => setter.Property == TextBlock.FontSizeProperty);
if (fontSizeSetter?.Value is double fontSize)
{
ResultItemFontSize = fontSize;
}
}
if (resourceDictionary["ItemSubTitleStyle"] is Style itemSubTitleStyle)
{
var fontSizeSetter = itemSubTitleStyle.Setters
.OfType<Setter>()
.FirstOrDefault(setter => setter.Property == TextBlock.FontSizeProperty);
if (fontSizeSetter?.Value is double fontSize)
{
ResultSubItemFontSize = fontSize;
}
}
}
}

View file

@ -256,10 +256,17 @@
BorderThickness="1"
Style="{StaticResource SettingSeparatorStyle}" />
<Button
Margin="8"
Margin="12 4 12 8"
HorizontalAlignment="Stretch"
Command="{Binding ImportCommand}"
Content="{DynamicResource ImportThemeSize}"
ToolTip="{DynamicResource ImportThemeSizeToolTip}" />
<Button
Margin="12 4 12 8"
HorizontalAlignment="Stretch"
Command="{Binding ResetCommand}"
Content="{DynamicResource resetCustomize}" />
Content="{DynamicResource resetCustomize}"
ToolTip="{DynamicResource resetCustomizeToolTip}" />
</StackPanel>
</ScrollViewer>
</Border>