Skip to content

Let more controls follow setting window font & Add Use Logon Task option in welcome page 5 #3486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public Control CreateSettingPanel()
TextWrapping = TextWrapping.WrapWithOverflow
};

desc.SetResourceReference(TextBlock.StyleProperty, "SettingPanelTextBlockDescriptionStyle"); // for theme change
desc.SetResourceReference(FrameworkElement.StyleProperty, "SettingPanelTextBlockDescriptionStyle"); // for theme change
}

// Add the name and description to the panel
Expand Down Expand Up @@ -251,6 +251,8 @@ public Control CreateSettingPanel()
ToolTip = attributes.Description
};

textBox.SetResourceReference(Control.FontFamilyProperty, "SettingWindowFont"); // for theme change

textBox.TextChanged += (_, _) =>
{
Settings[attributes.Name] = textBox.Text;
Expand All @@ -273,20 +275,24 @@ public Control CreateSettingPanel()
ToolTip = attributes.Description
};

textBox.SetResourceReference(Control.FontFamilyProperty, "SettingWindowFont"); // for theme change

textBox.TextChanged += (_, _) =>
{
Settings[attributes.Name] = textBox.Text;
};

var Btn = new Button()
var btn = new Button()
{
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Center,
Margin = SettingPanelItemLeftMargin,
Content = API.GetTranslation("select")
};

Btn.Click += (_, _) =>
btn.SetResourceReference(Control.FontFamilyProperty, "SettingWindowFont"); // for theme change

