Skip to content

Commit 6da9001

Browse files
authored
Code Quality: Removed PaneHolder to solely use PreviewPaneHolder (#10979)
1 parent 65061b6 commit 6da9001

24 files changed

+112
-258
lines changed

src/Files.App/App.xaml.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public partial class App : Application
5555
public static StorageHistoryWrapper HistoryWrapper = new StorageHistoryWrapper();
5656
public static SettingsViewModel AppSettings { get; private set; }
5757
public static AppModel AppModel { get; private set; }
58-
public static PaneViewModel PaneViewModel { get; private set; }
5958
public static PreviewPaneViewModel PreviewPaneViewModel { get; private set; }
6059
public static JumpListManager JumpList { get; private set; }
6160
public static RecentItems RecentItemsManager { get; private set; }
@@ -109,7 +108,7 @@ private IServiceProvider ConfigureServices()
109108
.AddSingleton<IPreferencesSettingsService, PreferencesSettingsService>((sp) => new PreferencesSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
110109
.AddSingleton<IFoldersSettingsService, FoldersSettingsService>((sp) => new FoldersSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
111110
.AddSingleton<IApplicationSettingsService, ApplicationSettingsService>((sp) => new ApplicationSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
112-
.AddSingleton<IPaneSettingsService, PaneSettingsService>((sp) => new PaneSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
111+
.AddSingleton<IPreviewPaneSettingsService, PreviewPaneSettingsService>((sp) => new PreviewPaneSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
113112
.AddSingleton<ILayoutSettingsService, LayoutSettingsService>((sp) => new LayoutSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
114113
.AddSingleton<IAppSettingsService, AppSettingsService>((sp) => new AppSettingsService((sp.GetService<IUserSettingsService>() as UserSettingsService).GetSharingContext()))
115114
// Settings not related to IUserSettingsService:
@@ -149,7 +148,6 @@ private static void EnsureSettingsAndConfigurationAreBootstrapped()
149148
JumpList ??= new JumpListManager();
150149
RecentItemsManager ??= new RecentItems();
151150
AppModel ??= new AppModel();
152-
PaneViewModel ??= new PaneViewModel();
153151
PreviewPaneViewModel ??= new PreviewPaneViewModel();
154152
LibraryManager ??= new LibraryManager();
155153
DrivesManager ??= new DrivesManager();
@@ -297,7 +295,6 @@ await SafetyExtensions.IgnoreExceptions(async () =>
297295
}
298296

299297
DrivesManager?.Dispose();
300-
PaneViewModel?.Dispose();
301298
PreviewPaneViewModel?.Dispose();
302299

303300
// Try to maintain clipboard data after app close

src/Files.App/BaseLayout.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public abstract class BaseLayout : Page, IBaseLayout, INotifyPropertyChanged
5858

5959
public CurrentInstanceViewModel? InstanceViewModel => ParentShellPageInstance?.InstanceViewModel;
6060

61-
public IPaneViewModel PaneViewModel => App.PaneViewModel;
61+
public PreviewPaneViewModel PreviewPaneViewModel => App.PreviewPaneViewModel;
6262

6363
public AppModel AppModel => App.AppModel;
6464
public DirectoryPropertiesViewModel DirectoryPropertiesViewModel { get; }
@@ -205,9 +205,9 @@ internal set
205205
App.PreviewPaneViewModel.SelectedItem = value?.Count == 1 ? value.First() : null;
206206

207207
// check if the preview pane is open before updating the model
208-
if (PaneViewModel.IsPreviewSelected)
208+
if (PreviewPaneViewModel.IsEnabled)
209209
{
210-
bool isPaneEnabled = ((App.Window.Content as Frame)?.Content as MainPage)?.IsPaneEnabled ?? false;
210+
bool isPaneEnabled = ((App.Window.Content as Frame)?.Content as MainPage)?.ShouldPreviewPaneBeActive ?? false;
211211
if (isPaneEnabled)
212212
App.PreviewPaneViewModel.UpdateSelectedItemPreview();
213213
}
@@ -1039,7 +1039,7 @@ protected void UninitializeDrag(UIElement element)
10391039

10401040
public virtual void Dispose()
10411041
{
1042-
PaneViewModel?.Dispose();
1042+
PreviewPaneViewModel?.Dispose();
10431043
UnhookBaseEvents();
10441044
}
10451045

src/Files.App/DataModels/AppModel.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ namespace Files.App.DataModels
1111
{
1212
public class AppModel : ObservableObject
1313
{
14-
// todo: refactor PaneViewModel, this doesn't belong here
15-
public IPaneViewModel PaneViewModel { get; } = new PaneViewModel();
16-
1714
public AppModel()
1815
{
1916
Clipboard.ContentChanged += Clipboard_ContentChanged;

src/Files.App/IBaseLayout.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public interface IBaseLayout : IDisposable
2121

2222
ItemManipulationModel ItemManipulationModel { get; }
2323

24-
IPaneViewModel PaneViewModel { get; }
24+
PreviewPaneViewModel PreviewPaneViewModel { get; }
2525

2626
public SelectedItemsPropertiesViewModel SelectedItemsPropertiesViewModel { get; }
2727
public DirectoryPropertiesViewModel DirectoryPropertiesViewModel { get; }

src/Files.App/ServicesImplementation/Settings/PaneSettingsService.cs renamed to src/Files.App/ServicesImplementation/Settings/PreviewPaneSettingsService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
namespace Files.App.ServicesImplementation.Settings
99
{
10-
internal sealed class PaneSettingsService : BaseObservableJsonSettings, IPaneSettingsService
10+
internal sealed class PreviewPaneSettingsService : BaseObservableJsonSettings, IPreviewPaneSettingsService
1111
{
12-
public PaneContents Content
12+
public bool IsEnabled
1313
{
14-
get => Get(PaneContents.None);
14+
get => Get(false);
1515
set => Set(value);
1616
}
1717

@@ -39,7 +39,7 @@ public bool ShowPreviewOnly
3939
set => Set(value);
4040
}
4141

42-
public PaneSettingsService(ISettingsSharingContext settingsSharingContext)
42+
public PreviewPaneSettingsService(ISettingsSharingContext settingsSharingContext)
4343
{
4444
RegisterSettingsContext(settingsSharingContext);
4545
}

src/Files.App/ServicesImplementation/Settings/UserSettingsService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ public IAppearanceSettingsService AppearanceSettingsService
3030
get => GetSettingsService(ref _AppearanceSettingsService);
3131
}
3232

33-
private IPaneSettingsService _PaneSettingsService;
34-
public IPaneSettingsService PaneSettingsService
33+
private IPreviewPaneSettingsService _PreviewPaneSettingsService;
34+
public IPreviewPaneSettingsService PreviewPaneSettingsService
3535
{
36-
get => GetSettingsService(ref _PaneSettingsService);
36+
get => GetSettingsService(ref _PreviewPaneSettingsService);
3737
}
3838

3939
private ILayoutSettingsService _LayoutSettingsService;

src/Files.App/UserControls/FilePreviews/MediaPreview.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ public MediaPreview(MediaPreviewViewModel model)
2626

2727
private void PlayerContext_Loaded(object sender, RoutedEventArgs e)
2828
{
29-
PlayerContext.MediaPlayer.Volume = UserSettingsService.PaneSettingsService.MediaVolume;
29+
PlayerContext.MediaPlayer.Volume = UserSettingsService.PreviewPaneSettingsService.MediaVolume;
3030
PlayerContext.MediaPlayer.VolumeChanged += MediaPlayer_VolumeChanged;
3131
ViewModel.TogglePlaybackRequested += TogglePlaybackRequestInvoked;
3232
}
3333

3434
private void MediaPlayer_VolumeChanged(MediaPlayer sender, object args)
3535
{
36-
if (sender.Volume != UserSettingsService.PaneSettingsService.MediaVolume)
36+
if (sender.Volume != UserSettingsService.PreviewPaneSettingsService.MediaVolume)
3737
{
38-
UserSettingsService.PaneSettingsService.MediaVolume = sender.Volume;
38+
UserSettingsService.PreviewPaneSettingsService.MediaVolume = sender.Volume;
3939
}
4040
}
4141

src/Files.App/UserControls/InnerNavigationToolbar.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@
823823
MinWidth="40"
824824
AccessKey="P"
825825
AutomationProperties.Name="{helpers:ResourceString Name=PreviewPaneToggle/AutomationProperties/Name}"
826-
IsChecked="{x:Bind AppModel.PaneViewModel.IsPreviewSelected, Mode=TwoWay}"
826+
IsChecked="{x:Bind PreviewPaneViewModel.IsEnabled, Mode=TwoWay}"
827827
IsEnabled="{x:Bind ShowPreviewPaneButton, Mode=OneWay}"
828828
Label="{helpers:ResourceString Name=PreviewPaneToggle/Label}"
829829
LabelPosition="Collapsed"

src/Files.App/UserControls/InnerNavigationToolbar.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public InnerNavigationToolbar()
2727

2828
public AppModel AppModel => App.AppModel;
2929

30+
public PreviewPaneViewModel PreviewPaneViewModel => App.PreviewPaneViewModel;
31+
3032
public ToolbarViewModel ViewModel
3133
{
3234
get => (ToolbarViewModel)GetValue(ViewModelProperty);

src/Files.App/UserControls/Pane/Pane.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)