-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fix: Fixed issue where toolbar button sometimes had the wrong icon state #17032
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 all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Copyright (c) Files Community | ||
// Licensed under the MIT License. | ||
|
||
using Files.Shared.Helpers; | ||
using Windows.Graphics.Imaging; | ||
|
||
namespace Files.App.Actions | ||
|
@@ -20,8 +21,14 @@ internal abstract class BaseRotateAction : ObservableObject, IAction | |
protected abstract BitmapRotation Rotation { get; } | ||
|
||
public bool IsExecutable => | ||
IsContextPageTypeAdaptedToCommand() && | ||
(context.ShellPage?.SlimContentPage?.SelectedItemsPropertiesViewModel?.IsCompatibleToSetAsWindowsWallpaper ?? false); | ||
context.ShellPage is not null && | ||
context.ShellPage.SlimContentPage is not null && | ||
context.PageType != ContentPageTypes.RecycleBin && | ||
context.PageType != ContentPageTypes.ZipFolder && | ||
context.PageType != ContentPageTypes.ReleaseNotes && | ||
context.PageType != ContentPageTypes.Settings && | ||
context.HasSelection && | ||
context.SelectedItems.All(x => FileExtensionHelpers.IsCompatibleToSetAsWindowsWallpaper(x.FileExtension)); | ||
|
||
public BaseRotateAction() | ||
{ | ||
|
@@ -40,30 +47,10 @@ public async Task ExecuteAsync(object? parameter = null) | |
await _infoPaneViewModel.UpdateSelectedItemPreviewAsync(); | ||
} | ||
|
||
private bool IsContextPageTypeAdaptedToCommand() | ||
{ | ||
return | ||
context.PageType != ContentPageTypes.RecycleBin && | ||
context.PageType != ContentPageTypes.ZipFolder && | ||
context.PageType != ContentPageTypes.ReleaseNotes && | ||
context.PageType != ContentPageTypes.Settings && | ||
context.PageType != ContentPageTypes.None; | ||
} | ||
|
||
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
if (e.PropertyName is nameof(IContentPageContext.SelectedItem)) | ||
{ | ||
if (context.ShellPage is not null && context.ShellPage.SlimContentPage is not null) | ||
{ | ||
var viewModel = context.ShellPage.SlimContentPage.SelectedItemsPropertiesViewModel; | ||
var extensions = context.SelectedItems.Select(selectedItem => selectedItem.FileExtension).Distinct().ToList(); | ||
|
||
viewModel.CheckAllFileExtensions(extensions); | ||
Comment on lines
-57
to
-62
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. Why was this deleted? 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. The logic was moved to |
||
} | ||
|
||
if (e.PropertyName is nameof(IContentPageContext.SelectedItems)) | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2,6 +2,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Licensed under the MIT License. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
using CommunityToolkit.WinUI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
using Files.App.Actions; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
using Files.Shared.Helpers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
using Microsoft.UI.Dispatching; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
using Microsoft.UI.Xaml; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -75,14 +76,26 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public SearchBoxViewModel SearchBoxViewModel => (SearchBoxViewModel)SearchBox; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public bool HasAdditionalAction => InstanceViewModel.IsPageTypeRecycleBin || IsPowerShellScript || CanExtract || IsImage || IsFont || IsInfFile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public bool CanCopy => SelectedItems is not null && SelectedItems.Any(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public bool HasAdditionalAction => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
InstanceViewModel.IsPageTypeRecycleBin || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commands.RunWithPowershell.IsExecutable || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CanExtract || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commands.DecompressArchive.IsExecutable || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commands.DecompressArchiveHere.IsExecutable || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commands.DecompressArchiveHereSmart.IsExecutable || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commands.DecompressArchiveToChildFolder.IsExecutable || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commands.EditInNotepad.IsExecutable || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commands.RotateLeft.IsExecutable || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commands.RotateRight.IsExecutable || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commands.SetAsAppBackground.IsExecutable || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commands.SetAsWallpaperBackground.IsExecutable || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commands.SetAsLockscreenBackground.IsExecutable || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commands.SetAsSlideshowBackground.IsExecutable || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commands.InstallFont.IsExecutable || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commands.InstallInfDriver.IsExecutable || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Commands.InstallCertificate.IsExecutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+79
to
+96
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.
Suggested change
This might look prettier, since the above is similar to other large statements in the codebase. 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. I'd rather stick with the current formatting. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public bool CanExtract => Commands.DecompressArchive.CanExecute(null) || Commands.DecompressArchiveHere.CanExecute(null) || Commands.DecompressArchiveHereSmart.CanExecute(null) || Commands.DecompressArchiveToChildFolder.CanExecute(null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public bool IsPowerShellScript => SelectedItems is not null && SelectedItems.Count == 1 && FileExtensionHelpers.IsPowerShellFile(SelectedItems.First().FileExtension) && !InstanceViewModel.IsPageTypeRecycleBin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public bool IsImage => SelectedItems is not null && SelectedItems.Any() && SelectedItems.All(x => FileExtensionHelpers.IsImageFile(x.FileExtension)) && !InstanceViewModel.IsPageTypeRecycleBin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public bool IsMultipleImageSelected => SelectedItems is not null && SelectedItems.Count > 1 && SelectedItems.All(x => FileExtensionHelpers.IsImageFile(x.FileExtension)) && !InstanceViewModel.IsPageTypeRecycleBin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public bool IsInfFile => SelectedItems is not null && SelectedItems.Count == 1 && FileExtensionHelpers.IsInfFile(SelectedItems.First().FileExtension) && !InstanceViewModel.IsPageTypeRecycleBin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public bool IsFont => SelectedItems is not null && SelectedItems.Any() && SelectedItems.All(x => FileExtensionHelpers.IsFontFile(x.FileExtension)) && !InstanceViewModel.IsPageTypeRecycleBin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public bool IsCardsLayout => _InstanceViewModel.FolderSettings.LayoutMode is FolderLayoutModes.CardsView; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public bool IsColumnLayout => _InstanceViewModel.FolderSettings.LayoutMode is FolderLayoutModes.ColumnView; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -126,6 +139,9 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
private bool _IsCommandPaletteOpen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public bool IsCommandPaletteOpen { get => _IsCommandPaletteOpen; set => SetProperty(ref _IsCommandPaletteOpen, value); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
private bool _IsDynamicOverflowEnabled; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public bool IsDynamicOverflowEnabled { get => _IsDynamicOverflowEnabled; set => SetProperty(ref _IsDynamicOverflowEnabled, value); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
private bool _IsUpdating; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public bool IsUpdating { get => _IsUpdating; set => SetProperty(ref _IsUpdating, value); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -242,14 +258,12 @@ public List<ListedItem>? SelectedItems | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (SetProperty(ref _SelectedItems, value)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OnPropertyChanged(nameof(CanCopy)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OnPropertyChanged(nameof(CanExtract)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OnPropertyChanged(nameof(IsInfFile)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OnPropertyChanged(nameof(IsPowerShellScript)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OnPropertyChanged(nameof(IsImage)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OnPropertyChanged(nameof(IsMultipleImageSelected)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OnPropertyChanged(nameof(IsFont)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
OnPropertyChanged(nameof(HasAdditionalAction)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Workaround to ensure the overflow button is only displayed when there are overflow items | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
IsDynamicOverflowEnabled = false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
IsDynamicOverflowEnabled = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Unchanged files with check annotations Beta
/// <summary> | ||
/// Analyzer that detects if string literals can be replaced with constants from the <c>Strings</c> class. | ||
/// </summary> | ||
[DiagnosticAnalyzer(LanguageNames.CSharp)] | ||
Check warning on line 12 in src/Files.Core.SourceGenerator/Analyzers/StringsPropertyAnalyzer.cs
|
||
internal sealed class StringsPropertyAnalyzer : DiagnosticAnalyzer | ||
{ | ||
/// <summary> |
/// <summary> | ||
/// Generates properties for strings based on resource files. | ||
/// </summary> | ||
[Generator] | ||
Check warning on line 13 in src/Files.Core.SourceGenerator/Generators/StringsPropertyGenerator.cs
|
||
internal sealed class StringsPropertyGenerator : IIncrementalGenerator | ||
{ | ||
// Static HashSet to track generated file names |
/// <summary> | ||
/// A generator for serializing/deserializing objects to/from the Windows Registry using attributes. | ||
/// </summary> | ||
[Generator] | ||
Check warning on line 9 in src/Files.Core.SourceGenerator/Generators/RegistrySerializationGenerator.cs
|
||
internal sealed class RegistrySerializationGenerator : IIncrementalGenerator | ||
{ | ||
/// <summary> |
{ | ||
public unsafe struct IStorageProviderStatusUISource : IComIID | ||
{ | ||
private void** lpVtbl; | ||
Check warning on line 14 in src/Files.App.CsWin32/IStorageProviderStatusUISource.cs
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public HRESULT GetStatusUI(IStorageProviderStatusUI** result) |
{ | ||
public unsafe struct IStorageProviderStatusUISourceFactory : IComIID | ||
{ | ||
private void** lpVtbl; | ||
Check warning on line 14 in src/Files.App.CsWin32/IStorageProviderStatusUISourceFactory.cs
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public HRESULT GetStatusUISource(nint syncRootId, IStorageProviderStatusUISource** result) |
{ | ||
public unsafe struct IStorageProviderQuotaUI : IComIID | ||
{ | ||
private void** lpVtbl; | ||
Check warning on line 14 in src/Files.App.CsWin32/IStorageProviderQuotaUI.cs
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public HRESULT GetQuotaTotalInBytes(ulong* value) |
{ | ||
public unsafe struct IStorageProviderStatusUI : IComIID | ||
{ | ||
private void** lpVtbl; | ||
Check warning on line 14 in src/Files.App.CsWin32/IStorageProviderStatusUI.cs
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public HRESULT GetQuotaUI(IStorageProviderQuotaUI** result) |
GetKeyState | ||
CreateDirectoryFromApp | ||
WNetCancelConnection2 | ||
NET_USE_CONNECT_FLAGS | ||
Check warning on line 48 in src/Files.App.CsWin32/NativeMethods.txt
|
||
NETRESOURCEW | ||
WNetAddConnection3 | ||
CREDENTIALW | ||
SetEntriesInAcl | ||
ACL_SIZE_INFORMATION | ||
DeleteAce | ||
EXPLICIT_ACCESS | ||
Check warning on line 81 in src/Files.App.CsWin32/NativeMethods.txt
|
||
ACCESS_ALLOWED_ACE | ||
LookupAccountSid | ||
GetComputerName | ||
CoTaskMemFree | ||
QueryDosDevice | ||
DeviceIoControl | ||
GetLastError | ||
Check warning on line 137 in src/Files.App.CsWin32/NativeMethods.txt
|
||
CreateFile | ||
GetVolumeInformation | ||
COMPRESSION_FORMAT |
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.
If you're interested, you can use is, and, or:
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.
They have the same results here so I would just leave it as is.