Skip to content

Commit f485e86

Browse files
committed
Support placeholder text
1 parent 697fb72 commit f485e86

File tree

6 files changed

+83
-4
lines changed

6 files changed

+83
-4
lines changed

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,17 @@ public string Theme
113113
public double? SettingWindowLeft { get; set; } = null;
114114
public System.Windows.WindowState SettingWindowState { get; set; } = WindowState.Normal;
115115

116+
bool _showPlaceholder { get; set; } = true;
117+
public bool ShowPlaceholder
118+
{
119+
get => _showPlaceholder;
120+
set
121+
{
122+
_showPlaceholder = value;
123+
OnPropertyChanged();
124+
}
125+
}
126+
116127
public int CustomExplorerIndex { get; set; } = 0;
117128

118129
[JsonIgnore]

Flow.Launcher/Languages/en.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<system:String x:Key="GameMode">Game Mode</system:String>
4040
<system:String x:Key="GameModeToolTip">Suspend the use of Hotkeys.</system:String>
4141
<system:String x:Key="PositionReset">Position Reset</system:String>
42-
<system:String x:Key="PositionResetToolTip">Reset search window position</system:String>
42+
<system:String x:Key="queryTextBoxSuggestion">Type here to search</system:String>
4343

4444
<!-- Setting General -->
4545
<system:String x:Key="flowlauncher_settings">Settings</system:String>
@@ -202,6 +202,8 @@
202202
<system:String x:Key="Date">Date</system:String>
203203
<system:String x:Key="TypeIsDarkToolTip">This theme supports two(light/dark) modes.</system:String>
204204
<system:String x:Key="TypeHasBlurToolTip">This theme supports Blur Transparent Background.</system:String>
205+
<system:String x:Key="PlaceholderText">Placeholder Text</system:String>
206+
<system:String x:Key="PlaceholderTextTip">Display placeholder text when query is empty</system:String>
205207

206208
<!-- Setting Hotkey -->
207209
<system:String x:Key="hotkey">Hotkey</system:String>

Flow.Launcher/MainWindow.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@
218218
<Grid x:Name="QueryBoxArea">
219219
<Border MinHeight="30" Style="{DynamicResource QueryBoxBgStyle}">
220220
<Grid>
221+
<TextBox
222+
x:Name="QueryTextPlaceholderBox"
223+
Height="{Binding MainWindowHeight, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
224+
FontSize="{Binding QueryBoxFontSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
225+
IsEnabled="False"
226+
Style="{DynamicResource QuerySuggestionBoxStyle}"
227+
Text="{DynamicResource queryTextBoxSuggestion}"
228+
Visibility="Collapsed" />
221229
<TextBox
222230
x:Name="QueryTextSuggestionBox"
223231
Height="{Binding MainWindowHeight, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
115115
welcomeWindow.Show();
116116
}
117117

118+
// Initialize place holder
119+
SetupPlaceholderText();
120+
118121
// Hide window if need
119122
UpdatePosition();
120123
if (_settings.HideOnStartup)
@@ -237,6 +240,9 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
237240
case nameof(Settings.WindowTop):
238241
Top = _settings.WindowTop;
239242
break;
243+
case nameof(Settings.ShowPlaceholder):
244+
SetupPlaceholderText();
245+
break;
240246
}
241247
};
242248

@@ -1028,6 +1034,43 @@ private void QueryTextBox_OnPreviewDragOver(object sender, DragEventArgs e)
10281034

10291035
#endregion
10301036

1037+
#region Placeholder
1038+
1039+
private void SetupPlaceholderText()
1040+
{
1041+
if (_settings.ShowPlaceholder)
1042+
{
1043+
QueryTextBox.TextChanged += QueryTextBox_TextChanged;
1044+
QueryTextSuggestionBox.TextChanged += QueryTextSuggestionBox_TextChanged;
1045+
SetPlaceholderText();
1046+
}
1047+
else
1048+
{
1049+
QueryTextBox.TextChanged -= QueryTextBox_TextChanged;
1050+
QueryTextSuggestionBox.TextChanged -= QueryTextSuggestionBox_TextChanged;
1051+
QueryTextPlaceholderBox.Visibility = Visibility.Collapsed;
1052+
}
1053+
}
1054+
1055+
private void QueryTextBox_TextChanged(object sender, TextChangedEventArgs e)
1056+
{
1057+
SetPlaceholderText();
1058+
}
1059+
1060+
private void QueryTextSuggestionBox_TextChanged(object sender, TextChangedEventArgs e)
1061+
{
1062+
SetPlaceholderText();
1063+
}
1064+
1065+
private void SetPlaceholderText()
1066+
{
1067+
var queryText = QueryTextBox.Text;
1068+
var suggestionText = QueryTextSuggestionBox.Text;
1069+
QueryTextPlaceholderBox.Visibility = string.IsNullOrEmpty(queryText) && string.IsNullOrEmpty(suggestionText) ? Visibility.Visible : Visibility.Collapsed;
1070+
}
1071+
1072+
#endregion
1073+
10311074
#region IDisposable
10321075

10331076
protected virtual void Dispose(bool disposing)

Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ public double SoundEffectVolume
259259
set => Settings.SoundVolume = value;
260260
}
261261

262+
public bool ShowPlaceholder
263+
{
264+
get => Settings.ShowPlaceholder;
265+
set => Settings.ShowPlaceholder = value;
266+
}
267+
262268
public bool UseClock
263269
{
264270
get => Settings.UseClock;

Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,6 @@
477477
<!-- ✅ 추가 -->
478478
</cc:Card>
479479

480-
481480
<!-- Drop shadow effect -->
482481
<cc:Card
483482
Title="{DynamicResource queryWindowShadowEffect}"
@@ -496,8 +495,6 @@
496495
Text="{DynamicResource browserMoreThemes}"
497496
Uri="{Binding LinkThemeGallery}" />
498497

499-
500-
501498
<!-- Fixed Height -->
502499
<cc:CardGroup Margin="0 20 0 0">
503500
<cc:Card
@@ -529,6 +526,18 @@
529526
OnContent="{DynamicResource enable}" />
530527
</cc:Card>
531528

529+
<!-- Placeholder text -->
530+
<cc:Card
531+
Title="{DynamicResource PlaceholderText}"
532+
Margin="0 14 0 0"
533+
Icon="&#xE82F;"
534+
Sub="{DynamicResource PlaceholderTextTip}">
535+
<ui:ToggleSwitch
536+
IsOn="{Binding ShowPlaceholder}"
537+
OffContent="{DynamicResource disable}"
538+
OnContent="{DynamicResource enable}" />
539+
</cc:Card>
540+
532541
<!-- Time and date -->
533542
<cc:CardGroup Margin="0 14 0 0">
534543
<cc:Card Title="{DynamicResource Clock}" Icon="&#xec92;">

0 commit comments

Comments
 (0)