[vlc-commits] [Git][videolan/vlc][master] 13 commits: macosx: Use displayStrings rather than title for album in VLCLibraryAlbumTableCellView

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sat May 25 18:30:07 UTC 2024



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
0c44e518 by Claudio Cambra at 2024-05-25T18:13:00+00:00
macosx: Use displayStrings rather than title for album in VLCLibraryAlbumTableCellView

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
ed114482 by Claudio Cambra at 2024-05-25T18:13:00+00:00
macosx: Do not provide placeholder strings within media library-matching data type properties, provide only in display strings

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

f

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
4a5ccb5b by Claudio Cambra at 2024-05-25T18:13:00+00:00
macosx: Fix secondary buttons on media item supplementary detail view getting compressed to height 0

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
3729f895 by Claudio Cambra at 2024-05-25T18:13:00+00:00
macosx: Add properties to get current collection item count and the library model's stored item count

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
a98e7f42 by Claudio Cambra at 2024-05-25T18:13:00+00:00
macosx: Do not reset state of awaiting present library item in audio view controller until displayed collection matches actual library model count

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
540ab52f by Claudio Cambra at 2024-05-25T18:13:00+00:00
macosx: Update library segment type when presenting an audio item which changes the audio segment type

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
d2d068c8 by Claudio Cambra at 2024-05-25T18:13:00+00:00
macosx: Remove now unused outlet for segmentedTitleControl

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
23a6f320 by Claudio Cambra at 2024-05-25T18:13:00+00:00
macosx: Properly update sidebar state when updating segment in audio view controller

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
fef8b7b4 by Claudio Cambra at 2024-05-25T18:13:00+00:00
macosx: Update navigation sidebar directly in audio view controlelr current segment type setter

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
ee95e68f by Claudio Cambra at 2024-05-25T18:13:00+00:00
macosx: Remove audio view controller segment property, have one source of truth for library segment

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
064ba2b5 by Claudio Cambra at 2024-05-25T18:13:00+00:00
macosx: Fix view mode in presenting library item for audio view

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
2443aa25 by Claudio Cambra at 2024-05-25T18:13:00+00:00
macosx: Fix crash when accessing carousel count before collection array initialised in home view video container view data source

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
c85ace4b by Claudio Cambra at 2024-05-25T18:13:00+00:00
macosx: Use NO for NSAsserts meant to never be reached

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


10 changed files:

- modules/gui/macosx/UI/VLCLibraryCollectionViewMediaItemSupplementaryDetailView.xib
- modules/gui/macosx/library/VLCLibraryDataTypes.m
- modules/gui/macosx/library/VLCLibraryWindow.h
- modules/gui/macosx/library/VLCLibraryWindow.m
- modules/gui/macosx/library/audio-library/VLCLibraryAlbumTableCellView.m
- modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.h
- modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m
- modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.h
- modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.m
- modules/gui/macosx/library/home-library/VLCLibraryHomeViewVideoContainerViewDataSource.m


Changes:

=====================================
modules/gui/macosx/UI/VLCLibraryCollectionViewMediaItemSupplementaryDetailView.xib
=====================================
@@ -100,6 +100,9 @@
                                                 <font key="font" metaFont="system"/>
                                             </buttonCell>
                                             <color key="contentTintColor" name="VLCAccentColor"/>
+                                            <constraints>
+                                                <constraint firstAttribute="height" constant="16" id="rj4-sx-pmn"/>
+                                            </constraints>
                                             <connections>
                                                 <action selector="primaryDetailAction:" target="HAc-or-XD8" id="bFl-ro-arq"/>
                                             </connections>
@@ -111,6 +114,9 @@
                                                 <font key="font" metaFont="system"/>
                                             </buttonCell>
                                             <color key="contentTintColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
+                                            <constraints>
+                                                <constraint firstAttribute="height" constant="16" id="eff-TH-kPm"/>
+                                            </constraints>
                                             <connections>
                                                 <action selector="secondaryDetailAction:" target="HAc-or-XD8" id="IAX-VG-Kpd"/>
                                             </connections>


=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.m
=====================================
@@ -127,8 +127,8 @@ static NSString *genreArrayDisplayString(NSArray<VLCMediaLibraryGenre *> * const
 
     VLCMediaLibraryGenre * const secondGenre = [genres objectAtIndex:1];
     return [NSString stringWithFormat:_NS("%@, %@, and %lli other genres"),
-                     firstGenre.name,
-                     secondGenre.name,
+                     firstGenre.displayString,
+                     secondGenre.displayString,
                      genreCount - 2];
 }
 
