-
-
Notifications
You must be signed in to change notification settings - Fork 448
Support Placeholder Text & Toggle Resize Search Window Mode #3396
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
Changes from 5 commits
f485e86
a4dac91
1a97a42
c74dd20
84f2686
91c5e84
10d4387
6f32a6f
78b6617
714860e
f160670
356f229
cd01260
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
using System.Windows.Media; | ||
using System.Windows.Media.Animation; | ||
using System.Windows.Shapes; | ||
using System.Windows.Shell; | ||
using System.Windows.Threading; | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using Flow.Launcher.Core.Plugin; | ||
|
@@ -115,6 +116,10 @@ private async void OnLoaded(object sender, RoutedEventArgs _) | |
welcomeWindow.Show(); | ||
} | ||
|
||
// Initialize place holder | ||
SetupPlaceholderText(); | ||
_viewModel.PlaceholderText = _settings.PlaceholderText; | ||
|
||
// Hide window if need | ||
UpdatePosition(); | ||
if (_settings.HideOnStartup) | ||
|
@@ -146,13 +151,17 @@ private async void OnLoaded(object sender, RoutedEventArgs _) | |
UpdatePosition(); | ||
|
||
// Refresh frame | ||
await Ioc.Default.GetRequiredService<Theme>().RefreshFrameAsync(); | ||
await _theme.RefreshFrameAsync(); | ||
|
||
// Initialize resize mode after refreshing frame | ||
SetupResizeMode(); | ||
|
||
// Reset preview | ||
_viewModel.ResetPreview(); | ||
|
||
// Since the default main window visibility is visible, so we need set focus during startup | ||
QueryTextBox.Focus(); | ||
|
||
// Set the initial state of the QueryTextBoxCursorMovedToEnd property | ||
// Without this part, when shown for the first time, switching the context menu does not move the cursor to the end. | ||
_viewModel.QueryTextCursorMovedToEnd = false; | ||
|
@@ -237,6 +246,15 @@ private async void OnLoaded(object sender, RoutedEventArgs _) | |
case nameof(Settings.WindowTop): | ||
Top = _settings.WindowTop; | ||
break; | ||
case nameof(Settings.ShowPlaceholder): | ||
SetupPlaceholderText(); | ||
break; | ||
case nameof(Settings.PlaceholderText): | ||
_viewModel.PlaceholderText = _settings.PlaceholderText; | ||
break; | ||
case nameof(Settings.ResizeWindow): | ||
SetupResizeMode(); | ||
break; | ||
} | ||
}; | ||
|
||
|
@@ -1028,6 +1046,56 @@ private void QueryTextBox_OnPreviewDragOver(object sender, DragEventArgs e) | |
|
||
#endregion | ||
|
||
#region Placeholder | ||
|
||
private void SetupPlaceholderText() | ||
{ | ||
if (_settings.ShowPlaceholder) | ||
{ | ||
QueryTextBox.TextChanged += QueryTextBox_TextChanged; | ||
QueryTextSuggestionBox.TextChanged += QueryTextSuggestionBox_TextChanged; | ||
SetPlaceholderText(); | ||
} | ||
else | ||
{ | ||
QueryTextBox.TextChanged -= QueryTextBox_TextChanged; | ||
QueryTextSuggestionBox.TextChanged -= QueryTextSuggestionBox_TextChanged; | ||
QueryTextPlaceholderBox.Visibility = Visibility.Collapsed; | ||
} | ||
} | ||
Comment on lines
+1056
to
+1072
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainConsider event handler cleanup in Dispose method. Event handlers are correctly added/removed based on settings, but consider also ensuring these handlers are detached in the 🏁 Script executed: #!/bin/bash
# Check if event handlers are properly cleaned up in Dispose method
echo "Checking MainWindow.xaml.cs for event handler cleanup in Dispose method..."
rg -A 5 -B 5 "Dispose\(bool disposing\)" Flow.Launcher/MainWindow.xaml.cs Length of output: 708 Event Handler Cleanup in Dispose Method Needed The setup in
|
||
|
||
private void QueryTextBox_TextChanged(object sender, TextChangedEventArgs e) | ||
{ | ||
SetPlaceholderText(); | ||
} | ||
|
||
private void QueryTextSuggestionBox_TextChanged(object sender, TextChangedEventArgs e) | ||
{ | ||
SetPlaceholderText(); | ||
} | ||
|
||
private void SetPlaceholderText() | ||
{ | ||
var queryText = QueryTextBox.Text; | ||
var suggestionText = QueryTextSuggestionBox.Text; | ||
QueryTextPlaceholderBox.Visibility = string.IsNullOrEmpty(queryText) && string.IsNullOrEmpty(suggestionText) ? Visibility.Visible : Visibility.Collapsed; | ||
} | ||
|
||
#endregion | ||
|
||
#region Resize Mode | ||
|
||
private void SetupResizeMode() | ||
{ | ||
ResizeMode = _settings.ResizeWindow ? ResizeMode.CanResize : ResizeMode.NoResize; | ||
if (WindowChrome.GetWindowChrome(this) is WindowChrome windowChrome) | ||
{ | ||
_theme.SetResizeBoarderThickness(windowChrome, _settings.ResizeWindow); | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
#region IDisposable | ||
|
||
protected virtual void Dispose(bool disposing) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Jack251970 Man~!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh no
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see #3448