Merge branch 'dev' into 250423-FixNumberboxColor

This commit is contained in:
DB P 2025-04-23 18:54:53 +09:00 committed by GitHub
commit 8ed0c47dac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 183 additions and 104 deletions

View file

@ -31,7 +31,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
{
_storage.Save();
}
private string _theme = Constant.DefaultTheme;
public string Hotkey { get; set; } = $"{KeyConstant.Alt} + {KeyConstant.Space}";
public string OpenResultModifiers { get; set; } = KeyConstant.Alt;
@ -103,6 +103,20 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public bool ShowBadges { get; set; } = false;
public bool ShowBadgesGlobalOnly { get; set; } = false;
private string _settingWindowFont { get; set; } = Win32Helper.GetSystemDefaultFont(false);
public string SettingWindowFont
{
get => _settingWindowFont;
set
{
if (_settingWindowFont != value)
{
_settingWindowFont = value;
OnPropertyChanged();
}
}
}
public bool UseClock { get; set; } = true;
public bool UseDate { get; set; } = false;
public string TimeFormat { get; set; } = "hh:mm tt";

View file

@ -628,21 +628,33 @@ namespace Flow.Launcher.Infrastructure
{ "pt", "Noto Sans" }
};
public static string GetSystemDefaultFont()
/// <summary>
/// Gets the system default font.
/// </summary>
/// <param name="useNoto">
/// If true, it will try to find the Noto font for the current culture.
/// </param>
/// <returns>
/// The name of the system default font.
/// </returns>
public static string GetSystemDefaultFont(bool useNoto = true)
{
try
{
var culture = CultureInfo.CurrentCulture;
var language = culture.Name; // e.g., "zh-TW"
var langPrefix = language.Split('-')[0]; // e.g., "zh"
// First, try to find by full name, and if not found, fallback to prefix
if (TryGetNotoFont(language, out var notoFont) || TryGetNotoFont(langPrefix, out notoFont))
if (useNoto)
{
// If the font is installed, return it
if (Fonts.SystemFontFamilies.Any(f => f.Source.Equals(notoFont)))
var culture = CultureInfo.CurrentCulture;
var language = culture.Name; // e.g., "zh-TW"
var langPrefix = language.Split('-')[0]; // e.g., "zh"
// First, try to find by full name, and if not found, fallback to prefix
if (TryGetNotoFont(language, out var notoFont) || TryGetNotoFont(langPrefix, out notoFont))
{
return notoFont;
// If the font is installed, return it
if (Fonts.SystemFontFamilies.Any(f => f.Source.Equals(notoFont)))
{
return notoFont;
}
}
}

View file

@ -8,6 +8,7 @@
Width="530"
Background="{DynamicResource PopuBGColor}"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
FontFamily="{Binding Settings.SettingWindowFont, Mode=TwoWay}"
Foreground="{DynamicResource PopupTextColor}"
Icon="Images\app.png"
MouseDown="window_MouseDown"

View file

@ -1,22 +1,23 @@
using Flow.Launcher.Helper;
using Flow.Launcher.Infrastructure.UserSettings;
using System.Collections.ObjectModel;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using System.Windows.Controls;
using Flow.Launcher.Helper;
using Flow.Launcher.Infrastructure.UserSettings;
namespace Flow.Launcher
{
public partial class CustomQueryHotkeySetting : Window
{
private readonly Settings _settings;
public Settings Settings { get; }
private bool update;
private CustomPluginHotkey updateCustomHotkey;
public CustomQueryHotkeySetting(Settings settings)
{
_settings = settings;
Settings = settings;
InitializeComponent();
}
@ -29,13 +30,13 @@ namespace Flow.Launcher
{
if (!update)
{
_settings.CustomPluginHotkeys ??= new ObservableCollection<CustomPluginHotkey>();
Settings.CustomPluginHotkeys ??= new ObservableCollection<CustomPluginHotkey>();
var pluginHotkey = new CustomPluginHotkey
{
Hotkey = HotkeyControl.CurrentHotkey.ToString(), ActionKeyword = tbAction.Text
};
_settings.CustomPluginHotkeys.Add(pluginHotkey);
Settings.CustomPluginHotkeys.Add(pluginHotkey);
HotKeyMapper.SetCustomQueryHotkey(pluginHotkey);
}
@ -54,7 +55,7 @@ namespace Flow.Launcher
public void UpdateItem(CustomPluginHotkey item)
{
updateCustomHotkey = _settings.CustomPluginHotkeys.FirstOrDefault(o =>
updateCustomHotkey = Settings.CustomPluginHotkeys.FirstOrDefault(o =>
o.ActionKeyword == item.ActionKeyword && o.Hotkey == item.Hotkey);
if (updateCustomHotkey == null)
{

View file

@ -7,6 +7,7 @@
Width="530"
Background="{DynamicResource PopuBGColor}"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
FontFamily="{Binding Settings.SettingWindowFont, Mode=TwoWay}"
Foreground="{DynamicResource PopupTextColor}"
Icon="Images\app.png"
ResizeMode="NoResize"
@ -56,11 +57,11 @@
</Button>
</Grid>
</StackPanel>
<StackPanel Margin="26,0,26,0">
<StackPanel Grid.Row="0" Margin="0,0,0,12">
<StackPanel Margin="26 0 26 0">
<StackPanel Grid.Row="0" Margin="0 0 0 12">
<TextBlock
Grid.Column="0"
Margin="0,0,0,0"
Margin="0 0 0 0"
FontSize="20"
FontWeight="SemiBold"
Text="{DynamicResource customQueryShortcut}"
@ -73,18 +74,18 @@
TextAlignment="Left"
TextWrapping="WrapWithOverflow" />
<TextBlock
Margin="0,20,0,0"
Margin="0 20 0 0"
FontSize="14"
Text="{DynamicResource customeQueryShortcutGuide}"
TextAlignment="Left"
TextWrapping="WrapWithOverflow" />
<Image
Width="478"
Margin="0,20,0,0"
Margin="0 20 0 0"
Source="/Images/illustration_02.png" />
</StackPanel>
<StackPanel Margin="0,10,0,10" Orientation="Horizontal">
<StackPanel Margin="0 10 0 10" Orientation="Horizontal">
<Grid Width="478">
<Grid.RowDefinitions>
<RowDefinition />
@ -124,14 +125,14 @@
LastChildFill="True">
<Button
x:Name="btnTestShortcut"
Margin="0,0,10,0"
Padding="10,5,10,5"
Margin="0 0 10 0"
Padding="10 5 10 5"
Click="BtnTestShortcut_OnClick"
Content="{DynamicResource preview}"
DockPanel.Dock="Right" />
<TextBox
x:Name="tbExpand"
Margin="10,0,10,0"
Margin="10 0 10 0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Text="{Binding Value}" />
@ -142,21 +143,21 @@
</StackPanel>
<Border
Grid.Row="1"
Margin="0,10,0,0"
Margin="0 10 0 0"
Background="{DynamicResource PopupButtonAreaBGColor}"
BorderBrush="{DynamicResource PopupButtonAreaBorderColor}"
BorderThickness="0,1,0,0">
BorderThickness="0 1 0 0">
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
<Button
x:Name="btnCancel"
MinWidth="140"
Margin="10,0,5,0"
Margin="10 0 5 0"
Click="BtnCancel_OnClick"
Content="{DynamicResource cancel}" />
<Button
x:Name="btnAdd"
MinWidth="140"
Margin="5,0,10,0"
Margin="5 0 10 0"
Click="BtnAdd_OnClick"
Style="{StaticResource AccentButtonStyle}">
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />

View file

@ -1,15 +1,18 @@
using System;
using System.Windows;
using System.Windows;
using System.Windows.Input;
using CommunityToolkit.Mvvm.DependencyInjection;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.SettingPages.ViewModels;
namespace Flow.Launcher
{
public partial class CustomShortcutSetting : Window
{
public Settings Settings { get; } = Ioc.Default.GetRequiredService<Settings>();
private readonly SettingsPaneHotkeyViewModel _hotkeyVm;
public string Key { get; set; } = String.Empty;
public string Value { get; set; } = String.Empty;
public string Key { get; set; } = string.Empty;
public string Value { get; set; } = string.Empty;
private string originalKey { get; } = null;
private string originalValue { get; } = null;
private bool update { get; } = false;

View file

@ -355,6 +355,7 @@
<system:String x:Key="logLevel">Log Level</system:String>
<system:String x:Key="LogLevelDEBUG">Debug</system:String>
<system:String x:Key="LogLevelINFO">Info</system:String>
<system:String x:Key="settingWindowFont">Setting Window Font</system:String>
<!-- FileManager Setting Dialog -->
<system:String x:Key="fileManagerWindow">Select File Manager</system:String>

View file

@ -10,6 +10,7 @@
Width="550"
Background="{DynamicResource PopuBGColor}"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
FontFamily="{Binding Settings.SettingWindowFont, Mode=TwoWay}"
Foreground="{DynamicResource PopupTextColor}"
ResizeMode="NoResize"
SizeToContent="Height"
@ -54,11 +55,11 @@
</Button>
</Grid>
</StackPanel>
<StackPanel Margin="26,12,26,0">
<StackPanel Margin="0,0,0,12">
<StackPanel Margin="26 12 26 0">
<StackPanel Margin="0 0 0 12">
<TextBlock
Grid.Column="0"
Margin="0,0,0,0"
Margin="0 0 0 0"
FontSize="20"
FontWeight="SemiBold"
Text="{DynamicResource defaultBrowserTitle}"
@ -73,7 +74,7 @@
</StackPanel>
<StackPanel Margin="14,28,0,0" Orientation="Horizontal">
<StackPanel Margin="14 28 0 0" Orientation="Horizontal">
<TextBlock
Grid.Column="1"
HorizontalAlignment="Left"
@ -84,7 +85,7 @@
Name="comboBox"
Height="35"
MinWidth="200"
Margin="14,0,0,0"
Margin="14 0 0 0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
ItemsSource="{Binding CustomBrowsers}"
@ -96,11 +97,11 @@
</ComboBox.ItemTemplate>
</ComboBox>
<Button
Margin="10,0,0,0"
Margin="10 0 0 0"
Click="btnAdd_Click"
Content="{DynamicResource add}" />
<Button
Margin="10,0,0,0"
Margin="10 0 0 0"
Click="btnDelete_Click"
Content="{DynamicResource delete}"
IsEnabled="{Binding CustomBrowser.Editable}" />
@ -108,10 +109,10 @@
</StackPanel>
<Rectangle
Height="1"
Margin="0,20,0,12"
Margin="0 20 0 12"
Fill="{DynamicResource SeparatorForeground}" />
<StackPanel
Margin="0,0,0,0"
Margin="0 0 0 0"
HorizontalAlignment="Stretch"
DataContext="{Binding CustomBrowser}"
Orientation="Horizontal">
@ -129,7 +130,7 @@
<TextBlock
Grid.Row="0"
Grid.Column="0"
Margin="14,5,10,0"
Margin="14 5 10 0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
@ -139,7 +140,7 @@
Grid.Row="0"
Grid.Column="1"
Width="Auto"
Margin="10,5,0,0"
Margin="10 5 0 0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
IsEnabled="{Binding Editable}"
@ -147,7 +148,7 @@
<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="14,10,0,0"
Margin="14 10 0 0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
@ -159,7 +160,7 @@
LastChildFill="True">
<Button
Name="btnBrowseFile"
Margin="0,10,0,0"
Margin="0 10 0 0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Click="btnBrowseFile_Click"
@ -177,7 +178,7 @@
</Button>
<TextBox
x:Name="PathTextBox"
Margin="10,10,5,0"
Margin="10 10 5 0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
IsEnabled="{Binding Editable}"
@ -187,19 +188,17 @@
<StackPanel
Grid.Row="2"
Grid.Column="1"
Margin="14,10,14,0"
Margin="14 10 14 0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Orientation="Horizontal">
<RadioButton IsChecked="{Binding OpenInTab}"
Content="{DynamicResource defaultBrowser_newTab}"></RadioButton>
<RadioButton IsChecked="{Binding OpenInNewWindow, Mode=OneTime}"
Content="{DynamicResource defaultBrowser_newWindow}"></RadioButton>
<RadioButton Content="{DynamicResource defaultBrowser_newTab}" IsChecked="{Binding OpenInTab}" />
<RadioButton Content="{DynamicResource defaultBrowser_newWindow}" IsChecked="{Binding OpenInNewWindow, Mode=OneTime}" />
</StackPanel>
<TextBlock
Grid.Row="3"
Grid.Column="0"
Margin="14,10,0,20"
Margin="14 10 0 20"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
@ -207,17 +206,17 @@
<StackPanel
Grid.Row="3"
Grid.Column="1"
Margin="0,10,0,15"
Margin="0 10 0 15"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBox
x:Name="fileArgTextBox"
Width="180"
Margin="10,0,0,0"
Margin="10 0 0 0"
Text="{Binding PrivateArg}" />
<CheckBox
Margin="12,0,0,0"
Margin="12 0 0 0"
VerticalAlignment="Center"
IsChecked="{Binding EnablePrivate}">
<CheckBox.Style>
@ -239,18 +238,18 @@
Grid.Row="1"
Background="{DynamicResource PopupButtonAreaBGColor}"
BorderBrush="{DynamicResource PopupButtonAreaBorderColor}"
BorderThickness="0,1,0,0">
BorderThickness="0 1 0 0">
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
<Button
x:Name="btnCancel"
Width="145"
Margin="0,0,5,0"
Margin="0 0 5 0"
Click="btnCancel_Click"
Content="{DynamicResource cancel}" />
<Button
x:Name="btnDone"
Width="145"
Margin="5,0,0,0"
Margin="5 0 0 0"
Click="btnDone_Click"
Content="{DynamicResource done}"
ForceCursor="True"

View file

@ -1,27 +1,25 @@
using Flow.Launcher.Infrastructure.UserSettings;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using CommunityToolkit.Mvvm.ComponentModel;
using Flow.Launcher.Infrastructure.UserSettings;
namespace Flow.Launcher
{
public partial class SelectBrowserWindow : Window, INotifyPropertyChanged
[INotifyPropertyChanged]
public partial class SelectBrowserWindow : Window
{
private int selectedCustomBrowserIndex;
public event PropertyChangedEventHandler PropertyChanged;
public Settings Settings { get; }
private int selectedCustomBrowserIndex;
public int SelectedCustomBrowserIndex
{
get => selectedCustomBrowserIndex; set
{
selectedCustomBrowserIndex = value;
PropertyChanged?.Invoke(this, new(nameof(CustomBrowser)));
OnPropertyChanged(nameof(CustomBrowser));
}
}
public ObservableCollection<CustomBrowserViewModel> CustomBrowsers { get; set; }
@ -64,8 +62,7 @@ namespace Flow.Launcher
private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
Nullable<bool> result = dlg.ShowDialog();
var result = dlg.ShowDialog();
if (result == true)
{
TextBox path = (TextBox)(((FrameworkElement)sender).Parent as FrameworkElement).FindName("PathTextBox");

View file

@ -10,6 +10,7 @@
Width="600"
Background="{DynamicResource PopuBGColor}"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
FontFamily="{Binding Settings.SettingWindowFont, Mode=TwoWay}"
Foreground="{DynamicResource PopupTextColor}"
ResizeMode="NoResize"
SizeToContent="Height"

View file

@ -1,28 +1,27 @@
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.ViewModel;
using System;
using System.Collections.ObjectModel;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using CommunityToolkit.Mvvm.ComponentModel;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.ViewModel;
namespace Flow.Launcher
{
public partial class SelectFileManagerWindow : Window, INotifyPropertyChanged
[INotifyPropertyChanged]
public partial class SelectFileManagerWindow : Window
{
private int selectedCustomExplorerIndex;
public event PropertyChangedEventHandler PropertyChanged;
public Settings Settings { get; }
private int selectedCustomExplorerIndex;
public int SelectedCustomExplorerIndex
{
get => selectedCustomExplorerIndex; set
{
selectedCustomExplorerIndex = value;
PropertyChanged?.Invoke(this, new(nameof(CustomExplorer)));
OnPropertyChanged(nameof(CustomExplorer));
}
}
public ObservableCollection<CustomExplorerViewModel> CustomExplorers { get; set; }
@ -65,8 +64,7 @@ namespace Flow.Launcher
private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
Nullable<bool> result = dlg.ShowDialog();
var result = dlg.ShowDialog();
if (result == true)
{
TextBox path = (TextBox)(((FrameworkElement)sender).Parent as FrameworkElement).FindName("PathTextBox");

View file

@ -268,4 +268,23 @@ public partial class SettingsPaneAboutViewModel : BaseModel
return "0 B";
}
public string SettingWindowFont
{
get => _settings.SettingWindowFont;
set
{
if (_settings.SettingWindowFont != value)
{
_settings.SettingWindowFont = value;
OnPropertyChanged();
}
}
}
[RelayCommand]
private void ResetSettingWindowFont()
{
SettingWindowFont = Win32Helper.GetSystemDefaultFont(false);
}
}

View file

@ -12,6 +12,11 @@
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<ui:Page.Resources>
<ResourceDictionary>
<CollectionViewSource x:Key="SortedFonts" Source="{Binding Source={x:Static Fonts.SystemFontFamilies}}" />
</ResourceDictionary>
</ui:Page.Resources>
<ScrollViewer
Margin="0"
CanContentScroll="True"
@ -127,13 +132,39 @@
</StackPanel>
</cc:Card>
<cc:Card Title="{DynamicResource logLevel}" Icon="&#xE749;">
<ComboBox
DisplayMemberPath="Display"
ItemsSource="{Binding LogLevels}"
SelectedValue="{Binding LogLevel}"
SelectedValuePath="Value" />
</cc:Card>
<cc:ExCard
Title="Advanced"
Margin="0 14 0 0"
Icon="&#xE8B7;">
<StackPanel>
<cc:Card
Title="{DynamicResource logLevel}"
Icon="&#xE749;"
Type="Inside">
<ComboBox
DisplayMemberPath="Display"
ItemsSource="{Binding LogLevels}"
SelectedValue="{Binding LogLevel}"
SelectedValuePath="Value" />
</cc:Card>
<cc:Card
Title="{DynamicResource settingWindowFont}"
Icon="&#xf259;"
Type="Inside">
<StackPanel Orientation="Horizontal">
<Button Command="{Binding ResetSettingWindowFontCommand}" Content="Reset" />
<ComboBox
Margin="12 8 0 8"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
DisplayMemberPath="Source"
ItemsSource="{Binding Source={StaticResource SortedFonts}}"
SelectedValue="{Binding SettingWindowFont, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
SelectedValuePath="Source" />
</StackPanel>
</cc:Card>
</StackPanel>
</cc:ExCard>
<TextBlock
Margin="14 20 0 0"

View file

@ -13,6 +13,7 @@
MinHeight="600"
d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}"
Closed="OnClosed"
FontFamily="{Binding Settings.SettingWindowFont, Mode=TwoWay}"
Icon="Images\app.ico"
Left="{Binding SettingWindowLeft, Mode=TwoWay}"
Loaded="OnLoaded"

View file

@ -5,11 +5,11 @@ namespace Flow.Launcher.ViewModel;
public partial class SettingWindowViewModel : BaseModel
{
private readonly Settings _settings;
public Settings Settings { get; }
public SettingWindowViewModel(Settings settings)
{
_settings = settings;
Settings = settings;
}
/// <summary>
@ -17,30 +17,30 @@ public partial class SettingWindowViewModel : BaseModel
/// </summary>
public void Save()
{
_settings.Save();
Settings.Save();
}
public double SettingWindowWidth
{
get => _settings.SettingWindowWidth;
set => _settings.SettingWindowWidth = value;
get => Settings.SettingWindowWidth;
set => Settings.SettingWindowWidth = value;
}
public double SettingWindowHeight
{
get => _settings.SettingWindowHeight;
set => _settings.SettingWindowHeight = value;
get => Settings.SettingWindowHeight;
set => Settings.SettingWindowHeight = value;
}
public double? SettingWindowTop
{
get => _settings.SettingWindowTop;
set => _settings.SettingWindowTop = value;
get => Settings.SettingWindowTop;
set => Settings.SettingWindowTop = value;
}
public double? SettingWindowLeft
{
get => _settings.SettingWindowLeft;
set => _settings.SettingWindowLeft = value;
get => Settings.SettingWindowLeft;
set => Settings.SettingWindowLeft = value;
}
}