Skip to content

Commit 7935234

Browse files
authored
Feature: Added set as app background action (#15316)
1 parent 8378b84 commit 7935234

File tree

7 files changed

+51
-0
lines changed

7 files changed

+51
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) 2024 Files Community
2+
// Licensed under the MIT License. See the LICENSE.
3+
4+
namespace Files.App.Actions
5+
{
6+
internal sealed class SetAsAppBackgroundAction : BaseSetAsAction
7+
{
8+
private IAppearanceSettingsService AppearanceSettingsService { get; } = Ioc.Default.GetRequiredService<IAppearanceSettingsService>();
9+
10+
public override string Label
11+
=> "SetAsAppBackground".GetLocalizedResource();
12+
13+
public override string Description
14+
=> "SetAsAppBackgroundDescription".GetLocalizedResource();
15+
16+
public override RichGlyph Glyph
17+
=> new("\uE91B");
18+
19+
public override bool IsExecutable =>
20+
base.IsExecutable &&
21+
context.SelectedItem is not null;
22+
23+
public override Task ExecuteAsync()
24+
{
25+
if (context.SelectedItem is not null)
26+
AppearanceSettingsService.AppThemeBackgroundImageSource = context.SelectedItem.ItemPath;
27+
28+
return Task.CompletedTask;
29+
}
30+
}
31+
}

src/Files.App/Data/Commands/Manager/CommandCodes.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public enum CommandCodes
7171
SetAsWallpaperBackground,
7272
SetAsSlideshowBackground,
7373
SetAsLockscreenBackground,
74+
SetAsAppBackground,
7475

7576
// Install
7677
InstallFont,

src/Files.App/Data/Commands/Manager/CommandManager.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public IRichCommand this[HotKey hotKey]
7676
public IRichCommand SetAsWallpaperBackground => commands[CommandCodes.SetAsWallpaperBackground];
7777
public IRichCommand SetAsSlideshowBackground => commands[CommandCodes.SetAsSlideshowBackground];
7878
public IRichCommand SetAsLockscreenBackground => commands[CommandCodes.SetAsLockscreenBackground];
79+
public IRichCommand SetAsAppBackground => commands[CommandCodes.SetAsAppBackground];
7980
public IRichCommand CopyItem => commands[CommandCodes.CopyItem];
8081
public IRichCommand CopyPath => commands[CommandCodes.CopyPath];
8182
public IRichCommand CopyPathWithQuotes => commands[CommandCodes.CopyPathWithQuotes];
@@ -249,6 +250,7 @@ public IEnumerator<IRichCommand> GetEnumerator() =>
249250
[CommandCodes.SetAsWallpaperBackground] = new SetAsWallpaperBackgroundAction(),
250251
[CommandCodes.SetAsSlideshowBackground] = new SetAsSlideshowBackgroundAction(),
251252
[CommandCodes.SetAsLockscreenBackground] = new SetAsLockscreenBackgroundAction(),
253+
[CommandCodes.SetAsAppBackground] = new SetAsAppBackgroundAction(),
252254
[CommandCodes.CopyItem] = new CopyItemAction(),
253255
[CommandCodes.CopyPath] = new CopyPathAction(),
254256
[CommandCodes.CopyPathWithQuotes] = new CopyPathWithQuotesAction(),

src/Files.App/Data/Commands/Manager/ICommandManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public interface ICommandManager : IEnumerable<IRichCommand>
6767
IRichCommand SetAsWallpaperBackground { get; }
6868
IRichCommand SetAsSlideshowBackground { get; }
6969
IRichCommand SetAsLockscreenBackground { get; }
70+
IRichCommand SetAsAppBackground { get; }
7071

7172
IRichCommand InstallFont { get; }
7273
IRichCommand InstallInfDriver { get; }

src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(
411411
new ContextMenuFlyoutItemViewModelBuilder(Commands.SetAsWallpaperBackground).Build(),
412412
new ContextMenuFlyoutItemViewModelBuilder(Commands.SetAsLockscreenBackground).Build(),
413413
new ContextMenuFlyoutItemViewModelBuilder(Commands.SetAsSlideshowBackground).Build(),
414+
new ContextMenuFlyoutItemViewModelBuilder(Commands.SetAsAppBackground).Build(),
414415
]
415416
},
416417
new ContextMenuFlyoutItemViewModelBuilder(Commands.RotateLeft)

src/Files.App/Strings/en-US/Resources.resw

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@
339339
<data name="SetAsLockscreen" xml:space="preserve">
340340
<value>Set as lockscreen background</value>
341341
</data>
342+
<data name="SetAsAppBackground" xml:space="preserve">
343+
<value>Set as app background</value>
344+
</data>
342345
<data name="AccessDeniedDeleteDialog.Text" xml:space="preserve">
343346
<value>We weren't able to delete this item</value>
344347
</data>
@@ -2463,6 +2466,9 @@
24632466
<data name="SetAsLockscreenBackgroundDescription" xml:space="preserve">
24642467
<value>Set selected picture as lockscreen background</value>
24652468
</data>
2469+
<data name="SetAsAppBackgroundDescription" xml:space="preserve">
2470+
<value>Set selected picture as the app background</value>
2471+
</data>
24662472
<data name="InstallFontDescription" xml:space="preserve">
24672473
<value>Install selected font(s)</value>
24682474
</data>

src/Files.App/UserControls/InnerNavigationToolbar.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,15 @@
384384
<FontIcon Glyph="{x:Bind Commands.SetAsLockscreenBackground.Glyph.BaseGlyph}" />
385385
</MenuFlyoutItem.Icon>
386386
</MenuFlyoutItem>
387+
<MenuFlyoutItem
388+
x:Name="SetAsAppBackgroundFlyoutItem"
389+
Command="{x:Bind Commands.SetAsAppBackground}"
390+
KeyboardAcceleratorTextOverride="{x:Bind Commands.SetAsAppBackground.HotKeyText, Mode=OneWay}"
391+
Text="{helpers:ResourceString Name=Application}">
392+
<MenuFlyoutItem.Icon>
393+
<FontIcon Glyph="{x:Bind Commands.SetAsAppBackground.Glyph.BaseGlyph}" />
394+
</MenuFlyoutItem.Icon>
395+
</MenuFlyoutItem>
387396
</MenuFlyout>
388397
</AppBarButton.Flyout>
389398

0 commit comments

Comments
 (0)