[vlc-commits] [Git][videolan/vlc][master] 20 commits: macosx: Add VLCLibraryWindowPersistentPreferences class
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Thu Apr 13 00:10:25 UTC 2023
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
1a7fefff by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Add VLCLibraryWindowPersistentPreferences class
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
e1ee0c63 by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Add enum for library view mode
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
95b0bb65 by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Add generic setter for setting in VLCLibraryWindowPersistentPreferences
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
ede562db by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Add convenience method to get full library window preference key
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
d6c83cc1 by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Add generic getter for library window view mode settings
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
f36125eb by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Add properties to VLCLibraryWindowPersistentPreferences for new preferences
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
65f634a3 by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Add custom setters for new library window preferences
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
9d1d986f by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Add custom getters for new library window preferences
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
1c915e7d by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Use existing view mode enum in VLCLibraryWindow for preferences
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
1c334ccf by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Make VLCLibraryWindowPersistentPreferences a singleton
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
2d7805ca by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Store changes in library view mode using the new preferences class
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
b6f82eda by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Use new library window preferences to set gridvslist view mode in audio view controller
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
229e9567 by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Use new library window preferences to set the view mode in video view controller
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
63f8ac17 by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Don't encode view mode in library window restorable state now that it is stored in user defaults
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
71b99048 by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Use new library window preferences singleton to get view mode in media source views
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
f06cf5bc by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Remove now unneeded resetting of gridvslistsegmentedcontrol target and action
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
979a0ca9 by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Split main title segmented control and gridvslist segmented control actions into two separate methods
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
2d90877a by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Guard against storing and retrieving bad view mode values in settings
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
103779c5 by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Ensure media source data source sets view mode dependent on the specific media source mode
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
31c3f00d by Claudio Cambra at 2023-04-12T23:21:43+00:00
macosx: Update grid vs list view mode segmented control on view changes
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
16 changed files:
- extras/package/macosx/VLC.xcodeproj/project.pbxproj
- modules/gui/macosx/Makefile.am
- modules/gui/macosx/UI/VLCLibraryWindow.xib
- modules/gui/macosx/library/VLCLibraryWindow.h
- modules/gui/macosx/library/VLCLibraryWindow.m
- modules/gui/macosx/library/VLCLibraryWindowController.m
- + modules/gui/macosx/library/VLCLibraryWindowPersistentPreferences.h
- + modules/gui/macosx/library/VLCLibraryWindowPersistentPreferences.m
- modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.h
- modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.m
- modules/gui/macosx/library/media-source/VLCLibraryMediaSourceViewController.m
- modules/gui/macosx/library/media-source/VLCMediaSourceBaseDataSource.h
- modules/gui/macosx/library/media-source/VLCMediaSourceBaseDataSource.m
- modules/gui/macosx/library/media-source/VLCMediaSourceDataSource.h
- modules/gui/macosx/library/video-library/VLCLibraryVideoViewController.h
- modules/gui/macosx/library/video-library/VLCLibraryVideoViewController.m
Changes:
=====================================
extras/package/macosx/VLC.xcodeproj/project.pbxproj
=====================================
@@ -80,6 +80,7 @@
5325C57D29302E6800B2B63A /* VLCLibraryAudioViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5325C57B29302E6800B2B63A /* VLCLibraryAudioViewController.m */; };
534E8E3A29A06325009503F8 /* VLCMainVideoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 534E8E3929A06325009503F8 /* VLCMainVideoViewController.m */; };
5352B37329DF29BF0011CE03 /* VLCMainVideoViewControlsBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 5352B37229DF29BF0011CE03 /* VLCMainVideoViewControlsBar.m */; };
+ 5352B37629E149AC0011CE03 /* VLCLibraryWindowPersistentPreferences.m in Sources */ = {isa = PBXBuildFile; fileRef = 5352B37529E149AC0011CE03 /* VLCLibraryWindowPersistentPreferences.m */; };
5362550D293FD639005D64FA /* VLCLibraryWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5362550C293FD639005D64FA /* VLCLibraryWindowController.m */; };
536283F0291146BC00640C15 /* VLCLibraryTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 536283DE291146BC00640C15 /* VLCLibraryTableView.m */; };
536283F1291146BC00640C15 /* VLCLibraryAlbumTracksDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 536283DF291146BC00640C15 /* VLCLibraryAlbumTracksDataSource.m */; };
@@ -261,6 +262,8 @@
534E8E3929A06325009503F8 /* VLCMainVideoViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCMainVideoViewController.m; sourceTree = "<group>"; };
5352B37129DF29BF0011CE03 /* VLCMainVideoViewControlsBar.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCMainVideoViewControlsBar.h; sourceTree = "<group>"; };
5352B37229DF29BF0011CE03 /* VLCMainVideoViewControlsBar.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCMainVideoViewControlsBar.m; sourceTree = "<group>"; };
+ 5352B37429E149AC0011CE03 /* VLCLibraryWindowPersistentPreferences.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryWindowPersistentPreferences.h; sourceTree = "<group>"; };
+ 5352B37529E149AC0011CE03 /* VLCLibraryWindowPersistentPreferences.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLibraryWindowPersistentPreferences.m; sourceTree = "<group>"; };
5362550B293FD639005D64FA /* VLCLibraryWindowController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryWindowController.h; sourceTree = "<group>"; };
5362550C293FD639005D64FA /* VLCLibraryWindowController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLibraryWindowController.m; sourceTree = "<group>"; };
536283DC291146BC00640C15 /* VLCLibraryAlbumTracksDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCLibraryAlbumTracksDataSource.h; sourceTree = "<group>"; };
@@ -1209,6 +1212,8 @@
7D713D312201AE350042BEB7 /* VLCLibraryWindow.m */,
5362550B293FD639005D64FA /* VLCLibraryWindowController.h */,
5362550C293FD639005D64FA /* VLCLibraryWindowController.m */,
+ 5352B37429E149AC0011CE03 /* VLCLibraryWindowPersistentPreferences.h */,
+ 5352B37529E149AC0011CE03 /* VLCLibraryWindowPersistentPreferences.m */,
5317FE02294E3DD3001702F0 /* VLCLibraryCollectionViewDelegate.h */,
5317FE03294E3DD3001702F0 /* VLCLibraryCollectionViewDelegate.m */,
5317FE05294E8D1A001702F0 /* VLCLibraryCollectionViewDataSource.h */,
@@ -1988,6 +1993,7 @@
7DD2F5C52081B73B007EE187 /* VLCRemoteControlService.m in Sources */,
1C31139F1E508C6900D4DD76 /* VLCMainWindowControlsBar.m in Sources */,
1C3113A11E508C6900D4DD76 /* VLCConvertAndSaveWindowController.m in Sources */,
+ 5352B37629E149AC0011CE03 /* VLCLibraryWindowPersistentPreferences.m in Sources */,
7DBB7639227F3FBC002649E1 /* VLCLibraryCollectionViewSupplementaryElementView.m in Sources */,
1C3113A31E508C6900D4DD76 /* VLCCoreDialogProvider.m in Sources */,
6B2EFC631F281A0900F3C0EA /* VLCVolumeSliderCell.m in Sources */,
=====================================
modules/gui/macosx/Makefile.am
=====================================
@@ -135,6 +135,8 @@ libmacosx_plugin_la_SOURCES = \
gui/macosx/library/VLCLibraryWindow.m \
gui/macosx/library/VLCLibraryWindowController.h \
gui/macosx/library/VLCLibraryWindowController.m \
+ gui/macosx/library/VLCLibraryWindowPersistentPreferences.h \
+ gui/macosx/library/VLCLibraryWindowPersistentPreferences.m \
gui/macosx/library/video-library/VLCLibraryVideoViewController.h \
gui/macosx/library/video-library/VLCLibraryVideoViewController.m \
gui/macosx/library/video-library/VLCLibraryVideoCollectionViewsStackViewController.h \
=====================================
modules/gui/macosx/UI/VLCLibraryWindow.xib
=====================================
@@ -670,6 +670,9 @@
<action selector="segmentedControlAction:" target="QvC-M9-y7g" id="seg-Me-t1n"/>
</connections>
</segmentedControl>
+ <connections>
+ <action selector="segmentedTitleControlAction:" target="QvC-M9-y7g" id="YUg-2w-bwP"/>
+ </connections>
</toolbarItem>
<toolbarItem implicitItemIdentifier="NSToolbarFlexibleSpaceItem" id="89f-AL-zuU"/>
<toolbarItem implicitItemIdentifier="85037E27-D263-490C-B4B2-0EFE5B5837AA" label="Library View Type" paletteLabel="Library View Type" sizingBehavior="auto" id="kBa-MC-Mdq">
@@ -685,6 +688,9 @@
</segments>
</segmentedCell>
</segmentedControl>
+ <connections>
+ <action selector="gridVsListSegmentedControlAction:" target="QvC-M9-y7g" id="HMA-eG-oej"/>
+ </connections>
</toolbarItem>
<searchToolbarItem implicitItemIdentifier="A132890F-6B3D-4523-A71B-B00F095057C4" label="Search" paletteLabel="Search" visibilityPriority="1001" id="dv4-Il-y8X">
<nil key="toolTip"/>
=====================================
modules/gui/macosx/library/VLCLibraryWindow.h
=====================================
@@ -45,9 +45,11 @@ typedef NS_ENUM(NSUInteger, VLCLibrarySegment) {
VLCLibraryStreamsSegment
};
-typedef NS_ENUM(NSUInteger, VLCViewModeSegment) {
- VLCGridViewModeSegment = 0,
- VLCListViewModeSegment
+typedef NS_ENUM(NSInteger, VLCLibraryViewModeSegment) {
+ VLCLibrarySmallestSentinelViewModeSegment = -1,
+ VLCLibraryGridViewModeSegment,
+ VLCLibraryListViewModeSegment,
+ VLCLibraryLargestSentinelViewModeSegment
};
@interface VLCLibraryWindow : VLCFullVideoViewWindow<NSUserInterfaceItemIdentification>
@@ -145,6 +147,7 @@ extern const NSUserInterfaceItemIdentifier VLCLibraryWindowIdentifier;
- (void)togglePlaylist;
- (void)hideControlsBar;
- (void)showControlsBar;
+- (void)updateGridVsListViewModeSegmentedControl;
- (IBAction)playlistDoubleClickAction:(id)sender;
- (IBAction)shuffleAction:(id)sender;
@@ -157,7 +160,9 @@ extern const NSUserInterfaceItemIdentifier VLCLibraryWindowIdentifier;
- (IBAction)showAndHidePlaylist:(id)sender;
- (IBAction)backwardsNavigationAction:(id)sender;
- (IBAction)forwardsNavigationAction:(id)sender;
-- (IBAction)segmentedControlAction:(id)sender;
+- (IBAction)segmentedTitleControlAction:(id)sender;
+- (IBAction)gridVsListSegmentedControlAction:(id)sender;
+
@end
NS_ASSUME_NONNULL_END
=====================================
modules/gui/macosx/library/VLCLibraryWindow.m
=====================================
@@ -21,7 +21,9 @@
*****************************************************************************/
#import "VLCLibraryWindow.h"
-#include "VLCLibraryDataTypes.h"
+
+#import "VLCLibraryDataTypes.h"
+
#import "extensions/NSString+Helpers.h"
#import "extensions/NSFont+VLCAdditions.h"
#import "extensions/NSColor+VLCAdditions.h"
@@ -40,6 +42,7 @@
#import "library/VLCLibrarySortingMenuController.h"
#import "library/VLCLibraryNavigationStack.h"
#import "library/VLCLibraryUIUnits.h"
+#import "library/VLCLibraryWindowPersistentPreferences.h"
#import "library/video-library/VLCLibraryVideoCollectionViewsStackViewController.h"
#import "library/video-library/VLCLibraryVideoTableViewDataSource.h"
@@ -47,6 +50,7 @@
#import "library/audio-library/VLCLibraryAlbumTableCellView.h"
#import "library/audio-library/VLCLibraryAudioViewController.h"
+#import "library/audio-library/VLCLibraryAudioDataSource.h"
#import "media-source/VLCMediaSourceBaseDataSource.h"
#import "media-source/VLCLibraryMediaSourceViewController.h"
@@ -268,7 +272,6 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
{
[super encodeRestorableStateWithCoder:coder];
[coder encodeInteger:_segmentedTitleControl.selectedSegment forKey:@"macosx-library-selected-segment"];
- [coder encodeInteger:_gridVsListSegmentedControl.selectedSegment forKey:@"macosx-library-view-mode-selected-segment"];
[coder encodeInteger:_audioSegmentedControl.selectedSegment forKey:@"macosx-library-audio-view-selected-segment"];
}
@@ -372,13 +375,52 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
#pragma mark - misc. user interactions
-- (void)setViewForSelectedSegment
+- (void)updateGridVsListViewModeSegmentedControl
{
- _currentSelectedSegment = _segmentedTitleControl.selectedSegment;
- _currentSelectedViewModeSegment = _gridVsListSegmentedControl.selectedSegment;
+ const VLCLibrarySegment selectedLibrarySegment = _segmentedTitleControl.selectedSegment;
+ VLCLibraryWindowPersistentPreferences * const preferences = VLCLibraryWindowPersistentPreferences.sharedInstance;
- VLCLibrarySegment selectedLibrarySegment = _segmentedTitleControl.selectedSegment;
switch (selectedLibrarySegment) {
+ case VLCLibraryVideoSegment:
+ _currentSelectedViewModeSegment = preferences.videoLibraryViewMode;
+ break;
+ case VLCLibraryMusicSegment:
+ {
+ const VLCAudioLibrarySegment selectedAudioSegment = _audioSegmentedControl.selectedSegment;
+ switch (selectedAudioSegment) {
+ case VLCAudioLibraryArtistsSegment:
+ _currentSelectedViewModeSegment = preferences.artistLibraryViewMode;
+ break;
+ case VLCAudioLibraryGenresSegment:
+ _currentSelectedViewModeSegment = preferences.genreLibraryViewMode;
+ break;
+ case VLCAudioLibraryAlbumsSegment:
+ _currentSelectedViewModeSegment = preferences.albumLibraryViewMode;
+ break;
+ case VLCAudioLibrarySongsSegment:
+ _currentSelectedViewModeSegment = preferences.songsLibraryViewMode;
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+ case VLCLibraryBrowseSegment:
+ _currentSelectedViewModeSegment = preferences.browseLibraryViewMode;
+ break;
+ case VLCLibraryStreamsSegment:
+ _currentSelectedViewModeSegment = preferences.streamLibraryViewMode;
+ break;
+ default:
+ break;
+ }
+
+ _gridVsListSegmentedControl.selectedSegment = _currentSelectedViewModeSegment;
+}
+
+- (void)setViewForSelectedSegment
+{
+ switch (_currentSelectedSegment) {
case VLCLibraryVideoSegment:
[self showVideoLibrary];
break;
@@ -387,22 +429,73 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
break;
case VLCLibraryBrowseSegment:
case VLCLibraryStreamsSegment:
- [self showMediaSourceLibraryWithSegment:selectedLibrarySegment];
+ [self showMediaSourceLibraryWithSegment:_currentSelectedSegment];
break;
default:
break;
}
+
+ [self invalidateRestorableState];
}
-- (IBAction)segmentedControlAction:(id)sender
+- (IBAction)segmentedTitleControlAction:(id)sender
{
- if (_segmentedTitleControl.selectedSegment == _currentSelectedSegment &&
- _gridVsListSegmentedControl.selectedSegment == _currentSelectedViewModeSegment) {
+ if (_segmentedTitleControl.selectedSegment == _currentSelectedSegment) {
return;
}
+ _currentSelectedSegment = _segmentedTitleControl.selectedSegment;
+ [self setViewForSelectedSegment];
+ [self updateGridVsListViewModeSegmentedControl];
+}
+
+- (IBAction)gridVsListSegmentedControlAction:(id)sender
+{
+ if (_gridVsListSegmentedControl.selectedSegment == _currentSelectedViewModeSegment) {
+ return;
+ }
+
+ _currentSelectedViewModeSegment = _gridVsListSegmentedControl.selectedSegment;
+
+ const VLCLibrarySegment selectedLibrarySegment = _segmentedTitleControl.selectedSegment;
+ VLCLibraryWindowPersistentPreferences * const preferences = VLCLibraryWindowPersistentPreferences.sharedInstance;
+
+ switch (selectedLibrarySegment) {
+ case VLCLibraryVideoSegment:
+ preferences.videoLibraryViewMode = _currentSelectedViewModeSegment;
+ break;
+ case VLCLibraryMusicSegment:
+ {
+ const VLCAudioLibrarySegment selectedAudioSegment = _audioSegmentedControl.selectedSegment;
+ switch (selectedAudioSegment) {
+ case VLCAudioLibraryArtistsSegment:
+ preferences.artistLibraryViewMode = _currentSelectedViewModeSegment;
+ break;
+ case VLCAudioLibraryGenresSegment:
+ preferences.genreLibraryViewMode = _currentSelectedViewModeSegment;
+ break;
+ case VLCAudioLibraryAlbumsSegment:
+ preferences.albumLibraryViewMode = _currentSelectedViewModeSegment;
+ break;
+ case VLCAudioLibrarySongsSegment:
+ preferences.songsLibraryViewMode = _currentSelectedViewModeSegment;
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+ case VLCLibraryBrowseSegment:
+ preferences.browseLibraryViewMode = _currentSelectedViewModeSegment;
+ break;
+ case VLCLibraryStreamsSegment:
+ preferences.streamLibraryViewMode = _currentSelectedViewModeSegment;
+ break;
+ default:
+ break;
+ }
+
[self setViewForSelectedSegment];
- [self invalidateRestorableState];
}
- (void)hideToolbarItem:(NSToolbarItem *)toolbarItem
@@ -500,9 +593,6 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
[self setLibrarySearchToolbarItemVisible:YES];
_optionBarView.hidden = YES;
- _gridVsListSegmentedControl.target = self;
- _gridVsListSegmentedControl.action = @selector(segmentedControlAction:);
-
[_libraryVideoViewController presentVideoView];
}
@@ -513,9 +603,6 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
[self setLibrarySearchToolbarItemVisible:YES];
_optionBarView.hidden = NO;
- _gridVsListSegmentedControl.target = self;
- _gridVsListSegmentedControl.action = @selector(segmentedControlAction:);
-
[_libraryAudioViewController presentAudioView];
}
@@ -614,7 +701,7 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
- (IBAction)goToBrowseSection:(id)sender
{
[_segmentedTitleControl setSelected:YES forSegment:2];
- [self segmentedControlAction:_segmentedTitleControl];
+ [self segmentedTitleControlAction:_segmentedTitleControl];
}
#pragma mark - split view delegation
=====================================
modules/gui/macosx/library/VLCLibraryWindowController.m
=====================================
@@ -68,14 +68,12 @@
VLCLibraryWindow *libraryWindow = [VLCMain sharedInstance].libraryWindow;
NSInteger rememberedSelectedLibrarySegment = [state decodeIntegerForKey:@"macosx-library-selected-segment"];
- NSInteger rememberedSelectedLibraryViewModeSegment = [state decodeIntegerForKey:@"macosx-library-view-mode-selected-segment"];
NSInteger rememberedSelectedLibraryViewAudioSegment = [state decodeIntegerForKey:@"macosx-library-audio-view-selected-segment"];
[libraryWindow.segmentedTitleControl setSelectedSegment:rememberedSelectedLibrarySegment];
- [libraryWindow.gridVsListSegmentedControl setSelectedSegment:rememberedSelectedLibraryViewModeSegment];
[libraryWindow.audioSegmentedControl setSelectedSegment:rememberedSelectedLibraryViewAudioSegment];
- [libraryWindow segmentedControlAction:self];
+ [libraryWindow segmentedTitleControlAction:self];
if (rememberedSelectedLibrarySegment == VLCLibraryMusicSegment) {
[libraryWindow.libraryAudioViewController segmentedControlAction:self];
}
=====================================
modules/gui/macosx/library/VLCLibraryWindowPersistentPreferences.h
=====================================
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * VLCLibraryWindowPersistentPreferences.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2023 VLC authors and VideoLAN
+ *
+ * Authors: Claudio Cambra <developer at claudiocambra.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+#import "VLCLibraryWindow.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+ at interface VLCLibraryWindowPersistentPreferences : NSObject
+
++ (VLCLibraryWindowPersistentPreferences *)sharedInstance;
+
+ at property (readwrite, nonatomic) VLCLibraryViewModeSegment videoLibraryViewMode;
+ at property (readwrite, nonatomic) VLCLibraryViewModeSegment albumLibraryViewMode;
+ at property (readwrite, nonatomic) VLCLibraryViewModeSegment genreLibraryViewMode;
+ at property (readwrite, nonatomic) VLCLibraryViewModeSegment songsLibraryViewMode;
+ at property (readwrite, nonatomic) VLCLibraryViewModeSegment artistLibraryViewMode;
+ at property (readwrite, nonatomic) VLCLibraryViewModeSegment browseLibraryViewMode;
+ at property (readwrite, nonatomic) VLCLibraryViewModeSegment streamLibraryViewMode;
+
+ at end
+
+NS_ASSUME_NONNULL_END
=====================================
modules/gui/macosx/library/VLCLibraryWindowPersistentPreferences.m
=====================================
@@ -0,0 +1,159 @@
+/*****************************************************************************
+ * VLCLibraryWindowPersistentPreferences.m: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2023 VLC authors and VideoLAN
+ *
+ * Authors: Claudio Cambra <developer at claudiocambra.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import "VLCLibraryWindowPersistentPreferences.h"
+
+NSString * const VLCLibraryWindowPreferencePrefix = @"VLCLibraryWindow";
+
+NSString * const VLCLibraryVideoLibraryViewModePreferenceKey = @"VideoLibraryViewMode";
+NSString * const VLCLibraryAlbumLibraryViewModePreferenceKey = @"AlbumLibraryViewMode";
+NSString * const VLCLibraryGenreLibraryViewModePreferenceKey = @"GenreLibraryViewMode";
+NSString * const VLCLibrarySongsLibraryViewModePreferenceKey = @"SongsLibraryViewMode";
+NSString * const VLCLibraryArtistLibraryViewModePreferenceKey = @"ArtistLibraryViewMode";
+NSString * const VLCLibraryBrowseLibraryViewModePreferenceKey = @"BrowseLibraryViewMode";
+NSString * const VLCLibraryStreamLibraryViewModePreferenceKey = @"StreamLibraryViewMode";
+
+ at implementation VLCLibraryWindowPersistentPreferences
+
+static VLCLibraryWindowPersistentPreferences *sharedInstance = nil;
+
++ (VLCLibraryWindowPersistentPreferences *)sharedInstance
+{
+ static dispatch_once_t pred;
+ dispatch_once(&pred, ^{
+ sharedInstance = [[VLCLibraryWindowPersistentPreferences alloc] init];
+ });
+
+ return sharedInstance;
+}
+
+- (NSString * const)fullLibraryWindowKey:(NSString *)partialKey
+{
+ return [NSString stringWithFormat:@"%@.%@", VLCLibraryWindowPreferencePrefix, partialKey];
+}
+
+- (const NSInteger)libraryViewModePreferenceWithKey:(NSString *)key
+{
+ NSUserDefaults * const standardUserDefaults = NSUserDefaults.standardUserDefaults;
+ NSString * const fullKey = [self fullLibraryWindowKey:key];
+ NSInteger viewModeValue = [standardUserDefaults integerForKey:fullKey];
+
+ if (viewModeValue <= VLCLibrarySmallestSentinelViewModeSegment ||
+ viewModeValue >= VLCLibraryLargestSentinelViewModeSegment) {
+
+ NSLog(@"WARNING: Retrieved invalid values for library view mode. Resorting to default.");
+ viewModeValue = VLCLibraryGridViewModeSegment; // Set to workable default
+ }
+
+ return viewModeValue;
+}
+
+- (void)setLibraryWindowViewModePreferenceWithKey:(NSString *)key
+ value:(VLCLibraryViewModeSegment)viewMode
+{
+ NSParameterAssert(viewMode > VLCLibrarySmallestSentinelViewModeSegment &&
+ viewMode < VLCLibraryLargestSentinelViewModeSegment);
+
+ NSUserDefaults * const standardUserDefaults = NSUserDefaults.standardUserDefaults;
+ NSString * const fullKey = [self fullLibraryWindowKey:key];
+ [standardUserDefaults setInteger:viewMode forKey:fullKey];
+}
+
+- (VLCLibraryViewModeSegment)videoLibraryViewMode
+{
+ return [self libraryViewModePreferenceWithKey:VLCLibraryVideoLibraryViewModePreferenceKey];
+}
+
+- (void)setVideoLibraryViewMode:(VLCLibraryViewModeSegment)videoLibraryViewMode
+{
+ [self setLibraryWindowViewModePreferenceWithKey:VLCLibraryVideoLibraryViewModePreferenceKey
+ value:videoLibraryViewMode];
+}
+
+- (VLCLibraryViewModeSegment)albumLibraryViewMode
+{
+ return [self libraryViewModePreferenceWithKey:VLCLibraryAlbumLibraryViewModePreferenceKey];
+}
+
+- (void)setAlbumLibraryViewMode:(VLCLibraryViewModeSegment)albumLibraryViewMode
+{
+ [self setLibraryWindowViewModePreferenceWithKey:VLCLibraryAlbumLibraryViewModePreferenceKey
+ value:albumLibraryViewMode];
+
+}
+
+- (VLCLibraryViewModeSegment)genreLibraryViewMode
+{
+ return [self libraryViewModePreferenceWithKey:VLCLibraryGenreLibraryViewModePreferenceKey];
+}
+
+- (void)setGenreLibraryViewMode:(VLCLibraryViewModeSegment)genreLibraryViewMode
+{
+ [self setLibraryWindowViewModePreferenceWithKey:VLCLibraryGenreLibraryViewModePreferenceKey
+ value:genreLibraryViewMode];
+}
+
+- (VLCLibraryViewModeSegment)songsLibraryViewMode
+{
+ return [self libraryViewModePreferenceWithKey:VLCLibrarySongsLibraryViewModePreferenceKey];
+}
+
+- (void)setSongsLibraryViewMode:(VLCLibraryViewModeSegment)songsLibraryViewMode
+{
+ [self setLibraryWindowViewModePreferenceWithKey:VLCLibrarySongsLibraryViewModePreferenceKey
+ value:songsLibraryViewMode];
+}
+
+- (VLCLibraryViewModeSegment)artistLibraryViewMode
+{
+ return [self libraryViewModePreferenceWithKey:VLCLibraryArtistLibraryViewModePreferenceKey];
+}
+
+- (void)setArtistLibraryViewMode:(VLCLibraryViewModeSegment)artistLibraryViewMode
+{
+ [self setLibraryWindowViewModePreferenceWithKey:VLCLibraryArtistLibraryViewModePreferenceKey
+ value:artistLibraryViewMode];
+}
+
+- (VLCLibraryViewModeSegment)browseLibraryViewMode
+{
+ return [self libraryViewModePreferenceWithKey:VLCLibraryBrowseLibraryViewModePreferenceKey];
+}
+
+- (void)setBrowseLibraryViewMode:(VLCLibraryViewModeSegment)browseLibraryViewMode
+{
+ [self setLibraryWindowViewModePreferenceWithKey:VLCLibraryBrowseLibraryViewModePreferenceKey
+ value:browseLibraryViewMode];
+}
+
+- (VLCLibraryViewModeSegment)streamLibraryViewMode
+{
+ return [self libraryViewModePreferenceWithKey:VLCLibraryStreamLibraryViewModePreferenceKey];
+}
+
+- (void)setStreamLibraryViewMode:(VLCLibraryViewModeSegment)streamLibraryViewMode
+{
+ [self setLibraryWindowViewModePreferenceWithKey:VLCLibraryStreamLibraryViewModePreferenceKey
+ value:streamLibraryViewMode];
+}
+
+ at end
=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.h
=====================================
@@ -48,7 +48,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (readonly) NSScrollView *audioLibraryGridModeSplitViewListSelectionCollectionViewScrollView;
@property (readonly) NSCollectionView *audioLibraryGridModeSplitViewListSelectionCollectionView;
@property (readonly) NSSegmentedControl *audioSegmentedControl;
- at property (readonly) NSSegmentedControl *gridVsListSegmentedControl;
@property (readonly) NSSegmentedControl *segmentedTitleControl;
@property (readonly) NSImageView *placeholderImageView;
@property (readonly) NSTextField *placeholderLabel;
=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.m
=====================================
@@ -30,6 +30,7 @@
#import "library/VLCLibraryModel.h"
#import "library/VLCLibraryNavigationStack.h"
#import "library/VLCLibraryWindow.h"
+#import "library/VLCLibraryWindowPersistentPreferences.h"
#import "library/audio-library/VLCLibraryAlbumTableCellView.h"
#import "library/audio-library/VLCLibraryAudioDataSource.h"
@@ -116,7 +117,6 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
_audioLibraryGridModeSplitViewListSelectionCollectionView = libraryWindow.audioLibraryGridModeSplitViewListSelectionCollectionView;
_audioSegmentedControl = libraryWindow.audioSegmentedControl;
- _gridVsListSegmentedControl = libraryWindow.gridVsListSegmentedControl;
_segmentedTitleControl = libraryWindow.segmentedTitleControl;
_placeholderImageView = libraryWindow.placeholderImageView;
_placeholderLabel = libraryWindow.placeholderLabel;
@@ -355,7 +355,8 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
- (void)updatePresentedView
{
- _audioDataSource.audioLibrarySegment = _audioSegmentedControl.selectedSegment;
+ const VLCAudioLibrarySegment audioLibrarySegment = _audioSegmentedControl.selectedSegment;
+ _audioDataSource.audioLibrarySegment = audioLibrarySegment;
if (_audioDataSource.libraryModel.listOfAudioMedia.count == 0) {
[self presentPlaceholderAudioView];
@@ -363,11 +364,35 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
[self prepareAudioLibraryView];
[self hideAllViews];
- if (self.gridVsListSegmentedControl.selectedSegment == VLCListViewModeSegment) {
+ VLCLibraryViewModeSegment viewModeSegment = VLCLibraryGridViewModeSegment; // default value
+ VLCLibraryWindowPersistentPreferences * const libraryWindowPrefs = VLCLibraryWindowPersistentPreferences.sharedInstance;
+
+ switch (audioLibrarySegment) {
+ case VLCAudioLibraryArtistsSegment:
+ viewModeSegment = libraryWindowPrefs.artistLibraryViewMode;
+ break;
+ case VLCAudioLibraryGenresSegment:
+ viewModeSegment = libraryWindowPrefs.genreLibraryViewMode;
+ break;
+ case VLCAudioLibrarySongsSegment:
+ viewModeSegment = libraryWindowPrefs.songsLibraryViewMode;
+ break;
+ case VLCAudioLibraryAlbumsSegment:
+ viewModeSegment = libraryWindowPrefs.albumLibraryViewMode;
+ break;
+ default:
+ break;
+ }
+
+ if (viewModeSegment == VLCLibraryListViewModeSegment) {
[self presentAudioTableView];
- } else if (self.gridVsListSegmentedControl.selectedSegment == VLCGridViewModeSegment) {
+ } else if (viewModeSegment == VLCLibraryGridViewModeSegment) {
[self presentAudioGridModeView];
+ } else {
+ NSAssert(false, @"View mode must be grid or list mode");
}
+
+ [VLCMain.sharedInstance.libraryWindow updateGridVsListViewModeSegmentedControl];
}
}
=====================================
modules/gui/macosx/library/media-source/VLCLibraryMediaSourceViewController.m
=====================================
@@ -68,7 +68,6 @@
_baseDataSource.collectionViewScrollView = _collectionViewScrollView;
_baseDataSource.homeButton = _homeButton;
_baseDataSource.pathControl = _pathControl;
- _baseDataSource.gridVsListSegmentedControl = _gridVsListSegmentedControl;
_baseDataSource.tableView = _tableView;
[_baseDataSource setupViews];
}
=====================================
modules/gui/macosx/library/media-source/VLCMediaSourceBaseDataSource.h
=====================================
@@ -41,7 +41,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (readwrite) NSCollectionView *collectionView;
@property (readwrite) NSScrollView *collectionViewScrollView;
@property (readwrite) NSTableView *tableView;
- at property (readwrite) NSSegmentedControl *gridVsListSegmentedControl;
@property (readwrite) NSButton *homeButton;
@property (readwrite) VLCInputNodePathControl *pathControl;
@property (readwrite, nonatomic) VLCMediaSourceMode mediaSourceMode;
@@ -51,7 +50,6 @@ NS_ASSUME_NONNULL_BEGIN
- (void)reloadViews;
- (void)homeButtonAction:(id)sender;
- (void)pathControlAction:(id)sender;
-- (void)setGridOrListMode:(id)sender;
@end
=====================================
modules/gui/macosx/library/media-source/VLCMediaSourceBaseDataSource.m
=====================================
@@ -38,6 +38,7 @@
#import "library/VLCLibraryCollectionViewSupplementaryElementView.h"
#import "library/VLCLibraryTableCellView.h"
#import "library/VLCLibraryUIUnits.h"
+#import "library/VLCLibraryWindowPersistentPreferences.h"
#import "main/VLCMain.h"
@@ -114,11 +115,31 @@ NSString *VLCMediaSourceTableViewCellIdentifier = @"VLCMediaSourceTableViewCellI
- (void)reloadViews
{
- self.gridVsListSegmentedControl.action = @selector(setGridOrListMode:);
- self.gridVsListSegmentedControl.target = self;
- _gridViewMode = self.gridVsListSegmentedControl.selectedSegment == VLCGridViewModeSegment;
+ VLCLibraryViewModeSegment viewModeSegment = VLCLibraryGridViewModeSegment;
+ VLCLibraryWindowPersistentPreferences * const libraryWindowPrefs = VLCLibraryWindowPersistentPreferences.sharedInstance;
+
+ switch (_mediaSourceMode) {
+ case VLCMediaSourceModeLAN:
+ viewModeSegment = libraryWindowPrefs.browseLibraryViewMode;
+ break;
+ case VLCMediaSourceModeInternet:
+ viewModeSegment = libraryWindowPrefs.streamLibraryViewMode;
+ break;
+ default:
+ break;
+ }
- [self setCurrentViewMode];
+ if (viewModeSegment == VLCLibraryGridViewModeSegment) {
+ self.collectionViewScrollView.hidden = NO;
+ self.tableView.hidden = YES;
+ [self.collectionView reloadData];
+ } else if (viewModeSegment == VLCLibraryListViewModeSegment) {
+ self.collectionViewScrollView.hidden = YES;
+ self.tableView.hidden = NO;
+ [self.tableView reloadData];
+ } else {
+ NSAssert(false, @"View mode must be grid or list mode");
+ }
}
- (void)loadMediaSources
@@ -464,27 +485,6 @@ referenceSizeForHeaderInSection:(NSInteger)section
}
}
-- (void)setCurrentViewMode
-{
- if (_gridViewMode) {
- self.collectionViewScrollView.hidden = NO;
- self.tableView.hidden = YES;
- [self.collectionView reloadData];
- } else {
- self.collectionViewScrollView.hidden = YES;
- self.tableView.hidden = NO;
- [self.tableView reloadData];
- }
-}
-
-- (void)setGridOrListMode:(id)sender
-{
- _gridViewMode = self.gridVsListSegmentedControl.selectedSegment == VLCGridViewModeSegment;
- _childDataSource.gridViewMode = _gridViewMode;
-
- [self setCurrentViewMode];
-}
-
#pragma mark - VLCMediaSource Delegation
- (void)mediaSourceChildrenReset:(NSNotification *)aNotification
=====================================
modules/gui/macosx/library/media-source/VLCMediaSourceDataSource.h
=====================================
@@ -40,7 +40,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (readwrite, assign) NSCollectionView *collectionView;
@property (readwrite, assign) NSTableView *tableView;
@property (readwrite) VLCInputNodePathControl *pathControl;
- at property (readwrite) BOOL gridViewMode;
- (void)setupViews;
- (VLCInputItem*)mediaSourceInputItemAtRow:(NSInteger)tableViewRow;
=====================================
modules/gui/macosx/library/video-library/VLCLibraryVideoViewController.h
=====================================
@@ -42,7 +42,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (readonly) NSTableView *videoLibraryGroupSelectionTableView;
@property (readonly) NSScrollView *videoLibraryGroupsTableViewScrollView;
@property (readonly) NSTableView *videoLibraryGroupsTableView;
- at property (readonly) NSSegmentedControl *gridVsListSegmentedControl;
@property (readonly) NSSegmentedControl *segmentedTitleControl;
@property (readonly) NSImageView *placeholderImageView;
@property (readonly) NSTextField *placeholderLabel;
=====================================
modules/gui/macosx/library/video-library/VLCLibraryVideoViewController.m
=====================================
@@ -28,6 +28,7 @@
#import "library/VLCLibraryModel.h"
#import "library/VLCLibraryUIUnits.h"
#import "library/VLCLibraryWindow.h"
+#import "library/VLCLibraryWindowPersistentPreferences.h"
#import "library/audio-library/VLCLibraryAudioViewController.h"
@@ -90,7 +91,6 @@
_videoLibraryGroupsTableViewScrollView = libraryWindow.videoLibraryGroupsTableViewScrollView;
_videoLibraryGroupsTableView = libraryWindow.videoLibraryGroupsTableView;
- _gridVsListSegmentedControl = libraryWindow.gridVsListSegmentedControl;
_segmentedTitleControl = libraryWindow.segmentedTitleControl;
_placeholderImageView = libraryWindow.placeholderImageView;
_placeholderLabel = libraryWindow.placeholderLabel;
@@ -208,14 +208,18 @@
[_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_videoLibraryView(>=572.)]|" options:0 metrics:0 views:dict]];
[_libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_videoLibraryView(>=444.)]|" options:0 metrics:0 views:dict]];
- if (self.gridVsListSegmentedControl.selectedSegment == VLCGridViewModeSegment) {
+ const VLCLibraryViewModeSegment viewModeSegment = VLCLibraryWindowPersistentPreferences.sharedInstance.videoLibraryViewMode;
+
+ if (viewModeSegment == VLCLibraryGridViewModeSegment) {
_videoLibrarySplitView.hidden = YES;
_videoLibraryCollectionViewsStackViewScrollView.hidden = NO;
[_libraryVideoCollectionViewsStackViewController reloadData];
- } else {
+ } else if (viewModeSegment == VLCLibraryListViewModeSegment) {
_videoLibrarySplitView.hidden = NO;
_videoLibraryCollectionViewsStackViewScrollView.hidden = YES;
[_libraryVideoTableViewDataSource reloadData];
+ } else {
+ NSAssert(false, @"View mode must be grid or list mode");
}
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3f3b98b6517eb9119e77f3b8b2e64947b64d2ad3...31c3f00de7dc442516fd0c030eb7805d1b78db2c
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3f3b98b6517eb9119e77f3b8b2e64947b64d2ad3...31c3f00de7dc442516fd0c030eb7805d1b78db2c
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list