Support placeholder size change

This commit is contained in:
Jack251970 2025-03-29 15:08:49 +08:00
parent c74dd20088
commit 84f2686710
7 changed files with 65 additions and 13 deletions

View file

@ -134,6 +134,16 @@ namespace Flow.Launcher.Infrastructure.UserSettings
OnPropertyChanged();
}
}
string _placeholderText { get; set; } = string.Empty;
public string PlaceholderText
{
get => _placeholderText;
set
{
_placeholderText = value;
OnPropertyChanged();
}
}
public int CustomExplorerIndex { get; set; } = 0;

View file

@ -202,8 +202,10 @@
<system:String x:Key="BackdropTypesMicaAlt">Mica Alt</system:String>
<system:String x:Key="TypeIsDarkToolTip">This theme supports two(light/dark) modes.</system:String>
<system:String x:Key="TypeHasBlurToolTip">This theme supports Blur Transparent Background.</system:String>
<system:String x:Key="PlaceholderText">Placeholder Text</system:String>
<system:String x:Key="PlaceholderTextTip">Display placeholder text when query is empty</system:String>
<system:String x:Key="ShowPlaceholder">Show placeholder</system:String>
<system:String x:Key="ShowPlaceholderTip">Display placeholder when query is empty</system:String>
<system:String x:Key="PlaceholderText">Placeholder text</system:String>
<system:String x:Key="PlaceholderTextTip">Change placeholder text. Input empty will use: Type here to search</system:String>
<system:String x:Key="ResizeWindow">Allow window size change</system:String>
<system:String x:Key="ResizeWindowTip">Allow dragging the search window edges to change its size</system:String>

View file

@ -224,7 +224,7 @@
FontSize="{Binding QueryBoxFontSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
IsEnabled="False"
Style="{DynamicResource QuerySuggestionBoxStyle}"
Text="{DynamicResource queryTextBoxSuggestion}"
Text="{Binding PlaceholderText, Mode=OneWay}"
Visibility="Collapsed" />
<TextBox
x:Name="QueryTextSuggestionBox"

View file

@ -118,6 +118,7 @@ namespace Flow.Launcher
// Initialize place holder
SetupPlaceholderText();
_viewModel.PlaceholderText = _settings.PlaceholderText;
// Hide window if need
UpdatePosition();
@ -248,6 +249,9 @@ namespace Flow.Launcher
case nameof(Settings.ShowPlaceholder):
SetupPlaceholderText();
break;
case nameof(Settings.PlaceholderText):
_viewModel.PlaceholderText = _settings.PlaceholderText;
break;
case nameof(Settings.ResizeWindow):
SetupResizeMode();
break;

View file

@ -271,6 +271,12 @@ public partial class SettingsPaneThemeViewModel : BaseModel
set => Settings.ShowPlaceholder = value;
}
public string PlaceholderText
{
get => Settings.PlaceholderText;
set => Settings.PlaceholderText = value;
}
public bool UseClock
{
get => Settings.UseClock;

View file

@ -70,6 +70,7 @@
<ColumnDefinition Width="8*" />
<ColumnDefinition MaxWidth="250" Style="{StaticResource SecondColumnStyle}" />
</Grid.ColumnDefinitions>
<!-- Theme Size Editor -->
<Border
Grid.Column="1"
@ -542,16 +543,27 @@
</cc:Card>
<!-- Placeholder text -->
<cc:Card
Title="{DynamicResource PlaceholderText}"
Margin="0 14 0 0"
Icon="&#xE82F;"
Sub="{DynamicResource PlaceholderTextTip}">
<ui:ToggleSwitch
IsOn="{Binding ShowPlaceholder}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}" />
</cc:Card>
<cc:CardGroup Margin="0 14 0 0">
<cc:Card
Title="{DynamicResource ShowPlaceholder}"
Icon="&#xE82F;"
Sub="{DynamicResource ShowPlaceholderTip}">
<ui:ToggleSwitch
IsOn="{Binding ShowPlaceholder}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}" />
</cc:Card>
<cc:Card
Title="{DynamicResource PlaceholderText}"
Icon="&#xED59;"
Sub="{DynamicResource PlaceholderTextTip}">
<TextBox
MinWidth="80"
Text="{Binding PlaceholderText}"
TextWrapping="NoWrap" />
</cc:Card>
</cc:CardGroup>
<!-- Time and date -->
<cc:CardGroup Margin="0 14 0 0">

View file

@ -765,6 +765,24 @@ namespace Flow.Launcher.ViewModel
public double ClockPanelOpacity { get; set; } = 1;
public double SearchIconOpacity { get; set; } = 1;
private string _placeholderText;
public string PlaceholderText
{
get => _placeholderText;
set
{
if (string.IsNullOrEmpty(value))
{
_placeholderText = App.API.GetTranslation("queryTextBoxSuggestion");
}
else
{
_placeholderText = value;
}
OnPropertyChanged();
}
}
public double MainWindowWidth
{
get => Settings.WindowSize;