Skip to content
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

Feature: Renamed "Favorites" section to "Pinned" #14862

Merged
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/rich-commands.md
yaira2 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ This is the list of all commands defined in `CommandCodes` enum except `None`.
| Share | ShareItem | Share | Share selected file(s) with others | |
| Start | PinToStart | Pin to the Start Menu | Pin item(s) to the Start Menu | |
| | UnpinFromStart | Unpin from the Start Menu | Unpin item(s) from the Start Menu | |
| Favorites | PinItemToFavorites | Pin to Favorites | Pin folder(s) to Favorites | |
| | UnpinItemFromFavorites | Unpin from Favorites | Unpin folder(s) from Favorites | |
| Sidebar | PinFolderToSidebar | Pin to Sidebar | Pin folder(s) to Sidebar | |
| | UnpinFolderFromSidebar | Unpin from Sidebar | Unpin folder(s) from Sidebar | |
| Backgrounds | SetAsWallpaperBackground | Set as desktop background | Set selected picture as desktop background | |
| | SetAsSlideshowBackground | Set as desktop slideshow | Set selected pictures as desktop slideshow | |
| | SetAsLockscreenBackground | Set as lockscreen background | Set selected picture as lockscreen background | |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.App.Services;
using Files.App.UserControls.Widgets;
using Windows.Storage;