@@ -456,10 +456,6 @@ static NSString *genreArrayDisplayString(NSArray<VLCMediaLibraryGenre *> * const
         self.secondaryActionableDetail = YES;
 
         _name = toNSStr(p_artist->psz_name);
-        if ([_name isEqualToString:@""]) {
-            _name = _NS("Unknown Artist");
-        }
-
         _shortBiography = toNSStr(p_artist->psz_shortbio);
         _musicBrainzID = toNSStr(p_artist->psz_mb_id);
         _numberOfAlbums = p_artist->i_nb_album;
@@ -470,7 +466,7 @@ static NSString *genreArrayDisplayString(NSArray<VLCMediaLibraryGenre *> * const
 
 - (NSString *)displayString
 {
-    return _name;
+    return self.name.length == 0 ? _NS("Unknown Artist") : self.name;
 }
 
 - (NSString *)primaryDetailString
@@ -579,10 +575,6 @@ static NSString *genreArrayDisplayString(NSArray<VLCMediaLibraryGenre *> * const
         self.secondaryActionableDetail = YES;
 
         _title = toNSStr(p_album->psz_title);
-        if ([_title isEqualToString:@""]) {
-            _title = _NS("Unknown Album");
-        }
-
         _summary = toNSStr(p_album->psz_summary);
         _artistName = toNSStr(p_album->psz_artist);
         _artistID = p_album->i_artist_id;
@@ -595,7 +587,7 @@ static NSString *genreArrayDisplayString(NSArray<VLCMediaLibraryGenre *> * const
 
 - (NSString *)displayString
 {
-    return _title;
+    return self.title.length == 0 ? _NS("Unknown Album") : self.title;
 }
 
 - (NSString *)primaryDetailString
@@ -680,10 +672,6 @@ static NSString *genreArrayDisplayString(NSArray<VLCMediaLibraryGenre *> * const
         self.secondaryActionableDetail = NO;
 
         _name = toNSStr(p_genre->psz_name);
-        if ([_name isEqualToString:@""]) {
-            _name = _NS("Unknown Genre");
-        }
-
         _numberOfTracks = p_genre->i_nb_tracks;
     }
     return self;
@@ -705,7 +693,7 @@ static NSString *genreArrayDisplayString(NSArray<VLCMediaLibraryGenre *> * const
 
 - (NSString *)displayString
 {
-    return _name;
+    return self.name.length == 0 ? _NS("Unknown Genre") : self.name;
 }
 
 - (NSString *)primaryDetailString
@@ -886,11 +874,7 @@ static NSString *genreArrayDisplayString(NSArray<VLCMediaLibraryGenre *> * const
         _lastPlayedDate = p_mediaItem->i_last_played_date;
         _progress = p_mediaItem->f_progress;
         _favorited = p_mediaItem->b_is_favorite;
-
         _title = toNSStr(p_mediaItem->psz_title);
-        if ([_title isEqualToString:@""]) {
-            _title = _NS("Unknown Media Item");
-        }
 
         switch (p_mediaItem->i_subtype) {
             case VLC_ML_MEDIA_SUBTYPE_MOVIE:
@@ -1028,7 +1012,7 @@ static NSString *genreArrayDisplayString(NSArray<VLCMediaLibraryGenre *> * const
 
 - (NSString *)displayString
 {
-    return _title;
+    return self.title.length == 0 ? _NS("Unknown item") : self.title;
 }
 
 - (nullable NSString *)contextualPrimaryDetailString


=====================================
modules/gui/macosx/library/VLCLibraryWindow.h
=====================================
@@ -60,7 +60,6 @@ extern const NSUserInterfaceItemIdentifier VLCLibraryWindowIdentifier;
 
 @property (nonatomic, weak) IBOutlet VLCControlsBarCommon* controlsBar;
 @property (readwrite, weak) IBOutlet NSLayoutConstraint *controlsBarHeightConstraint;
- at property (readwrite, weak) IBOutlet NSSegmentedControl *segmentedTitleControl;
 @property (readwrite, weak) IBOutlet NSLayoutConstraint *videoViewBottomConstraint;
 @property (readwrite, weak) IBOutlet NSSegmentedControl *gridVsListSegmentedControl;
 @property (readwrite, weak) IBOutlet NSSplitView *mainSplitView;


=====================================
modules/gui/macosx/library/VLCLibraryWindow.m
=====================================
@@ -337,7 +337,7 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
 - (void)showAudioLibrary
 {
     [self.toolbarDelegate layoutForSegment:VLCLibraryMusicSegment];
-    self.libraryAudioViewController.currentSegmentType = self.librarySegmentType;
+    [self.libraryAudioViewController presentAudioView];
 }
 
 - (void)showMediaSourceLibrary


=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAlbumTableCellView.m
=====================================
@@ -301,7 +301,7 @@ const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
     VLCMediaLibraryAlbum * const album = (VLCMediaLibraryAlbum *)self.representedItem.item;
     NSAssert(album != nil, @"Represented item should be a medialibraryalbum!");
 
-    self.albumNameTextField.stringValue = album.title;
+    self.albumNameTextField.stringValue = album.displayString;
     self.artistNameTextButton.title = album.artistName;
     self.genreNameTextButton.title = album.genreString;
 


=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.h
=====================================
@@ -72,6 +72,8 @@ extern NSString * const VLCLibraryAudioDataSourceDisplayedCollectionChangedNotif
 
 @property (nonatomic, readwrite, assign) VLCAudioLibrarySegment audioLibrarySegment;
 
+ at property (readonly) size_t collectionToDisplayCount;
+ at property (readonly) NSInteger displayedCollectionCount;
 @property (readonly) BOOL displayedCollectionUpdating;
 
 + (void)setupCollectionView:(NSCollectionView *)collectionView;


=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m
=====================================
@@ -119,6 +119,30 @@ NSString * const VLCLibraryAudioDataSourceDisplayedCollectionChangedNotification
     }
 }
 
+- (size_t)collectionToDisplayCount
+{
+    switch(_currentParentType) {
+    case VLCMediaLibraryParentGroupTypeAudioLibrary:
+        return self.libraryModel.numberOfAudioMedia;
+    case VLCMediaLibraryParentGroupTypeRecentAudios:
+        return self.libraryModel.numberOfRecentAudioMedia;
+    case VLCMediaLibraryParentGroupTypeAlbum:
+        return self.libraryModel.numberOfAlbums;
+    case VLCMediaLibraryParentGroupTypeArtist:
+        return self.libraryModel.numberOfArtists;
+    case VLCMediaLibraryParentGroupTypeGenre:
+        return self.libraryModel.numberOfGenres;
+    default:
+        NSAssert(NO, @"current parent type should not be unknown, no collection to display");
+        return 0;
+    }
+}
+
+- (NSInteger)displayedCollectionCount
+{
+    return self.displayedCollection.count;
+}
+
 - (NSArray *)collectionToDisplay
 {
     switch(_currentParentType) {


=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.h
=====================================
@@ -55,7 +55,6 @@ NS_ASSUME_NONNULL_BEGIN
 @property (readonly) NSImageView *placeholderImageView;
 @property (readonly) NSTextField *placeholderLabel;
 @property (readonly) NSView *emptyLibraryView;
- at property (readwrite, nonatomic) VLCLibrarySegmentType currentSegmentType;
 @property (readonly) VLCLoadingOverlayView *loadingOverlayView;
 
 @property (readonly) VLCLibraryAudioDataSource *audioDataSource;


=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.m
=====================================
@@ -32,6 +32,8 @@
 #import "library/VLCLibraryModel.h"
 #import "library/VLCLibraryNavigationStack.h"
 #import "library/VLCLibrarySegment.h"
+#import "library/VLCLibraryWindowNavigationSidebarViewController.h"
+#import "library/VLCLibraryWindowSplitViewController.h"
 #import "library/VLCLibraryTwoPaneSplitViewDelegate.h"
 #import "library/VLCLibraryWindow.h"
 #import "library/VLCLibraryWindowPersistentPreferences.h"
@@ -79,8 +81,6 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
     self = [super init];
 
     if (self) {
-        _currentSegmentType = VLCLibraryLowSentinelSegment;
-
         [self setupPropertiesFromLibraryWindow:libraryWindow];
         [self setupAudioDataSource];
 
@@ -403,7 +403,7 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
 
 - (void)presentAudioGridModeView
 {
-    const VLCLibrarySegmentType selectedSegment = self.currentSegmentType;
+    const VLCLibrarySegmentType selectedSegment = self.libraryWindow.librarySegmentType;
     if (selectedSegment == VLCLibrarySongsMusicSubSegment ||
         selectedSegment == VLCLibraryAlbumsMusicSubSegment) {
 
@@ -418,7 +418,7 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
 
 - (void)presentAudioTableView
 {
-    if (self.currentSegmentType == VLCLibrarySongsMusicSubSegment) {
+    if (self.libraryWindow.librarySegmentType == VLCLibrarySongsMusicSubSegment) {
         _audioSongTableViewScrollView.hidden = NO;
     } else {
         _audioLibrarySplitView.hidden = NO;
@@ -429,7 +429,7 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
 {
     VLCLibraryWindowPersistentPreferences * const libraryWindowPrefs = VLCLibraryWindowPersistentPreferences.sharedInstance;
 
-    switch (self.currentSegmentType) {
+    switch (self.libraryWindow.librarySegmentType) {
         case VLCLibraryArtistsMusicSubSegment:
             return libraryWindowPrefs.artistLibraryViewMode;
         case VLCLibraryGenresMusicSubSegment:
@@ -445,7 +445,7 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
 
 - (VLCAudioLibrarySegment)currentLibrarySegmentToAudioLibrarySegment
 {
-    switch (self.currentSegmentType) {
+    switch (self.libraryWindow.librarySegmentType) {
         case VLCLibraryMusicSegment:
         case VLCLibraryArtistsMusicSubSegment:
             return VLCAudioLibraryArtistsSegment;
@@ -463,7 +463,7 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
 
 - (void)updatePresentedView
 {
-    _audioDataSource.audioLibrarySegment = [self currentLibrarySegmentToAudioLibrarySegment];
+    self.audioDataSource.audioLibrarySegment = [self currentLibrarySegmentToAudioLibrarySegment];
     if (_audioDataSource.libraryModel.numberOfAudioMedia == 0) {
         [self presentPlaceholderAudioView];
     } else {
@@ -484,12 +484,6 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
     }
 }
 
-- (void)setCurrentSegmentType:(VLCLibrarySegmentType)currentSegmentType
-{
-    _currentSegmentType = currentSegmentType;
-    [self updatePresentedView];
-}
-
 - (void)reloadData
 {
     [_audioDataSource reloadData];
@@ -546,6 +540,10 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
 
 - (void)presentLibraryItemWaitForDataSourceFinished:(NSNotification *)aNotification
 {
+    if (self.audioDataSource.displayedCollectionCount < self.audioDataSource.collectionToDisplayCount) {
+        return;
+    }
+    
     [NSNotificationCenter.defaultCenter removeObserver:self
                                                   name:VLCLibraryAudioDataSourceDisplayedCollectionChangedNotification
                                                 object:self.audioDataSource];
@@ -555,6 +553,8 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
         [self presentLibraryItemInTableView:_awaitingPresentingLibraryItem];
     } else if (viewModeSegment == VLCLibraryGridViewModeSegment) {
         [self presentLibraryItemInCollectionView:_awaitingPresentingLibraryItem];
+    } else {
+        NSAssert(NO, @"No valid view mode segment acquired, cannot present item!");
     }
 
     _awaitingPresentingLibraryItem = nil;
@@ -570,14 +570,15 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
 
     // If the library item is a media item, we need to select the corresponding segment
     // in the segmented control. We then need to update the presented view.
+    VLCLibrarySegmentType segmentType;
     if ([libraryItem isKindOfClass:VLCMediaLibraryAlbum.class]) {
-        self.currentSegmentType = VLCLibraryAlbumsMusicSubSegment;
+        segmentType = VLCLibraryAlbumsMusicSubSegment;
     } else if ([libraryItem isKindOfClass:VLCMediaLibraryArtist.class]) {
-        self.currentSegmentType = VLCLibraryArtistsMusicSubSegment;
+        segmentType = VLCLibraryArtistsMusicSubSegment;
     } else if ([libraryItem isKindOfClass:VLCMediaLibraryGenre.class]) {
-        self.currentSegmentType = VLCLibraryGenresMusicSubSegment;
+        segmentType = VLCLibraryGenresMusicSubSegment;
     } else {
-        self.currentSegmentType = VLCLibrarySongsMusicSubSegment;
+        segmentType = VLCLibrarySongsMusicSubSegment;
     }
 
     [NSNotificationCenter.defaultCenter addObserver:self
@@ -585,10 +586,10 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
                                                name:VLCLibraryAudioDataSourceDisplayedCollectionChangedNotification
                                              object:self.audioDataSource];
 
+    VLCLibraryWindow * const libraryWindow = self.libraryWindow;
+    libraryWindow.librarySegmentType = segmentType;
+    [libraryWindow.splitViewController.navSidebarViewController selectSegment:segmentType];
     [self updatePresentedView];
-    if (!self.audioDataSource.displayedCollectionUpdating) {
-        [self presentLibraryItemWaitForDataSourceFinished:nil];
-    }
 }
 
 - (void)libraryModelUpdated:(NSNotification *)aNotification


=====================================
modules/gui/macosx/library/home-library/VLCLibraryHomeViewVideoContainerViewDataSource.m
=====================================
@@ -368,6 +368,10 @@ viewForSupplementaryElementOfKind:(NSCollectionViewSupplementaryElementKind)kind
 
 - (NSInteger)numberOfItemsInCarousel:(iCarousel *)carousel
 {
+    if (self.collectionArray == nil) {
+        return 0;
+    }
+    
     return self.collectionArray.count;
 }
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c0d8f87113ae988c4ae4abaa08e1d4411597038a...c85ace4b60557134cc88b30bd252d86eb01f6b2f

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c0d8f87113ae988c4ae4abaa08e1d4411597038a...c85ace4b60557134cc88b30bd252d86eb01f6b2f
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