[Run] Adding configurable fontsizes (#30541)

* Adding configurable fontsize for result titles

* Update src/settings-ui/Settings.UI/SettingsXAML/Views/PowerLauncherPage.xaml

Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com>

* Updating strings

* XAML styler

* CI fix

* PowerLauncher images

* update results height on font change

* Revert "update results height on font change"

This reverts commit 459f57c647.

---------

Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com>
Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
This commit is contained in:
Niels Laute
2023-12-26 14:49:50 +01:00
committed by GitHub
parent c098cfb193
commit ccd401fc16
16 changed files with 115 additions and 40 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 113 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -33,7 +33,7 @@
<TextBlock <TextBlock
Margin="6,0,0,0" Margin="6,0,0,0"
VerticalAlignment="Center" VerticalAlignment="Center"
FontSize="16" FontSize="{DynamicResource TitleFontSize}"
Text="{TemplateBinding Tag}"> Text="{TemplateBinding Tag}">
<TextBlock.Style> <TextBlock.Style>
<Style TargetType="{x:Type TextBlock}"> <Style TargetType="{x:Type TextBlock}">
@@ -98,11 +98,13 @@
<local:CustomSearchBox <local:CustomSearchBox
x:Name="QueryTextBox" x:Name="QueryTextBox"
Grid.Column="1" Grid.Column="1"
MinHeight="0"
Margin="0"
VerticalAlignment="Center" VerticalAlignment="Center"
x:FieldModifier="public" x:FieldModifier="public"
AutomationProperties.Name="{x:Static p:Resources.Query}" AutomationProperties.Name="{x:Static p:Resources.Query}"
Canvas.ZIndex="0" Canvas.ZIndex="0"
FontSize="18" FontSize="{DynamicResource TitleFontSize}"
Style="{StaticResource QueryTextBoxStyle}" Style="{StaticResource QueryTextBoxStyle}"
Tag="{x:Static p:Resources.startTyping}" /> Tag="{x:Static p:Resources.startTyping}" />
<TextBlock <TextBlock
@@ -112,7 +114,7 @@
VerticalAlignment="Center" VerticalAlignment="Center"
x:FieldModifier="public" x:FieldModifier="public"
Canvas.ZIndex="-1" Canvas.ZIndex="-1"
FontSize="18" FontSize="{DynamicResource TitleFontSize}"
Foreground="{DynamicResource TextPlaceholderColorBrush}" /> Foreground="{DynamicResource TextPlaceholderColorBrush}" />
<ui:SymbolIcon <ui:SymbolIcon
AutomationProperties.Name="{x:Static p:Resources.SearchIcon}" AutomationProperties.Name="{x:Static p:Resources.SearchIcon}"

View File

@@ -214,6 +214,7 @@ namespace PowerLauncher
_viewModel.MainWindowVisibility = Visibility.Collapsed; _viewModel.MainWindowVisibility = Visibility.Collapsed;
_viewModel.LoadedAtLeastOnce = true; _viewModel.LoadedAtLeastOnce = true;
_viewModel.SetPluginsOverviewVisibility(); _viewModel.SetPluginsOverviewVisibility();
_viewModel.SetFontSize();
BringProcessToForeground(); BringProcessToForeground();
} }
@@ -357,6 +358,8 @@ namespace PowerLauncher
BringProcessToForeground(); BringProcessToForeground();
_viewModel.SetPluginsOverviewVisibility(); _viewModel.SetPluginsOverviewVisibility();
_viewModel.SetFontSize();
if (_viewModel.Plugins.Count > 0) if (_viewModel.Plugins.Count > 0)
{ {
_viewModel.SelectedPlugin = null; _viewModel.SelectedPlugin = null;

View File

@@ -5,7 +5,6 @@
xmlns:Behaviors="http://schemas.microsoft.com/xaml/behaviors" xmlns:Behaviors="http://schemas.microsoft.com/xaml/behaviors"
xmlns:converters="clr-namespace:PowerLauncher.Converters" xmlns:converters="clr-namespace:PowerLauncher.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:helper="clr-namespace:PowerLauncher.Helper"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:p="clr-namespace:PowerLauncher.Properties" xmlns:p="clr-namespace:PowerLauncher.Properties"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
@@ -59,7 +58,7 @@
<ListView.ItemTemplate> <ListView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Grid <Grid
Height="44" MinHeight="44"
Background="Transparent" Background="Transparent"
ToolTipService.BetweenShowDelay="0" ToolTipService.BetweenShowDelay="0"
ToolTipService.InitialShowDelay="1000"> ToolTipService.InitialShowDelay="1000">
@@ -76,10 +75,6 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ToolTip> <Grid.ToolTip>
<ToolTip <ToolTip
MaxWidth="480" MaxWidth="480"
@@ -109,35 +104,38 @@
VerticalAlignment="Center" VerticalAlignment="Center"
AutomationProperties.Name="{x:Static p:Resources.AppIcon}" AutomationProperties.Name="{x:Static p:Resources.AppIcon}"
Source="{Binding Image}" /> Source="{Binding Image}" />
<TextBlock <StackPanel
x:Name="Title"
Grid.Column="1" Grid.Column="1"
VerticalAlignment="Bottom" VerticalAlignment="Center"
AutomationProperties.Name="{x:Static p:Resources.Title}" Orientation="Vertical">
FontSize="16" <TextBlock
IsHitTestVisible="False" x:Name="Title"
TextTrimming="CharacterEllipsis"> VerticalAlignment="Bottom"
<viewmodel:ResultsViewModel.FormattedText> AutomationProperties.Name="{x:Static p:Resources.Title}"
<MultiBinding Converter="{StaticResource highlightTextConverter}"> FontSize="{DynamicResource TitleFontSize}"
<Binding Path="Result.Title" /> IsHitTestVisible="False"
<Binding Path="Result.TitleHighlightData" /> TextTrimming="CharacterEllipsis">
<Binding Path="IsSelected" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type ListViewItem}}" /> <viewmodel:ResultsViewModel.FormattedText>
</MultiBinding> <MultiBinding Converter="{StaticResource highlightTextConverter}">
</viewmodel:ResultsViewModel.FormattedText> <Binding Path="Result.Title" />
</TextBlock> <Binding Path="Result.TitleHighlightData" />
<TextBlock <Binding Path="IsSelected" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type ListViewItem}}" />
x:Name="Path" </MultiBinding>
Grid.Row="1" </viewmodel:ResultsViewModel.FormattedText>
Grid.Column="1" </TextBlock>
VerticalAlignment="Top" <TextBlock
AutomationProperties.Name="{x:Static p:Resources.Subtitle}" x:Name="Path"
Opacity="0.6" VerticalAlignment="Top"
Style="{StaticResource CaptionTextBlockStyle}" AutomationProperties.Name="{x:Static p:Resources.Subtitle}"
Text="{Binding Result.SubTitle}" Opacity="0.6"
TextTrimming="CharacterEllipsis" /> Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding Result.SubTitle}"
TextTrimming="CharacterEllipsis" />
</StackPanel>
<ListView <ListView
Grid.RowSpan="2"
Grid.Column="2" Grid.Column="2"
Height="44"
HorizontalAlignment="Right" HorizontalAlignment="Right"
VerticalAlignment="Center" VerticalAlignment="Center"
AutomationProperties.Name="{x:Static p:Resources.ContextMenuItemsCollection}" AutomationProperties.Name="{x:Static p:Resources.ContextMenuItemsCollection}"

