Refresh interface when Home Page is changed

This commit is contained in:
Jack251970 2025-05-03 22:54:46 +08:00
parent f2f4ebf0ac
commit 96bb62af27
4 changed files with 34 additions and 7 deletions

View file

@ -159,7 +159,20 @@ namespace Flow.Launcher.Infrastructure.UserSettings
}
}
public bool ShowHomePage { get; set; } = true;
private bool _showHomePage { get; set; } = true;
public bool ShowHomePage
{
get => _showHomePage;
set
{
if (_showHomePage != value)
{
_showHomePage = value;
OnPropertyChanged();
}
}
}
public bool ShowHistoryResultsForHomePage { get; set; } = false;
public int MaxHistoryResultsToShowForHomePage { get; set; } = 5;

View file

@ -277,6 +277,17 @@ namespace Flow.Launcher
case nameof(Settings.SettingWindowFont):
InitializeContextMenu();
break;
case nameof(Settings.ShowHomePage):
// We should refresh results when these two settings are changed but we cannot do that
// Because the order of the results will change, making the interface look weird
// So we would better refresh results when query text is changed next time
/*case nameof(Settings.ShowHistoryResultsForHomePage):
case nameof(Settings.MaxHistoryResultsToShowForHomePage):*/
if (string.IsNullOrEmpty(_viewModel.QueryText))
{
_viewModel.QueryResults();
}
break;
}
};
@ -294,7 +305,10 @@ namespace Flow.Launcher
.AddValueChanged(History, (s, e) => UpdateClockPanelVisibility());
// Initialize query state
_viewModel.InitializeQuery();
if (_settings.ShowHomePage && string.IsNullOrEmpty(_viewModel.QueryText))
{
_viewModel.QueryResults();
}
}
private async void OnClosing(object sender, CancelEventArgs e)

View file

@ -1080,12 +1080,9 @@ namespace Flow.Launcher.ViewModel
#region Query
public void InitializeQuery()
public void QueryResults()
{
if (Settings.ShowHomePage)
{
_ = QueryResultsAsync(false);
}
_ = QueryResultsAsync(false);
}
public void Query(bool searchDelay, bool isReQuery = false)

View file

@ -82,6 +82,9 @@ namespace Flow.Launcher.ViewModel
{
PluginPair.Metadata.HomeDisabled = !value;
PluginSettingsObject.HomeDiabled = !value;
// We should refresh results when these two settings are changed but we cannot do that
// Because the order of the results will change, making the interface look weird
// So we would better refresh results when query text is changed next time
}
}