Skip to content

Commit 2cf7f97

Browse files
committed
Add Import Function
1 parent 49e0055 commit 2cf7f97

File tree

4 files changed

+66
-4
lines changed

4 files changed

+66
-4
lines changed

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ private ResourceDictionary GetResourceDictionary(string theme)
324324
return dict;
325325
}
326326

327-
private ResourceDictionary GetCurrentResourceDictionary()
327+
public ResourceDictionary GetCurrentResourceDictionary()
328328
{
329329
return GetResourceDictionary(_settings.Theme);
330330
}

Flow.Launcher/Languages/en.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@
199199
<system:String x:Key="resultItemFont">Result Title Font</system:String>
200200
<system:String x:Key="resultSubItemFont">Result Subtitle Font</system:String>
201201
<system:String x:Key="resetCustomize">Reset</system:String>
202+
<system:String x:Key="resetCustomizeToolTip">Reset to the recommended font and size settings.</system:String>
203+
<system:String x:Key="ImportThemeSize">Import Theme Size</system:String>
204+
<system:String x:Key="ImportThemeSizeToolTip">If a size value intended by the theme designer is available, it will be retrieved and applied.</system:String>
202205
<system:String x:Key="CustomizeToolTip">Customize</system:String>
203206
<system:String x:Key="windowMode">Window Mode</system:String>
204207
<system:String x:Key="opacity">Opacity</system:String>

Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Flow.Launcher.ViewModel;
1818
using ModernWpf;
1919
using ThemeManagerForColorSchemeSwitch = ModernWpf.ThemeManager;
20+
using System.Windows.Controls;
2021

2122
namespace Flow.Launcher.SettingPages.ViewModels;
2223

@@ -508,5 +509,56 @@ public void Reset()
508509
WindowHeightSize = 42;
509510
ItemHeightSize = 58;
510511
}
511-
512+
513+
[RelayCommand]
514+
private void Import()
515+
{
516+
var resourceDictionary = _theme.GetCurrentResourceDictionary();
517+
518+
if (resourceDictionary["QueryBoxStyle"] is Style queryBoxStyle)
519+
{
520+
var fontSizeSetter = queryBoxStyle.Setters
521+
.OfType<Setter>()
522+
.FirstOrDefault(setter => setter.Property == TextBox.FontSizeProperty);
523+
if (fontSizeSetter?.Value is double fontSize)
524+
{
525+
QueryBoxFontSize = fontSize;
526+
}
527+
528+
var heightSetter = queryBoxStyle.Setters
529+
.OfType<Setter>()
530+
.FirstOrDefault(setter => setter.Property == FrameworkElement.HeightProperty);
531+
if (heightSetter?.Value is double height)
532+
{
533+
WindowHeightSize = height;
534+
}
535+
}
536+
537+
if (resourceDictionary["ResultItemHeight"] is double resultItemHeight)
538+
{
539+
ItemHeightSize = resultItemHeight;
540+
}
541+
542+
if (resourceDictionary["ItemTitleStyle"] is Style itemTitleStyle)
543+
{
544+
var fontSizeSetter = itemTitleStyle.Setters
545+
.OfType<Setter>()
546+
.FirstOrDefault(setter => setter.Property == TextBlock.FontSizeProperty);
547+
if (fontSizeSetter?.Value is double fontSize)
548+
{
549+
ResultItemFontSize = fontSize;
550+
}
551+
}
552+
553+
if (resourceDictionary["ItemSubTitleStyle"] is Style itemSubTitleStyle)
554+
{
555+
var fontSizeSetter = itemSubTitleStyle.Setters
556+
.OfType<Setter>()
557+
.FirstOrDefault(setter => setter.Property == TextBlock.FontSizeProperty);
558+
if (fontSizeSetter?.Value is double fontSize)
559+
{
560+
ResultSubItemFontSize = fontSize;
561+
}
562+
}
563+
}
512564
}

Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,17 @@
256256
BorderThickness="1"
257257
Style="{StaticResource SettingSeparatorStyle}" />
258258
<Button
259-
Margin="8"
259+
Margin="12 4 12 8"
260+
HorizontalAlignment="Stretch"
261+
Command="{Binding ImportCommand}"
262+
Content="{DynamicResource ImportThemeSize}"
263+
ToolTip="{DynamicResource ImportThemeSizeToolTip}" />
264+
<Button
265+
Margin="12 4 12 8"
260266
HorizontalAlignment="Stretch"
261267
Command="{Binding ResetCommand}"
262-
Content="{DynamicResource resetCustomize}" />
268+
Content="{DynamicResource resetCustomize}"
269+
ToolTip="{DynamicResource resetCustomizeToolTip}" />
263270
</StackPanel>
264271
</ScrollViewer>
265272
</Border>

0 commit comments

Comments
 (0)