btn.Click += (_, _) =>
{
using System.Windows.Forms.CommonDialog dialog = type switch
{
Expand Down Expand Up @@ -320,7 +326,7 @@ public Control CreateSettingPanel()

// Create a stack panel to wrap the button and text box
stackPanel.Children.Add(textBox);
stackPanel.Children.Add(Btn);
stackPanel.Children.Add(btn);

contentControl = stackPanel;

Expand All @@ -340,6 +346,8 @@ public Control CreateSettingPanel()
ToolTip = attributes.Description
};

textBox.SetResourceReference(Control.FontFamilyProperty, "SettingWindowFont"); // for theme change

textBox.TextChanged += (sender, _) =>
{
Settings[attributes.Name] = ((TextBox)sender).Text;
Expand All @@ -362,6 +370,8 @@ public Control CreateSettingPanel()
ToolTip = attributes.Description,
};

passwordBox.SetResourceReference(Control.FontFamilyProperty, "SettingWindowFont"); // for theme change

passwordBox.PasswordChanged += (sender, _) =>
{
Settings[attributes.Name] = ((PasswordBox)sender).Password;
Expand All @@ -383,6 +393,8 @@ public Control CreateSettingPanel()
ToolTip = attributes.Description
};

comboBox.SetResourceReference(Control.FontFamilyProperty, "SettingWindowFont"); // for theme change

comboBox.SelectionChanged += (sender, _) =>
{
Settings[attributes.Name] = (string)((ComboBox)sender).SelectedItem;
Expand All @@ -409,6 +421,8 @@ Settings[attributes.Name] is bool isChecked
ToolTip = attributes.Description
};

checkBox.SetResourceReference(Control.FontFamilyProperty, "SettingWindowFont"); // for theme change

checkBox.Click += (sender, _) =>
{
Settings[attributes.Name] = ((CheckBox)sender).IsChecked ?? defaultValue;
Expand Down Expand Up @@ -451,7 +465,7 @@ Settings[attributes.Name] is bool isChecked
{
var sep = new Separator();

sep.SetResourceReference(Separator.StyleProperty, "SettingPanelSeparatorStyle");
sep.SetResourceReference(FrameworkElement.StyleProperty, "SettingPanelSeparatorStyle");

contentControl = sep;

Expand Down
2 changes: 2 additions & 0 deletions Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.ObjectModel;
using System.Text.Json.Serialization;
using System.Windows;
using System.Windows.Media;
using CommunityToolkit.Mvvm.DependencyInjection;
using Flow.Launcher.Infrastructure.Hotkey;
using Flow.Launcher.Infrastructure.Logger;
Expand Down Expand Up @@ -113,6 +114,7 @@ public string SettingWindowFont
{
_settingWindowFont = value;
OnPropertyChanged();
Application.Current.Resources["SettingWindowFont"] = new FontFamily(value);
}
}
}
Expand Down
25 changes: 14 additions & 11 deletions Flow.Launcher/ActionKeywords.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Title="{DynamicResource actionKeywordsTitle}"
Width="450"
Background="{DynamicResource PopuBGColor}"
FontFamily="{DynamicResource SettingWindowFont}"
Foreground="{DynamicResource PopupTextColor}"
Icon="Images\app.png"
Loaded="ActionKeyword_OnLoaded"
Expand Down Expand Up @@ -53,11 +54,11 @@
</Button>
</Grid>
</StackPanel>
<StackPanel Margin="26,12,26,0">
<StackPanel Grid.Row="0" Margin="0,0,0,12">
<StackPanel Margin="26 12 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 actionKeywordsTitle}"
Expand All @@ -71,7 +72,7 @@
TextWrapping="WrapWithOverflow" />
</StackPanel>

<StackPanel Margin="0,18,0,0" Orientation="Horizontal">
<StackPanel Margin="0 18 0 0" Orientation="Horizontal">
<TextBlock
Grid.Row="0"
Grid.Column="1"
Expand All @@ -83,14 +84,14 @@
x:Name="tbOldActionKeyword"
Grid.Row="0"
Grid.Column="1"
Margin="14,10,10,10"
Margin="14 10 10 10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="14"
FontWeight="SemiBold"
Foreground="{DynamicResource Color05B}" />
</StackPanel>
<StackPanel Margin="0,0,0,10" Orientation="Horizontal">
<StackPanel Margin="0 0 0 10" Orientation="Horizontal">
<TextBlock
Grid.Row="1"
Grid.Column="1"
Expand All @@ -101,7 +102,7 @@
<TextBox
x:Name="tbAction"
Width="105"
Margin="10,10,15,10"
Margin="10 10 15 10"
HorizontalAlignment="Left"
VerticalAlignment="Center" />
</StackPanel>
Expand All @@ -112,21 +113,23 @@
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"
Height="30"
Margin="10,0,5,0"
Margin="10 0 5 0"
Click="BtnCancel_OnClick"
Content="{DynamicResource cancel}" />
Content="{DynamicResource cancel}"
FontFamily="{DynamicResource SettingWindowFont}" />
<Button
x:Name="btnDone"
Width="145"
Height="30"
Margin="5,0,10,0"
Margin="5 0 10 0"
Click="btnDone_OnClick"
FontFamily="{DynamicResource SettingWindowFont}"
Style="{StaticResource AccentButtonStyle}">
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />
</Button>
Expand Down
16 changes: 10 additions & 6 deletions Flow.Launcher/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using CommunityToolkit.Mvvm.DependencyInjection;
using Flow.Launcher.Core;
using Flow.Launcher.Core.Configuration;
Expand Down Expand Up @@ -149,7 +150,7 @@ await API.StopwatchLogInfoAsync(ClassName, "Startup cost", async () =>
Ioc.Default.GetRequiredService<Portable>().PreStartCleanUpAfterPortabilityUpdate();

API.LogInfo(ClassName, "Begin Flow Launcher startup ----------------------------------------------------");
API.LogInfo(ClassName, "Runtime info:{ErrorReporting.RuntimeInfo()}");
API.LogInfo(ClassName, $"Runtime info:{ErrorReporting.RuntimeInfo()}");

RegisterAppDomainExceptions();
RegisterDispatcherUnhandledException();
Expand All @@ -169,19 +170,18 @@ await API.StopwatchLogInfoAsync(ClassName, "Startup cost", async () =>
await PluginManager.InitializePluginsAsync();

// Change language after all plugins are initialized because we need to update plugin title based on their api
// TODO: Clean InternationalizationManager.Instance and InternationalizationManager.Instance.GetTranslation in future
await Ioc.Default.GetRequiredService<Internationalization>().InitializeLanguageAsync();

await imageLoadertask;

_mainWindow = new MainWindow();
// Update dynamic resources base on settings
Current.Resources["SettingWindowFont"] = new FontFamily(_settings.SettingWindowFont);

API.LogInfo(ClassName, "Dependencies Info:{ErrorReporting.DependenciesInfo()}");
_mainWindow = new MainWindow();

Current.MainWindow = _mainWindow;
Current.MainWindow.Title = Constant.FlowLauncher;

// main windows needs initialized before theme change because of blur settings
// Main windows needs initialized before theme change because of blur settings
Ioc.Default.GetRequiredService<Theme>().ChangeTheme();

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Expand All @@ -198,6 +198,10 @@ await API.StopwatchLogInfoAsync(ClassName, "Startup cost", async () =>

#pragma warning restore VSTHRD100 // Avoid async void methods

/// <summary>
/// check startup only for Release
/// </summary>
[Conditional("RELEASE")]
private void AutoStartup()
{
// we try to enable auto-startup on first launch, or reenable if it was removed
Expand Down
12 changes: 8 additions & 4 deletions Flow.Launcher/CustomQueryHotkeySetting.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Width="530"
Background="{DynamicResource PopuBGColor}"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
FontFamily="{Binding Settings.SettingWindowFont, Mode=TwoWay}"
FontFamily="{DynamicResource SettingWindowFont}"
Foreground="{DynamicResource PopupTextColor}"
Icon="Images\app.png"
MouseDown="window_MouseDown"
Expand Down Expand Up @@ -120,15 +120,17 @@
Grid.Column="1"
Margin="10"
HorizontalAlignment="Stretch"
VerticalAlignment="Center" />
VerticalAlignment="Center"
FontFamily="{DynamicResource SettingWindowFont}" />
<Button
x:Name="btnTestActionKeyword"
Grid.Row="1"
Grid.Column="2"
Margin="0 0 10 0"
Padding="10 5 10 5"
Click="BtnTestActionKeyword_OnClick"
Content="{DynamicResource preview}" />
Content="{DynamicResource preview}"
FontFamily="{DynamicResource SettingWindowFont}" />
</Grid>
</StackPanel>
</StackPanel>
Expand All @@ -144,12 +146,14 @@
MinWidth="140"
Margin="10 0 5 0"
Click="BtnCancel_OnClick"
Content="{DynamicResource cancel}" />
Content="{DynamicResource cancel}"
FontFamily="{DynamicResource SettingWindowFont}" />
<Button
x:Name="btnAdd"
MinWidth="140"
Margin="5 0 10 0"
Click="btnAdd_OnClick"
FontFamily="{DynamicResource SettingWindowFont}"
Style="{StaticResource AccentButtonStyle}">
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />
</Button>
Expand Down
10 changes: 5 additions & 5 deletions Flow.Launcher/CustomQueryHotkeySetting.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ namespace Flow.Launcher
{
public partial class CustomQueryHotkeySetting : Window
{
public Settings Settings { get; }
private readonly Settings _settings;

private bool update;
private CustomPluginHotkey updateCustomHotkey;

public CustomQueryHotkeySetting(Settings settings)
{
Settings = settings;
_settings = settings;
InitializeComponent();
}

Expand All @@ -30,13 +30,13 @@ private void btnAdd_OnClick(object sender, RoutedEventArgs e)
{
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);
}
Expand All @@ -55,7 +55,7 @@ private void btnAdd_OnClick(object sender, RoutedEventArgs e)

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)
{
Expand Down
11 changes: 8 additions & 3 deletions Flow.Launcher/CustomShortcutSetting.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Width="530"
Background="{DynamicResource PopuBGColor}"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
FontFamily="{Binding Settings.SettingWindowFont, Mode=TwoWay}"
FontFamily="{DynamicResource SettingWindowFont}"
Foreground="{DynamicResource PopupTextColor}"
Icon="Images\app.png"
ResizeMode="NoResize"
Expand Down Expand Up @@ -109,6 +109,7 @@
Width="180"
Margin="10"
HorizontalAlignment="Left"
FontFamily="{DynamicResource SettingWindowFont}"
Text="{Binding Key}" />
<TextBlock
Grid.Row="1"
Expand All @@ -129,12 +130,14 @@
Padding="10 5 10 5"
Click="BtnTestShortcut_OnClick"
Content="{DynamicResource preview}"
DockPanel.Dock="Right" />
DockPanel.Dock="Right"
FontFamily="{DynamicResource SettingWindowFont}" />
<TextBox
x:Name="tbExpand"
Margin="10 0 10 0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
FontFamily="{DynamicResource SettingWindowFont}"
Text="{Binding Value}" />
</DockPanel>
</Grid>
Expand All @@ -153,12 +156,14 @@
MinWidth="140"
Margin="10 0 5 0"
Click="BtnCancel_OnClick"
Content="{DynamicResource cancel}" />
Content="{DynamicResource cancel}"
FontFamily="{DynamicResource SettingWindowFont}" />
<Button
x:Name="btnAdd"
MinWidth="140"
Margin="5 0 10 0"
Click="BtnAdd_OnClick"
FontFamily="{DynamicResource SettingWindowFont}"
Style="{StaticResource AccentButtonStyle}">
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />
</Button>
Expand Down
Loading
Loading