mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use property change event for settings & Use INotifyPropertyChanged instead
This commit is contained in:
parent
cdbe45d4dc
commit
c3509c3b20
13 changed files with 81 additions and 177 deletions
|
|
@ -96,7 +96,6 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
public string ResultSubFontStyle { get; set; }
|
||||
public string ResultSubFontWeight { get; set; }
|
||||
public string ResultSubFontStretch { get; set; }
|
||||
public string SettingWindowFont { get; set; } = Win32Helper.GetSystemDefaultFont(false);
|
||||
public bool UseGlyphIcons { get; set; } = true;
|
||||
public bool UseAnimation { get; set; } = true;
|
||||
public bool UseSound { get; set; } = true;
|
||||
|
|
@ -104,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";
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:flowlauncher="clr-namespace:Flow.Launcher"
|
||||
FontFamily="{Binding SettingWindowFont, Mode=TwoWay}"
|
||||
Title="{DynamicResource customeQueryHotkeyTitle}"
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -1,41 +1,23 @@
|
|||
using Flow.Launcher.Helper;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
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; set; }
|
||||
|
||||
private bool update;
|
||||
private CustomPluginHotkey updateCustomHotkey;
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public string SettingWindowFont
|
||||
{
|
||||
get => _settings.SettingWindowFont;
|
||||
set
|
||||
{
|
||||
if (_settings.SettingWindowFont != value)
|
||||
{
|
||||
_settings.SettingWindowFont = value;
|
||||
OnPropertyChanged(nameof(SettingWindowFont));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public CustomQueryHotkeySetting(Settings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
Settings = settings;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
|
@ -48,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);
|
||||
}
|
||||
|
|
@ -73,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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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}" />
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.SettingPages.ViewModels;
|
||||
|
||||
|
|
@ -9,33 +8,15 @@ namespace Flow.Launcher
|
|||
{
|
||||
public partial class CustomShortcutSetting : Window
|
||||
{
|
||||
private static readonly Settings _settings = Ioc.Default.GetRequiredService<Settings>();
|
||||
public Settings Settings { get; set; } = 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;
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public string SettingWindowFont
|
||||
{
|
||||
get => _settings.SettingWindowFont;
|
||||
set
|
||||
{
|
||||
if (_settings.SettingWindowFont != value)
|
||||
{
|
||||
_settings.SettingWindowFont = value;
|
||||
OnPropertyChanged(nameof(SettingWindowFont));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public CustomShortcutSetting(SettingsPaneHotkeyViewModel vm)
|
||||
{
|
||||
_hotkeyVm = vm;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
Width="550"
|
||||
Background="{DynamicResource PopuBGColor}"
|
||||
DataContext="{Binding RelativeSource={RelativeSource Self}}"
|
||||
FontFamily="{Binding SettingWindowFont, Mode=TwoWay}"
|
||||
FontFamily="{Binding Settings.SettingWindowFont, Mode=TwoWay}"
|
||||
Foreground="{DynamicResource PopupTextColor}"
|
||||
ResizeMode="NoResize"
|
||||
SizeToContent="Height"
|
||||
|
|
|
|||
|
|
@ -1,42 +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
|
||||
{
|
||||
public Settings Settings { get; }
|
||||
|
||||
private int selectedCustomBrowserIndex;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public Settings Settings { get; }
|
||||
public string SettingWindowFont
|
||||
{
|
||||
get => Settings.SettingWindowFont;
|
||||
set
|
||||
{
|
||||
if (Settings.SettingWindowFont != value)
|
||||
{
|
||||
Settings.SettingWindowFont = value;
|
||||
OnPropertyChanged(nameof(SettingWindowFont));
|
||||
}
|
||||
}
|
||||
}
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
public int SelectedCustomBrowserIndex
|
||||
{
|
||||
get => selectedCustomBrowserIndex; set
|
||||
{
|
||||
selectedCustomBrowserIndex = value;
|
||||
PropertyChanged?.Invoke(this, new(nameof(CustomBrowser)));
|
||||
OnPropertyChanged(nameof(CustomBrowser));
|
||||
}
|
||||
}
|
||||
public ObservableCollection<CustomBrowserViewModel> CustomBrowsers { get; set; }
|
||||
|
|
@ -79,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");
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
Width="600"
|
||||
Background="{DynamicResource PopuBGColor}"
|
||||
DataContext="{Binding RelativeSource={RelativeSource Self}}"
|
||||
FontFamily="{Binding SettingWindowFont, Mode=TwoWay}"
|
||||
FontFamily="{Binding Settings.SettingWindowFont, Mode=TwoWay}"
|
||||
Foreground="{DynamicResource PopupTextColor}"
|
||||
ResizeMode="NoResize"
|
||||
SizeToContent="Height"
|
||||
|
|
|
|||
|
|
@ -1,44 +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; }
|
||||
|
||||
public string SettingWindowFont
|
||||
{
|
||||
get => Settings.SettingWindowFont;
|
||||
set
|
||||
{
|
||||
if (Settings.SettingWindowFont != value)
|
||||
{
|
||||
Settings.SettingWindowFont = value;
|
||||
OnPropertyChanged(nameof(SettingWindowFont));
|
||||
}
|
||||
}
|
||||
}
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
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; }
|
||||
|
|
@ -81,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");
|
||||
|
|
|
|||
|
|
@ -160,8 +160,7 @@
|
|||
DisplayMemberPath="Source"
|
||||
ItemsSource="{Binding Source={StaticResource SortedFonts}}"
|
||||
SelectedValue="{Binding SettingWindowFont, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
SelectedValuePath="Source"
|
||||
SelectionChanged="SettingWindowFontComboBox_SelectionChanged" />
|
||||
SelectedValuePath="Source" />
|
||||
</StackPanel>
|
||||
</cc:Card>
|
||||
</StackPanel>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Navigation;
|
||||
using Flow.Launcher.Core;
|
||||
using Flow.Launcher.SettingPages.ViewModels;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
|
|
@ -31,21 +28,4 @@ public partial class SettingsPaneAbout
|
|||
App.API.OpenUrl(e.Uri.AbsoluteUri);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void SettingWindowFontComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (sender is ComboBox comboBox && comboBox.SelectedItem is FontFamily selectedFont)
|
||||
{
|
||||
if (DataContext is SettingsPaneAboutViewModel viewModel)
|
||||
{
|
||||
viewModel.SettingWindowFont = selectedFont.Source;
|
||||
|
||||
// 설정 창 글꼴 즉시 업데이트
|
||||
if (Window.GetWindow(this) is SettingWindow settingWindow)
|
||||
{
|
||||
settingWindow.FontFamily = selectedFont;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
MinHeight="600"
|
||||
d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}"
|
||||
Closed="OnClosed"
|
||||
FontFamily="{Binding SettingWindowFont, Mode=TwoWay}"
|
||||
FontFamily="{Binding Settings.SettingWindowFont, Mode=TwoWay}"
|
||||
Icon="Images\app.ico"
|
||||
Left="{Binding SettingWindowLeft, Mode=TwoWay}"
|
||||
Loaded="OnLoaded"
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
using System.ComponentModel;
|
||||
using System.Windows.Media;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.Plugin;
|
||||
|
||||
namespace Flow.Launcher.ViewModel;
|
||||
|
||||
public partial class SettingWindowViewModel : BaseModel
|
||||
{
|
||||
private readonly Settings _settings;
|
||||
public Settings Settings { get; set; }
|
||||
|
||||
public SettingWindowViewModel(Settings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
Settings = settings;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -19,44 +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;
|
||||
}
|
||||
|
||||
public string SettingWindowFont
|
||||
{
|
||||
get => _settings.SettingWindowFont;
|
||||
set
|
||||
{
|
||||
if (_settings.SettingWindowFont != value)
|
||||
{
|
||||
_settings.SettingWindowFont = value;
|
||||
OnPropertyChanged(nameof(SettingWindowFont));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue