mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
More refreshing
This commit is contained in:
@@ -69,7 +69,7 @@
|
|||||||
This is present due to a bug in CsWinRT where WPF projects cause the analyzer to fail.
|
This is present due to a bug in CsWinRT where WPF projects cause the analyzer to fail.
|
||||||
-->
|
-->
|
||||||
<PackageVersion Include="Microsoft.Windows.CsWinRT" Version="2.2.0" />
|
<PackageVersion Include="Microsoft.Windows.CsWinRT" Version="2.2.0" />
|
||||||
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.6901" />
|
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.7175" />
|
||||||
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.8.250907003" />
|
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.8.250907003" />
|
||||||
<PackageVersion Include="Microsoft.WindowsAppSDK.AI" Version="1.8.37" />
|
<PackageVersion Include="Microsoft.WindowsAppSDK.AI" Version="1.8.37" />
|
||||||
<PackageVersion Include="Microsoft.WindowsAppSDK.Runtime" Version="1.8.250907003" />
|
<PackageVersion Include="Microsoft.WindowsAppSDK.Runtime" Version="1.8.250907003" />
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||||
|
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||||
|
<RootNamespace>Microsoft.CmdPal.UI.Core</RootNamespace>
|
||||||
|
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
|
||||||
|
<UseWinUI>true</UseWinUI>
|
||||||
|
<WinUISDKReferences>false</WinUISDKReferences>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -9,6 +9,7 @@ using System.Text.Json.Nodes;
|
|||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using ManagedCommon;
|
using ManagedCommon;
|
||||||
|
using Microsoft.CmdPal.UI.ViewModels.Services;
|
||||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||||
using Windows.Foundation;
|
using Windows.Foundation;
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ public partial class AppStateModel : ObservableObject
|
|||||||
// STATE HERE
|
// STATE HERE
|
||||||
// Make sure that you make the setters public (JsonSerializer.Deserialize will fail silently otherwise)!
|
// Make sure that you make the setters public (JsonSerializer.Deserialize will fail silently otherwise)!
|
||||||
// Make sure that any new types you add are added to JsonSerializationContext!
|
// Make sure that any new types you add are added to JsonSerializationContext!
|
||||||
public RecentCommandsManager RecentCommands { get; set; } = new();
|
public RecentCommandsService RecentCommands { get; set; } = new();
|
||||||
|
|
||||||
public List<string> RunHistory { get; set; } = [];
|
public List<string> RunHistory { get; set; } = [];
|
||||||
|
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ public sealed partial class CommandProviderWrapper
|
|||||||
private void CommandProvider_ItemsChanged(object sender, IItemsChangedEventArgs args) =>
|
private void CommandProvider_ItemsChanged(object sender, IItemsChangedEventArgs args) =>
|
||||||
|
|
||||||
// We don't want to handle this ourselves - we want the
|
// We don't want to handle this ourselves - we want the
|
||||||
// TopLevelCommandManager to know about this, so they can remove
|
// TopLevelCommandService to know about this, so they can remove
|
||||||
// our old commands from their own list.
|
// our old commands from their own list.
|
||||||
//
|
//
|
||||||
// In handling this, a call will be made to `LoadTopLevelCommands` to
|
// In handling this, a call will be made to `LoadTopLevelCommands` to
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using Microsoft.CmdPal.Ext.Apps.Programs;
|
|||||||
using Microsoft.CmdPal.Ext.Apps.State;
|
using Microsoft.CmdPal.Ext.Apps.State;
|
||||||
using Microsoft.CmdPal.UI.ViewModels.Messages;
|
using Microsoft.CmdPal.UI.ViewModels.Messages;
|
||||||
using Microsoft.CmdPal.UI.ViewModels.Properties;
|
using Microsoft.CmdPal.UI.ViewModels.Properties;
|
||||||
|
using Microsoft.CmdPal.UI.ViewModels.Services;
|
||||||
using Microsoft.CommandPalette.Extensions;
|
using Microsoft.CommandPalette.Extensions;
|
||||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||||
|
|
||||||
@@ -38,9 +39,9 @@ public partial class MainListPage : DynamicListPage,
|
|||||||
"com.microsoft.cmdpal.builtin.remotedesktop",
|
"com.microsoft.cmdpal.builtin.remotedesktop",
|
||||||
];
|
];
|
||||||
|
|
||||||
private readonly TopLevelCommandManager _tlcManager;
|
private readonly TopLevelCommandService _tlcService;
|
||||||
private readonly SettingsModel _settingsModel;
|
private readonly SettingsModel _settingsModel;
|
||||||
private readonly AliasManager _aliasManager;
|
private readonly AliasService _aliasService;
|
||||||
private readonly AppStateModel _appStateModel;
|
private readonly AppStateModel _appStateModel;
|
||||||
private List<Scored<IListItem>>? _filteredItems;
|
private List<Scored<IListItem>>? _filteredItems;
|
||||||
private List<Scored<IListItem>>? _filteredApps;
|
private List<Scored<IListItem>>? _filteredApps;
|
||||||
@@ -55,18 +56,22 @@ public partial class MainListPage : DynamicListPage,
|
|||||||
|
|
||||||
private CancellationTokenSource? _cancellationTokenSource;
|
private CancellationTokenSource? _cancellationTokenSource;
|
||||||
|
|
||||||
public MainListPage(TopLevelCommandManager topLevelCommandManager, SettingsModel settingsModel, AliasManager aliasManager, AppStateModel appStateModel)
|
public MainListPage(
|
||||||
|
TopLevelCommandService topLevelCommandService,
|
||||||
|
SettingsModel settingsModel,
|
||||||
|
AliasService aliasService,
|
||||||
|
AppStateModel appStateModel)
|
||||||
{
|
{
|
||||||
Title = Resources.builtin_home_name;
|
Title = Resources.builtin_home_name;
|
||||||
Icon = IconHelpers.FromRelativePath("Assets\\StoreLogo.scale-200.png");
|
Icon = IconHelpers.FromRelativePath("Assets\\StoreLogo.scale-200.png");
|
||||||
PlaceholderText = Properties.Resources.builtin_main_list_page_searchbar_placeholder;
|
PlaceholderText = Properties.Resources.builtin_main_list_page_searchbar_placeholder;
|
||||||
|
|
||||||
_aliasManager = aliasManager;
|
_aliasService = aliasService;
|
||||||
_appStateModel = appStateModel;
|
_appStateModel = appStateModel;
|
||||||
|
|
||||||
_tlcManager = topLevelCommandManager;
|
_tlcService = topLevelCommandService;
|
||||||
_tlcManager.PropertyChanged += TlcManager_PropertyChanged;
|
_tlcService.PropertyChanged += TlcManager_PropertyChanged;
|
||||||
_tlcManager.TopLevelCommands.CollectionChanged += Commands_CollectionChanged;
|
_tlcService.TopLevelCommands.CollectionChanged += Commands_CollectionChanged;
|
||||||
|
|
||||||
// The all apps page will kick off a BG thread to start loading apps.
|
// The all apps page will kick off a BG thread to start loading apps.
|
||||||
// We just want to know when it is done.
|
// We just want to know when it is done.
|
||||||
@@ -85,7 +90,7 @@ public partial class MainListPage : DynamicListPage,
|
|||||||
_settingsModel = settingsModel;
|
_settingsModel = settingsModel;
|
||||||
_settingsModel.SettingsChanged += SettingsChangedHandler;
|
_settingsModel.SettingsChanged += SettingsChangedHandler;
|
||||||
HotReloadSettings(_settingsModel);
|
HotReloadSettings(_settingsModel);
|
||||||
_includeApps = _tlcManager.IsProviderActive(AllAppsCommandProvider.WellKnownId);
|
_includeApps = _tlcService.IsProviderActive(AllAppsCommandProvider.WellKnownId);
|
||||||
|
|
||||||
IsLoading = true;
|
IsLoading = true;
|
||||||
}
|
}
|
||||||
@@ -100,7 +105,7 @@ public partial class MainListPage : DynamicListPage,
|
|||||||
|
|
||||||
private void Commands_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
|
private void Commands_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
_includeApps = _tlcManager.IsProviderActive(AllAppsCommandProvider.WellKnownId);
|
_includeApps = _tlcService.IsProviderActive(AllAppsCommandProvider.WellKnownId);
|
||||||
if (_includeApps != _filteredItemsIncludesApps)
|
if (_includeApps != _filteredItemsIncludesApps)
|
||||||
{
|
{
|
||||||
ReapplySearchInBackground();
|
ReapplySearchInBackground();
|
||||||
@@ -129,7 +134,7 @@ public partial class MainListPage : DynamicListPage,
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
_refreshRequested.Clear();
|
_refreshRequested.Clear();
|
||||||
lock (_tlcManager.TopLevelCommands)
|
lock (_tlcService.TopLevelCommands)
|
||||||
{
|
{
|
||||||
if (_filteredItemsIncludesApps == _includeApps)
|
if (_filteredItemsIncludesApps == _includeApps)
|
||||||
{
|
{
|
||||||
@@ -160,9 +165,9 @@ public partial class MainListPage : DynamicListPage,
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(SearchText))
|
if (string.IsNullOrEmpty(SearchText))
|
||||||
{
|
{
|
||||||
lock (_tlcManager.TopLevelCommands)
|
lock (_tlcService.TopLevelCommands)
|
||||||
{
|
{
|
||||||
return _tlcManager
|
return _tlcService
|
||||||
.TopLevelCommands
|
.TopLevelCommands
|
||||||
.Where(tlc => !string.IsNullOrEmpty(tlc.Title))
|
.Where(tlc => !string.IsNullOrEmpty(tlc.Title))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
@@ -170,7 +175,7 @@ public partial class MainListPage : DynamicListPage,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lock (_tlcManager.TopLevelCommands)
|
lock (_tlcService.TopLevelCommands)
|
||||||
{
|
{
|
||||||
var limitedApps = new List<Scored<IListItem>>();
|
var limitedApps = new List<Scored<IListItem>>();
|
||||||
|
|
||||||
@@ -228,11 +233,11 @@ public partial class MainListPage : DynamicListPage,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_aliasManager.CheckAlias(newSearch))
|
if (_aliasService.CheckAlias(newSearch))
|
||||||
{
|
{
|
||||||
if (_filteredItemsIncludesApps != _includeApps)
|
if (_filteredItemsIncludesApps != _includeApps)
|
||||||
{
|
{
|
||||||
lock (_tlcManager.TopLevelCommands)
|
lock (_tlcService.TopLevelCommands)
|
||||||
{
|
{
|
||||||
_filteredItemsIncludesApps = _includeApps;
|
_filteredItemsIncludesApps = _includeApps;
|
||||||
ClearResults();
|
ClearResults();
|
||||||
@@ -248,7 +253,7 @@ public partial class MainListPage : DynamicListPage,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var commands = _tlcManager.TopLevelCommands;
|
var commands = _tlcService.TopLevelCommands;
|
||||||
lock (commands)
|
lock (commands)
|
||||||
{
|
{
|
||||||
if (token.IsCancellationRequested)
|
if (token.IsCancellationRequested)
|
||||||
@@ -486,13 +491,13 @@ public partial class MainListPage : DynamicListPage,
|
|||||||
private bool ActuallyLoading()
|
private bool ActuallyLoading()
|
||||||
{
|
{
|
||||||
var allApps = AllAppsCommandProvider.Page;
|
var allApps = AllAppsCommandProvider.Page;
|
||||||
return allApps.IsLoading || _tlcManager.IsLoading;
|
return allApps.IsLoading || _tlcService.IsLoading;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Almost verbatim ListHelpers.ScoreListItem, but also accounting for the
|
// Almost verbatim ListHelpers.ScoreListItem, but also accounting for the
|
||||||
// fact that we want fallback handlers down-weighted, so that they don't
|
// fact that we want fallback handlers down-weighted, so that they don't
|
||||||
// _always_ show up first.
|
// _always_ show up first.
|
||||||
internal static int ScoreTopLevelItem(string query, IListItem topLevelOrAppItem, IRecentCommandsManager history)
|
internal static int ScoreTopLevelItem(string query, IListItem topLevelOrAppItem, IRecentCommandsService history)
|
||||||
{
|
{
|
||||||
var title = topLevelOrAppItem.Title;
|
var title = topLevelOrAppItem.Title;
|
||||||
if (string.IsNullOrWhiteSpace(title))
|
if (string.IsNullOrWhiteSpace(title))
|
||||||
@@ -601,7 +606,7 @@ public partial class MainListPage : DynamicListPage,
|
|||||||
|
|
||||||
public void Receive(ClearSearchMessage message) => SearchText = string.Empty;
|
public void Receive(ClearSearchMessage message) => SearchText = string.Empty;
|
||||||
|
|
||||||
public void Receive(UpdateFallbackItemsMessage message) => RaiseItemsChanged(_tlcManager.TopLevelCommands.Count);
|
public void Receive(UpdateFallbackItemsMessage message) => RaiseItemsChanged(_tlcService.TopLevelCommands.Count);
|
||||||
|
|
||||||
private void SettingsChangedHandler(SettingsModel sender, object? args) => HotReloadSettings(sender);
|
private void SettingsChangedHandler(SettingsModel sender, object? args) => HotReloadSettings(sender);
|
||||||
|
|
||||||
@@ -612,8 +617,8 @@ public partial class MainListPage : DynamicListPage,
|
|||||||
_cancellationTokenSource?.Cancel();
|
_cancellationTokenSource?.Cancel();
|
||||||
_cancellationTokenSource?.Dispose();
|
_cancellationTokenSource?.Dispose();
|
||||||
|
|
||||||
_tlcManager.PropertyChanged -= TlcManager_PropertyChanged;
|
_tlcService.PropertyChanged -= TlcManager_PropertyChanged;
|
||||||
_tlcManager.TopLevelCommands.CollectionChanged -= Commands_CollectionChanged;
|
_tlcService.TopLevelCommands.CollectionChanged -= Commands_CollectionChanged;
|
||||||
|
|
||||||
if (_settingsModel is not null)
|
if (_settingsModel is not null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,12 +13,11 @@ using Microsoft.CmdPal.Core.Common.Helpers;
|
|||||||
using Microsoft.CmdPal.Core.Common.Services;
|
using Microsoft.CmdPal.Core.Common.Services;
|
||||||
using Microsoft.CmdPal.Core.ViewModels;
|
using Microsoft.CmdPal.Core.ViewModels;
|
||||||
using Microsoft.CmdPal.UI.ViewModels.Messages;
|
using Microsoft.CmdPal.UI.ViewModels.Messages;
|
||||||
using Microsoft.CmdPal.UI.ViewModels.Services;
|
|
||||||
using Microsoft.CommandPalette.Extensions;
|
using Microsoft.CommandPalette.Extensions;
|
||||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Microsoft.CmdPal.UI.ViewModels.ViewModels;
|
namespace Microsoft.CmdPal.UI.ViewModels.Services;
|
||||||
|
|
||||||
public partial class TopLevelCommandService : ObservableObject,
|
public partial class TopLevelCommandService : ObservableObject,
|
||||||
IRecipient<ReloadCommandsMessage>,
|
IRecipient<ReloadCommandsMessage>,
|
||||||
@@ -336,7 +335,7 @@ public partial class TopLevelCommandService : ObservableObject,
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
await extension.StartExtensionAsync().WaitAsync(TimeSpan.FromSeconds(10));
|
await extension.StartExtensionAsync().WaitAsync(TimeSpan.FromSeconds(10));
|
||||||
return new CommandProviderWrapper(extension, _taskScheduler, logger, _aliasManager, _hotkeyManager);
|
return new CommandProviderWrapper(extension, _taskScheduler, logger, _aliasService, _hotkeyManager);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -430,7 +429,7 @@ public partial class TopLevelCommandService : ObservableObject,
|
|||||||
|
|
||||||
void IPageContext.ShowException(Exception ex, string? extensionHint)
|
void IPageContext.ShowException(Exception ex, string? extensionHint)
|
||||||
{
|
{
|
||||||
var message = DiagnosticsHelper.BuildExceptionMessage(ex, extensionHint ?? "TopLevelCommandManager");
|
var message = DiagnosticsHelper.BuildExceptionMessage(ex, extensionHint ?? "TopLevelCommandService");
|
||||||
_commandPaletteHost.Log(message);
|
_commandPaletteHost.Log(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ public partial class SettingsViewModel : INotifyPropertyChanged
|
|||||||
|
|
||||||
private IEnumerable<CommandProviderWrapper> GetCommandProviders()
|
private IEnumerable<CommandProviderWrapper> GetCommandProviders()
|
||||||
{
|
{
|
||||||
var manager = _serviceProvider.GetService<TopLevelCommandManager>()!;
|
var manager = _serviceProvider.GetService<TopLevelCommandService>()!;
|
||||||
var allProviders = manager.CommandProviders;
|
var allProviders = manager.CommandProviders;
|
||||||
return allProviders;
|
return allProviders;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem
|
|||||||
{
|
{
|
||||||
GenerateId();
|
GenerateId();
|
||||||
|
|
||||||
FetchAliasFromAliasManager();
|
FetchAliasFromAliasService();
|
||||||
UpdateHotkey();
|
UpdateHotkey();
|
||||||
UpdateTags();
|
UpdateTags();
|
||||||
UpdateInitialIcon();
|
UpdateInitialIcon();
|
||||||
@@ -275,7 +275,7 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem
|
|||||||
UpdateTags();
|
UpdateTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FetchAliasFromAliasManager()
|
private void FetchAliasFromAliasService()
|
||||||
{
|
{
|
||||||
if (_aliasService is not null)
|
if (_aliasService is not null)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user