namespace Files.App.Actions
{
internal class PinItemAction : ObservableObject, IAction
internal sealed class PinFolderToSidebarAction : ObservableObject, IAction
{
private readonly IContentPageContext context;

private readonly IQuickAccessService service;

public string Label
=> "PinToFavorites".GetLocalizedResource();
=> "PinFolderToSidebar".GetLocalizedResource();

public string Description
=> "PinItemToFavoritesDescription".GetLocalizedResource();
=> "PinFolderToSidebarDescription".GetLocalizedResource();

public RichGlyph Glyph
=> new(opacityStyle: "ColorIconPinToFavorites");
=> new(opacityStyle: "ColorIconPinToSidebar");

public bool IsExecutable
=> GetIsExecutable();

public PinItemAction()
public PinFolderToSidebarAction()
{
context = Ioc.Default.GetRequiredService<IContentPageContext>();
service = Ioc.Default.GetRequiredService<IQuickAccessService>();
Expand All @@ -50,7 +47,7 @@ public async Task ExecuteAsync()

private bool GetIsExecutable()
{
string[] favorites = App.QuickAccessManager.Model.FavoriteItems.ToArray();
string[] pinnedFolders = App.QuickAccessManager.Model.PinnedFolders.ToArray();

return context.HasSelection
? context.SelectedItems.All(IsPinnable)
Expand All @@ -60,7 +57,7 @@ bool IsPinnable(ListedItem item)
{
return
item.PrimaryItemAttribute is StorageItemTypes.Folder &&
!favorites.Contains(item.ItemPath);
!pinnedFolders.Contains(item.ItemPath);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.App.Services;
using Files.App.UserControls.Widgets;

namespace Files.App.Actions
{
internal class UnpinItemAction : ObservableObject, IAction
internal sealed class UnpinFolderFromSidebarAction : ObservableObject, IAction
{
private readonly IContentPageContext context;

private readonly IQuickAccessService service;

public string Label
=> "UnpinFromFavorites".GetLocalizedResource();
=> "UnpinFolderFromSidebar".GetLocalizedResource();

public string Description
=> "UnpinItemFromFavoritesDescription".GetLocalizedResource();
=> "UnpinFolderFromSidebarDescription".GetLocalizedResource();

public RichGlyph Glyph
=> new(opacityStyle: "ColorIconUnpinFromFavorites");
=> new(opacityStyle: "ColorIconUnpinFromSidebar");

public bool IsExecutable
=> GetIsExecutable();

public UnpinItemAction()
public UnpinFolderFromSidebarAction()
{
context = Ioc.Default.GetRequiredService<IContentPageContext>();
service = Ioc.Default.GetRequiredService<IQuickAccessService>();
Expand All @@ -48,15 +44,15 @@ public async Task ExecuteAsync()

private bool GetIsExecutable()
{
string[] favorites = App.QuickAccessManager.Model.FavoriteItems.ToArray();
string[] pinnedFolders = App.QuickAccessManager.Model.PinnedFolders.ToArray();

return context.HasSelection
? context.SelectedItems.All(IsPinned)
: context.Folder is not null && IsPinned(context.Folder);

bool IsPinned(ListedItem item)
{
return favorites.Contains(item.ItemPath);
return pinnedFolders.Contains(item.ItemPath);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Actions/Start/PinToStartAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public string Description
=> "PinToStartDescription".GetLocalizedResource();

public RichGlyph Glyph
=> new(opacityStyle: "ColorIconPinToFavorites");
=> new(opacityStyle: "ColorIconPinToSidebar");

public bool IsExecutable =>
context.ShellPage is not null;
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Actions/Start/UnpinFromStartAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public string Description
=> "UnpinFromStartDescription".GetLocalizedResource();

public RichGlyph Glyph
=> new(opacityStyle: "ColorIconUnpinFromFavorites");
=> new(opacityStyle: "ColorIconUnpinFromSidebar");

public UnpinFromStartAction()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static class Shell32
public static class FluentIconsPaths
{
public const string CloudDriveIcon = "ms-appx:///Assets/FluentIcons/CloudDrive.png";
public const string FavoritesIcon = "ms-appx:///Assets/FluentIcons/Favorites.png";
public const string StarIcon = "ms-appx:///Assets/FluentIcons/Star.png";
public const string FileTagsIcon = "ms-appx:///Assets/FluentIcons/FileTags.png";
public const string HomeIcon = "ms-appx:///Assets/FluentIcons/Home.png";
}
Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/Data/Commands/CommandCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public enum CommandCodes
PinToStart,
UnpinFromStart,

// Favorites
PinItemToFavorites,
UnpinItemFromFavorites,
// Sidebar
PinFolderToSidebar,
UnpinFolderFromSidebar,

// Backgrounds
SetAsWallpaperBackground,
Expand Down
8 changes: 4 additions & 4 deletions src/Files.App/Data/Commands/Manager/CommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public IRichCommand this[HotKey hotKey]
public IRichCommand AddItem => commands[CommandCodes.AddItem];
public IRichCommand PinToStart => commands[CommandCodes.PinToStart];
public IRichCommand UnpinFromStart => commands[CommandCodes.UnpinFromStart];
public IRichCommand PinItemToFavorites => commands[CommandCodes.PinItemToFavorites];
public IRichCommand UnpinItemFromFavorites => commands[CommandCodes.UnpinItemFromFavorites];
public IRichCommand PinFolderToSidebar => commands[CommandCodes.PinFolderToSidebar];
public IRichCommand UnpinFolderFromSidebar => commands[CommandCodes.UnpinFolderFromSidebar];
public IRichCommand SetAsWallpaperBackground => commands[CommandCodes.SetAsWallpaperBackground];
public IRichCommand SetAsSlideshowBackground => commands[CommandCodes.SetAsSlideshowBackground];
public IRichCommand SetAsLockscreenBackground => commands[CommandCodes.SetAsLockscreenBackground];
Expand Down Expand Up @@ -238,8 +238,8 @@ public CommandManager()
[CommandCodes.AddItem] = new AddItemAction(),
[CommandCodes.PinToStart] = new PinToStartAction(),
[CommandCodes.UnpinFromStart] = new UnpinFromStartAction(),
[CommandCodes.PinItemToFavorites] = new PinItemAction(),
[CommandCodes.UnpinItemFromFavorites] = new UnpinItemAction(),
[CommandCodes.PinFolderToSidebar] = new PinFolderToSidebarAction(),
[CommandCodes.UnpinFolderFromSidebar] = new UnpinFolderFromSidebarAction(),
[CommandCodes.SetAsWallpaperBackground] = new SetAsWallpaperBackgroundAction(),
[CommandCodes.SetAsSlideshowBackground] = new SetAsSlideshowBackgroundAction(),
[CommandCodes.SetAsLockscreenBackground] = new SetAsLockscreenBackgroundAction(),
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Data/Commands/Manager/ICommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public interface ICommandManager : IEnumerable<IRichCommand>

IRichCommand PinToStart { get; }
IRichCommand UnpinFromStart { get; }
IRichCommand PinItemToFavorites { get; }
IRichCommand UnpinItemFromFavorites { get; }
IRichCommand PinFolderToSidebar { get; }
IRichCommand UnpinFolderFromSidebar { get; }

IRichCommand SetAsWallpaperBackground { get; }
IRichCommand SetAsSlideshowBackground { get; }
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Data/Contexts/SideBar/ISideBarContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public interface ISidebarContext
bool IsItemRightClicked { get; }

/// <summary>
/// Gets the value that indicates whether right clicked item is a favorite item
/// Gets the value that indicates whether right clicked item is a pinned folder item
/// </summary>
bool IsFavoriteItem { get; }
bool IsPinnedFolderItem { get; }

/// <summary>
/// Gets the drive item to open if any
Expand Down
14 changes: 7 additions & 7 deletions src/Files.App/Data/Contexts/SideBar/SideBarContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ namespace Files.App.Data.Contexts
/// <inheritdoc cref="ISidebarContext"/>
internal class SidebarContext : ObservableObject, ISidebarContext
{
private readonly SidebarPinnedModel favoriteModel = App.QuickAccessManager.Model;
private readonly PinnedFoldersManager favoriteModel = App.QuickAccessManager.Model;

private int FavoriteIndex =>
private int PinnedFolderItemIndex =>
IsItemRightClicked
? favoriteModel.IndexOfItem(_RightClickedItem!)
: -1;
Expand All @@ -19,10 +19,10 @@ internal class SidebarContext : ObservableObject, ISidebarContext
public bool IsItemRightClicked =>
_RightClickedItem is not null;

public bool IsFavoriteItem =>
public bool IsPinnedFolderItem =>
IsItemRightClicked &&
_RightClickedItem!.Section is SectionType.Favorites &&
FavoriteIndex is not -1;
_RightClickedItem!.Section is SectionType.Pinned &&
PinnedFolderItemIndex is not -1;

public DriveItem? OpenDriveItem
=> _RightClickedItem as DriveItem;
Expand All @@ -37,8 +37,8 @@ public void SidebarControl_RightClickedItemChanged(object? sender, INavigationCo
if (SetProperty(ref _RightClickedItem, e, nameof(RightClickedItem)))
{
OnPropertyChanged(nameof(IsItemRightClicked));
OnPropertyChanged(nameof(FavoriteIndex));
OnPropertyChanged(nameof(IsFavoriteItem));
OnPropertyChanged(nameof(PinnedFolderItemIndex));
OnPropertyChanged(nameof(IsPinnedFolderItem));
OnPropertyChanged(nameof(OpenDriveItem));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Data/Contracts/INavigationControlItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public enum NavigationControlItemType
public enum SectionType
{
Home,
Favorites,
Pinned,
Library,
Drives,
CloudDrives,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,13 +484,13 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(
IsVisible = Commands.OpenProperties.IsExecutable
}.Build(),
new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenParentFolder).Build(),
new ContextMenuFlyoutItemViewModelBuilder(Commands.PinItemToFavorites)
new ContextMenuFlyoutItemViewModelBuilder(Commands.PinFolderToSidebar)
{
IsVisible = Commands.PinItemToFavorites.IsExecutable && UserSettingsService.GeneralSettingsService.ShowFavoritesSection,
IsVisible = Commands.PinFolderToSidebar.IsExecutable && UserSettingsService.GeneralSettingsService.ShowPinnedSection,
}.Build(),
new ContextMenuFlyoutItemViewModelBuilder(Commands.UnpinItemFromFavorites)
new ContextMenuFlyoutItemViewModelBuilder(Commands.UnpinFolderFromSidebar)
{
IsVisible = Commands.UnpinItemFromFavorites.IsExecutable && UserSettingsService.GeneralSettingsService.ShowFavoritesSection,
IsVisible = Commands.UnpinFolderFromSidebar.IsExecutable && UserSettingsService.GeneralSettingsService.ShowPinnedSection,
}.Build(),
new ContextMenuFlyoutItemViewModelBuilder(Commands.PinToStart)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Data/Items/DriveItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public bool IsNetwork
=> Type == DriveType.Network;

public bool IsPinned
=> App.QuickAccessManager.Model.FavoriteItems.Contains(path);
=> App.QuickAccessManager.Model.PinnedFolders.Contains(path);

public string MaxSpaceText
=> MaxSpace.ToSizeString();
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Data/Items/ListedItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public override string ToString()
public bool IsGitItem => this is GitItem;
public virtual bool IsExecutable => FileExtensionHelpers.IsExecutableFile(ItemPath);
public virtual bool IsPythonFile => FileExtensionHelpers.IsPythonFile(ItemPath);
public bool IsPinned => App.QuickAccessManager.Model.FavoriteItems.Contains(itemPath);
public bool IsPinned => App.QuickAccessManager.Model.PinnedFolders.Contains(itemPath);
public bool IsDriveRoot => ItemPath == PathNormalization.GetPathRoot(ItemPath);
public bool IsElevationRequired { get; set; }

Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Data/Items/LocationItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public bool IsExpanded

public bool IsInvalid { get; set; } = false;

public bool IsPinned => App.QuickAccessManager.Model.FavoriteItems.Contains(path);
public bool IsPinned => App.QuickAccessManager.Model.PinnedFolders.Contains(path);

public SectionType Section { get; set; }

Expand All @@ -101,7 +101,7 @@ public FrameworkElement? ItemDecorator
{
get
{
if (Section == SectionType.Favorites)
if (Section == SectionType.Pinned)
{
return new OpacityIcon()
{
Expand Down
Loading
Loading