View File

@@ -180,6 +180,11 @@ namespace PowerLauncher
_settings.ShowPluginsOverview = (PowerToysRunSettings.ShowPluginsOverviewMode)overloadSettings.Properties.ShowPluginsOverview; _settings.ShowPluginsOverview = (PowerToysRunSettings.ShowPluginsOverviewMode)overloadSettings.Properties.ShowPluginsOverview;
} }
if (_settings.TitleFontSize != overloadSettings.Properties.TitleFontSize)
{
_settings.TitleFontSize = overloadSettings.Properties.TitleFontSize;
}
retry = false; retry = false;
} }

View File

@@ -1,4 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:core="clr-namespace:System;assembly=mscorlib">
<core:Double x:Key="TitleFontSize">16</core:Double>
<!-- This removes the selection state of the default WpfUI ListViewItemStyle --> <!-- This removes the selection state of the default WpfUI ListViewItemStyle -->
<Style x:Key="PluginsListViewItemStyle" TargetType="{x:Type ListViewItem}"> <Style x:Key="PluginsListViewItemStyle" TargetType="{x:Type ListViewItem}">

View File

@@ -397,6 +397,11 @@ namespace PowerLauncher.ViewModel
} }
} }
public void SetFontSize()
{
App.Current.Resources["TitleFontSize"] = (double)_settings.TitleFontSize;
}
public bool LastQuerySelected { get; set; } public bool LastQuerySelected { get; set; }
private ResultsViewModel _selectedResults; private ResultsViewModel _selectedResults;

View File

@@ -341,6 +341,8 @@ namespace Wox.Infrastructure.UserSettings
} }
} }
public int TitleFontSize { get; set; } = 16;
public bool IgnoreHotkeysOnFullscreen { get; set; } public bool IgnoreHotkeysOnFullscreen { get; set; }
public bool StartedFromPowerToysRunner { get; set; } public bool StartedFromPowerToysRunner { get; set; }

View File

