From 3b7ce0068b869bb40e435de93c428dbb2febabcd Mon Sep 17 00:00:00 2001
From: Yair <39923744+yaira2@users.noreply.github.com>
Date: Tue, 8 Apr 2025 19:22:36 -0400
Subject: [PATCH 1/3] Attempted fix
---
.../ImageManipulation/BaseRotateAction.cs | 36 ++++++---------
src/Files.App/UserControls/Toolbar.xaml | 44 +++++++++----------
.../NavigationToolbarViewModel.cs | 33 ++++++++------
3 files changed, 56 insertions(+), 57 deletions(-)
diff --git a/src/Files.App/Actions/Content/ImageManipulation/BaseRotateAction.cs b/src/Files.App/Actions/Content/ImageManipulation/BaseRotateAction.cs
index f4ddf3d598ef..67a4814c912e 100644
--- a/src/Files.App/Actions/Content/ImageManipulation/BaseRotateAction.cs
+++ b/src/Files.App/Actions/Content/ImageManipulation/BaseRotateAction.cs
@@ -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,13 @@ 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.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,29 +46,15 @@ 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))
+ switch (e.PropertyName)
{
- 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);
- }
-
- OnPropertyChanged(nameof(IsExecutable));
+ case nameof(IContentPageContext.SelectedItems):
+ {
+ OnPropertyChanged(nameof(IsExecutable));
+ break;
+ }
}
}
}
diff --git a/src/Files.App/UserControls/Toolbar.xaml b/src/Files.App/UserControls/Toolbar.xaml
index ef2c1a2cf2cf..2ade2131efc1 100644
--- a/src/Files.App/UserControls/Toolbar.xaml
+++ b/src/Files.App/UserControls/Toolbar.xaml
@@ -287,13 +287,13 @@
x:Name="ExtractButton"
Width="Auto"
MinWidth="40"
- x:Load="{x:Bind ViewModel.CanExtract, Mode=OneWay, FallbackValue=False}"
AccessKey="Z"
AccessKeyInvoked="AppBarButton_AccessKeyInvoked"
IsEnabled="{x:Bind ViewModel.CanExtract, Mode=OneWay, FallbackValue=False}"
Label="{helpers:ResourceString Name=Extract}"
LabelPosition="Default"
- Style="{StaticResource ToolBarAppBarButtonFlyoutStyle}">
+ Style="{StaticResource ToolBarAppBarButtonFlyoutStyle}"
+ Visibility="{x:Bind ViewModel.CanExtract, Mode=OneWay}">
@@ -331,12 +331,12 @@
x:Name="RunWithPowerShellButton"
Width="Auto"
MinWidth="40"
- x:Load="{x:Bind Commands.RunWithPowershell.IsExecutable, Mode=OneWay}"
AutomationProperties.Name="RunWithPowerShell"
Command="{x:Bind Commands.RunWithPowershell}"
Label="{x:Bind Commands.RunWithPowershell.Label}"
LabelPosition="Default"
- ToolTipService.ToolTip="{x:Bind Commands.RunWithPowershell.LabelWithHotKey, Mode=OneWay}">
+ ToolTipService.ToolTip="{x:Bind Commands.RunWithPowershell.LabelWithHotKey, Mode=OneWay}"
+ Visibility="{x:Bind Commands.RunWithPowershell.IsExecutable, Mode=OneWay}">
@@ -347,12 +347,12 @@
x:Name="EditInNotepadButton"
Width="Auto"
MinWidth="40"
- x:Load="{x:Bind Commands.EditInNotepad.IsExecutable, Mode=OneWay}"
AutomationProperties.Name="EditInNotepad"
Command="{x:Bind Commands.EditInNotepad}"
Label="{x:Bind Commands.EditInNotepad.Label}"
LabelPosition="Default"
- ToolTipService.ToolTip="{x:Bind Commands.EditInNotepad.LabelWithHotKey, Mode=OneWay}">
+ ToolTipService.ToolTip="{x:Bind Commands.EditInNotepad.LabelWithHotKey, Mode=OneWay}"
+ Visibility="{x:Bind Commands.EditInNotepad.IsExecutable, Mode=OneWay}">
@@ -363,11 +363,11 @@
x:Name="SetAsBackgroundButton"
Width="Auto"
MinWidth="40"
- x:Load="{x:Bind Commands.SetAsWallpaperBackground.IsExecutable, Mode=OneWay}"
Label="{helpers:ResourceString Name=SetAsBackgroundFlyout}"
LabelPosition="Default"
Style="{StaticResource ToolBarAppBarButtonFlyoutStyle}"
- ToolTipService.ToolTip="{helpers:ResourceString Name=SetAsBackgroundFlyout}">
+ ToolTipService.ToolTip="{helpers:ResourceString Name=SetAsBackgroundFlyout}"
+ Visibility="{x:Bind Commands.SetAsWallpaperBackground.IsExecutable, Mode=OneWay}">
@@ -410,21 +410,21 @@
x:Name="SetAsSlideshowButton"
Width="Auto"
MinWidth="40"
- x:Load="{x:Bind Commands.SetAsSlideshowBackground.IsExecutable, Mode=OneWay}"
Command="{x:Bind Commands.SetAsSlideshowBackground}"
Icon="{x:Bind Commands.SetAsSlideshowBackground.FontIcon}"
Label="{x:Bind Commands.SetAsSlideshowBackground.Label}"
LabelPosition="Default"
- ToolTipService.ToolTip="{x:Bind Commands.SetAsSlideshowBackground.LabelWithHotKey, Mode=OneWay}" />
+ ToolTipService.ToolTip="{x:Bind Commands.SetAsSlideshowBackground.LabelWithHotKey, Mode=OneWay}"
+ Visibility="{x:Bind Commands.SetAsSlideshowBackground.IsExecutable, Mode=OneWay}" />
+ ToolTipService.ToolTip="{helpers:ResourceString Name=Install}"
+ Visibility="{x:Bind Commands.InstallInfDriver.IsExecutable, Mode=OneWay}">
@@ -433,44 +433,44 @@
+ ToolTipService.ToolTip="{helpers:ResourceString Name=RotateLeft}"
+ Visibility="{x:Bind Commands.RotateLeft.IsExecutable, Mode=OneWay}">
+ ToolTipService.ToolTip="{helpers:ResourceString Name=RotateRight}"
+ Visibility="{x:Bind Commands.RotateRight.IsExecutable, Mode=OneWay}">
+ ToolTipService.ToolTip="{helpers:ResourceString Name=Install}"
+ Visibility="{x:Bind Commands.InstallFont.IsExecutable, Mode=OneWay}">
+ ToolTipService.ToolTip="{helpers:ResourceString Name=Install}"
+ Visibility="{x:Bind Commands.InstallCertificate.IsExecutable, Mode=OneWay}">
@@ -479,12 +479,12 @@
+ ToolTipService.ToolTip="{x:Bind Commands.PlayAll.LabelWithHotKey, Mode=OneWay}"
+ Visibility="{x:Bind Commands.PlayAll.IsExecutable, Mode=OneWay}">
diff --git a/src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs b/src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs
index 455aea1d3c4a..b780c9514068 100644
--- a/src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs
+++ b/src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs
@@ -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;
+
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;
@@ -242,13 +255,7 @@ public List? 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));
}
}
From b7cbc46e3e71afdc5bcafcdeccd1551269e7bea0 Mon Sep 17 00:00:00 2001
From: Yair <39923744+yaira2@users.noreply.github.com>
Date: Tue, 8 Apr 2025 22:19:19 -0400
Subject: [PATCH 2/3] Workaround
---
src/Files.App/UserControls/Toolbar.xaml | 3 ++-
.../ViewModels/UserControls/NavigationToolbarViewModel.cs | 7 +++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/Files.App/UserControls/Toolbar.xaml b/src/Files.App/UserControls/Toolbar.xaml
index 2ade2131efc1..a167218e65e0 100644
--- a/src/Files.App/UserControls/Toolbar.xaml
+++ b/src/Files.App/UserControls/Toolbar.xaml
@@ -72,7 +72,8 @@
Grid.Column="0"
HorizontalAlignment="Left"
x:Load="{x:Bind ViewModel.InstanceViewModel.IsPageTypeNotHome, Mode=OneWay}"
- DefaultLabelPosition="Right">
+ DefaultLabelPosition="Right"
+ IsDynamicOverflowEnabled="{x:Bind ViewModel.IsDynamicOverflowEnabled, Mode=OneWay}">
diff --git a/src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs b/src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs
index b780c9514068..05e632463d26 100644
--- a/src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs
+++ b/src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs
@@ -139,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); }
@@ -257,6 +260,10 @@ public List? SelectedItems
{
OnPropertyChanged(nameof(CanExtract));
OnPropertyChanged(nameof(HasAdditionalAction));
+
+ // Workaround to ensure the overflow button is only displayed when there are overflow items
+ IsDynamicOverflowEnabled = false;
+ IsDynamicOverflowEnabled = true;
}
}
}
From becf46deed0b0d4374f604c6e67af20a5ee40f66 Mon Sep 17 00:00:00 2001
From: Yair <39923744+yaira2@users.noreply.github.com>
Date: Tue, 8 Apr 2025 22:29:22 -0400
Subject: [PATCH 3/3] Update BaseRotateAction.cs
---
.../Content/ImageManipulation/BaseRotateAction.cs | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/src/Files.App/Actions/Content/ImageManipulation/BaseRotateAction.cs b/src/Files.App/Actions/Content/ImageManipulation/BaseRotateAction.cs
index 67a4814c912e..c340de656f63 100644
--- a/src/Files.App/Actions/Content/ImageManipulation/BaseRotateAction.cs
+++ b/src/Files.App/Actions/Content/ImageManipulation/BaseRotateAction.cs
@@ -22,6 +22,7 @@ internal abstract class BaseRotateAction : ObservableObject, IAction
public bool IsExecutable =>
context.ShellPage is not null &&
+ context.ShellPage.SlimContentPage is not null &&
context.PageType != ContentPageTypes.RecycleBin &&
context.PageType != ContentPageTypes.ZipFolder &&
context.PageType != ContentPageTypes.ReleaseNotes &&
@@ -48,14 +49,8 @@ public async Task ExecuteAsync(object? parameter = null)
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
- switch (e.PropertyName)
- {
- case nameof(IContentPageContext.SelectedItems):
- {
- OnPropertyChanged(nameof(IsExecutable));
- break;
- }
- }
+ if (e.PropertyName is nameof(IContentPageContext.SelectedItems))
+ OnPropertyChanged(nameof(IsExecutable));
}
}
-}
+}
\ No newline at end of file