Browse Source

macosx: Use new library window preferences to set gridvslist view mode in audio view controller

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
pull/162/head
Claudio Cambra 3 years ago
committed by Jean-Baptiste Kempf
parent
commit
b6f82edafc
  1. 1
      modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.h
  2. 31
      modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.m

1
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;
@property (readonly) NSSegmentedControl *gridVsListSegmentedControl;
@property (readonly) NSSegmentedControl *segmentedTitleControl;
@property (readonly) NSImageView *placeholderImageView;
@property (readonly) NSTextField *placeholderLabel;

31
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,10 +364,32 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
[self prepareAudioLibraryView];
[self hideAllViews];
if (self.gridVsListSegmentedControl.selectedSegment == VLCLibraryListViewModeSegment) {
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 == VLCLibraryGridViewModeSegment) {
} else if (viewModeSegment == VLCLibraryGridViewModeSegment) {
[self presentAudioGridModeView];
} else {
NSAssert(false, @"View mode must be grid or list mode");
}
}
}

Loading…
Cancel
Save