@@ -51,6 +51,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library
[JsonPropertyName("show_plugins_overview")] [JsonPropertyName("show_plugins_overview")]
public int ShowPluginsOverview { get; set; } public int ShowPluginsOverview { get; set; }
[JsonPropertyName("title_fontsize")]
public int TitleFontSize { get; set; }
[JsonPropertyName("startupPosition")] [JsonPropertyName("startupPosition")]
public StartupPosition Position { get; set; } public StartupPosition Position { get; set; }
@@ -111,6 +114,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
GenerateThumbnailsFromFiles = true; GenerateThumbnailsFromFiles = true;
UsePinyin = false; UsePinyin = false;
ShowPluginsOverview = 0; ShowPluginsOverview = 0;
TitleFontSize = 16;
} }
} }
} }

View File

@@ -83,6 +83,7 @@ namespace ViewModelTests
Assert.AreEqual(originalSettings.Properties.GenerateThumbnailsFromFiles, viewModel.GenerateThumbnailsFromFiles); Assert.AreEqual(originalSettings.Properties.GenerateThumbnailsFromFiles, viewModel.GenerateThumbnailsFromFiles);
Assert.AreEqual(originalSettings.Properties.UsePinyin, viewModel.UsePinyin); Assert.AreEqual(originalSettings.Properties.UsePinyin, viewModel.UsePinyin);
Assert.AreEqual(originalSettings.Properties.ShowPluginsOverview, viewModel.ShowPluginsOverviewIndex); Assert.AreEqual(originalSettings.Properties.ShowPluginsOverview, viewModel.ShowPluginsOverviewIndex);
Assert.AreEqual(originalSettings.Properties.TitleFontSize, viewModel.TitleFontSize);
// Verify that the stub file was used // Verify that the stub file was used
var expectedCallCount = 2; // once via the view model, and once by the test (GetSettings<T>) var expectedCallCount = 2; // once via the view model, and once by the test (GetSettings<T>)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -209,6 +209,33 @@
<ComboBoxItem x:Uid="ShowPluginsOverview_None" /> <ComboBoxItem x:Uid="ShowPluginsOverview_None" />
</ComboBox> </ComboBox>
</controls:SettingsCard> </controls:SettingsCard>
<controls:SettingsCard x:Uid="PowerLauncher_TitleFontSize" HeaderIcon="{ui:FontIcon Glyph=&#xE8E9;}">
<StackPanel Orientation="Horizontal" Spacing="12">
<TextBlock
VerticalAlignment="Center"
AutomationProperties.AccessibilityView="Raw"
FontSize="12"
FontWeight="SemiBold"
Text="A" />
<Slider
x:Uid="PowerLauncher_TextFontSizeSlider"
LargeChange="2"
Maximum="24"
Minimum="12"
SmallChange="2"
StepFrequency="2"
TickFrequency="2"
TickPlacement="Outside"
Value="{x:Bind ViewModel.TitleFontSize, Mode=TwoWay}" />
<TextBlock
VerticalAlignment="Center"
AutomationProperties.AccessibilityView="Raw"
FontSize="24"
FontWeight="SemiBold"
Text="A" />
</StackPanel>
</controls:SettingsCard>
</custom:SettingsGroup> </custom:SettingsGroup>
<custom:SettingsGroup x:Uid="PowerLauncher_Plugins" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}"> <custom:SettingsGroup x:Uid="PowerLauncher_Plugins" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.EnablePowerLauncher}">

View File

@@ -59,10 +59,7 @@
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
xmlns=""
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
@@ -3916,4 +3913,13 @@ Activate by holding the key for the character you want to add an accent to, then
<data name="ShowPluginsOverview_NonGlobal.Content" xml:space="preserve"> <data name="ShowPluginsOverview_NonGlobal.Content" xml:space="preserve">
<value>Not included in global results</value> <value>Not included in global results</value>
</data> </data>
<data name="PowerLauncher_TitleFontSize.Description" xml:space="preserve">
<value>The size of result titles and the search query</value>
</data>
<data name="PowerLauncher_TitleFontSize.Header" xml:space="preserve">
<value>Text size (pt)</value>
</data>
<data name="PowerLauncher_TextFontSizeSlider.[using:Microsoft.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Text size of result titles</value>
</data>
</root> </root>

View File

@@ -614,6 +614,23 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
} }
} }
public int TitleFontSize
{
get
{
return settings.Properties.TitleFontSize;
}
set
{
if (settings.Properties.TitleFontSize != value)
{
settings.Properties.TitleFontSize = value;
UpdateSettings();
}
}
}
private ObservableCollection<PowerLauncherPluginViewModel> _plugins; private ObservableCollection<PowerLauncherPluginViewModel> _plugins;
public ObservableCollection<PowerLauncherPluginViewModel> Plugins public ObservableCollection<PowerLauncherPluginViewModel> Plugins