[vlc-commits] [Git][videolan/vlc][master] 6 commits: macosx: Expose filterString in VLCLibraryModel

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Jun 11 07:47:32 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
0377feaf by Claudio Cambra at 2024-06-11T07:28:21+00:00
macosx: Expose filterString in VLCLibraryModel

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

- - - - -
8c500561 by Claudio Cambra at 2024-06-11T07:28:21+00:00
macosx: Present "No results" label when there are no results for a given filter string

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

- - - - -
fc092c52 by Claudio Cambra at 2024-06-11T07:28:21+00:00
macosx: Create VLCNoResultsLabel class

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

- - - - -
095edeb8 by Claudio Cambra at 2024-06-11T07:28:21+00:00
macosx: Configure no results label within no results label

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

- - - - -
69dc5c45 by Claudio Cambra at 2024-06-11T07:28:21+00:00
macosx: Use VLCNoResultsLabel in audio view controller

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

- - - - -
7cdad4b0 by Claudio Cambra at 2024-06-11T07:28:21+00:00
macosx: Also present no results label if relevant in video library view

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

- - - - -


9 changed files:

- extras/package/macosx/VLC.xcodeproj/project.pbxproj
- modules/gui/macosx/Makefile.am
- modules/gui/macosx/library/VLCLibraryController.m
- modules/gui/macosx/library/VLCLibraryModel.h
- modules/gui/macosx/library/VLCLibraryModel.m
- modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.m
- modules/gui/macosx/library/video-library/VLCLibraryVideoViewController.m
- + modules/gui/macosx/views/VLCNoResultsLabel.h
- + modules/gui/macosx/views/VLCNoResultsLabel.m


Changes:

=====================================
extras/package/macosx/VLC.xcodeproj/project.pbxproj
=====================================
@@ -127,6 +127,7 @@
 		53B447FA293BB47B00857588 /* VLCLibraryVideoGroupDescriptor.m in Sources */ = {isa = PBXBuildFile; fileRef = 53B447F4293BB47A00857588 /* VLCLibraryVideoGroupDescriptor.m */; };
 		53C1EF8B2B466B13001AEEF5 /* VLCLibraryHomeViewVideoGridContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 53C1EF852B466B13001AEEF5 /* VLCLibraryHomeViewVideoGridContainerView.m */; };
 		53C1EF8C2B466B13001AEEF5 /* VLCLibraryHomeViewStackViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 53C1EF862B466B13001AEEF5 /* VLCLibraryHomeViewStackViewController.m */; };
+		53CBE30B2C159A4D006BF2E3 /* VLCNoResultsLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 53CBE30A2C159A4D006BF2E3 /* VLCNoResultsLabel.m */; };
 		53D21A1F2BB465600085C71B /* VLCLibraryWindowPlaylistSidebarViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D21A1E2BB465600085C71B /* VLCLibraryWindowPlaylistSidebarViewController.m */; };
 		53D8ED9A2B583AAF00142EAD /* VLCLibraryModelChangeDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 53D8ED992B583AAF00142EAD /* VLCLibraryModelChangeDelegate.m */; };
 		53ED472329C74D1F00795DB1 /* VLCLibraryAudioTableViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 53ED472229C74D1F00795DB1 /* VLCLibraryAudioTableViewDelegate.m */; };
@@ -388,6 +389,8 @@
 		53C1EF862B466B13001AEEF5 /* VLCLibraryHomeViewStackViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCLibraryHomeViewStackViewController.m; sourceTree = "<group>"; };
 		53C1EF882B466B13001AEEF5 /* VLCLibraryHomeViewVideoGridContainerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCLibraryHomeViewVideoGridContainerView.h; sourceTree = "<group>"; };
 		53C1EF8A2B466B13001AEEF5 /* VLCLibraryHomeViewStackViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCLibraryHomeViewStackViewController.h; sourceTree = "<group>"; };
+		53CBE3092C159A4D006BF2E3 /* VLCNoResultsLabel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCNoResultsLabel.h; sourceTree = "<group>"; };
+		53CBE30A2C159A4D006BF2E3 /* VLCNoResultsLabel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCNoResultsLabel.m; sourceTree = "<group>"; };
 		53D21A1B2BB428A20085C71B /* VLCLibraryWindowNavigationSidebarView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = VLCLibraryWindowNavigationSidebarView.xib; sourceTree = "<group>"; };
 		53D21A1C2BB428F00085C71B /* VLCLibraryWindowPlaylistView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = VLCLibraryWindowPlaylistView.xib; sourceTree = "<group>"; };
 		53D21A1D2BB465600085C71B /* VLCLibraryWindowPlaylistSidebarViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryWindowPlaylistSidebarViewController.h; sourceTree = "<group>"; };
@@ -1074,6 +1077,8 @@
 				7D2FFA3F227B8A5B0085D649 /* VLCLinearProgressIndicator.m */,
 				535053EC2B610C3400D7EAF2 /* VLCLoadingOverlayView.h */,
 				535053ED2B610C3400D7EAF2 /* VLCLoadingOverlayView.m */,
+				53CBE3092C159A4D006BF2E3 /* VLCNoResultsLabel.h */,
+				53CBE30A2C159A4D006BF2E3 /* VLCNoResultsLabel.m */,
 				7D1BF28822A153E20027C50F /* VLCRoundedCornerTextField.h */,
 				7D1BF28922A153E20027C50F /* VLCRoundedCornerTextField.m */,
 				6B13E2A61BC67678001AD24A /* VLCScrollingClipView.h */,
@@ -2141,6 +2146,7 @@
 				536283F4291146BC00640C15 /* VLCLibraryCollectionViewMediaItemSupplementaryDetailView.m in Sources */,
 				7D93D8FC2316C2DC001C0063 /* VLCCustomCropArWindowController.m in Sources */,
 				1C3113941E508C6900D4DD76 /* VLCAddonsWindowController.m in Sources */,
+				53CBE30B2C159A4D006BF2E3 /* VLCNoResultsLabel.m in Sources */,
 				7D92AF2123DDCA8D00D81EA3 /* VLCLibraryImageCache.m in Sources */,
 				7D2E0EDE20CD206F0033A221 /* VLCVideoWindowCommon.m in Sources */,
 				1C3113961E508C6900D4DD76 /* applescript.m in Sources */,


=====================================
modules/gui/macosx/Makefile.am
=====================================
@@ -346,6 +346,8 @@ libmacosx_plugin_la_SOURCES = \
 	gui/macosx/views/VLCLinearProgressIndicator.m \
 	gui/macosx/views/VLCLoadingOverlayView.h \
 	gui/macosx/views/VLCLoadingOverlayView.m \
+	gui/macosx/views/VLCNoResultsLabel.h \
+	gui/macosx/views/VLCNoResultsLabel.m \
 	gui/macosx/views/VLCRoundedCornerTextField.h \
 	gui/macosx/views/VLCRoundedCornerTextField.m \
 	gui/macosx/views/VLCScrollingClipView.h \


=====================================
modules/gui/macosx/library/VLCLibraryController.m
=====================================
@@ -212,7 +212,7 @@ typedef int (*folder_action_f)(vlc_medialibrary_t*, const char*);
 
 - (void)filterByString:(NSString*)filterString
 {
-    [_libraryModel filterByString:filterString];
+    self.libraryModel.filterString = filterString;
 }
 
 @end


=====================================
modules/gui/macosx/library/VLCLibraryModel.h
=====================================
@@ -98,13 +98,14 @@ extern NSString * const VLCLibraryModelGenreUpdated;
 @property (readonly) NSDictionary<NSNumber *, NSString *> *artistDict;
 @property (readonly) NSDictionary<NSNumber *, NSString *> *genreDict;
 
+ at property (readwrite, nonatomic) NSString *filterString;
+
 - (nullable NSArray<VLCMediaLibraryAlbum *> *)listAlbumsOfParentType:(const enum vlc_ml_parent_type)parentType forID:(int64_t)ID;
 - (NSArray<id<VLCMediaLibraryItemProtocol>> *)listOfLibraryItemsOfParentType:(const VLCMediaLibraryParentGroupType)parentType;
 - (NSArray<VLCMediaLibraryMediaItem *> *)listOfMediaItemsForParentType:(const VLCMediaLibraryParentGroupType)parentType;
 
 - (void)sortByCriteria:(enum vlc_ml_sorting_criteria_t)sortCriteria
          andDescending:(bool)descending;
-- (void)filterByString:(NSString*)filterString;
 
 @end
 


=====================================
modules/gui/macosx/library/VLCLibraryModel.m
=====================================
@@ -63,7 +63,6 @@ NSString * const VLCLibraryModelGenreUpdated = @"VLCLibraryModelGenreUpdated";
 
     enum vlc_ml_sorting_criteria_t _sortCriteria;
     bool _sortDescending;
-    NSString *_filterString;
 
     size_t _initialVideoCount;
     size_t _initialAudioCount;
@@ -646,7 +645,7 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
     [self dropCaches];
 }
 
-- (void)filterByString:(NSString*)filterString
+- (void)setFilterString:(NSString *)filterString
 {
     if([filterString isEqualToString:_filterString]) {
         return;


=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.m
=====================================
@@ -50,6 +50,7 @@
 #import "main/VLCMain.h"
 
 #import "views/VLCLoadingOverlayView.h"
+#import "views/VLCNoResultsLabel.h"
 
 #import "windows/video/VLCVoutView.h"
 #import "windows/video/VLCMainVideoViewController.h"
@@ -69,6 +70,8 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
     VLCLibraryTwoPaneSplitViewDelegate *_splitViewDelegate;
 
     NSArray<NSLayoutConstraint *> *_loadingOverlayViewConstraints;
+
+    VLCNoResultsLabel *_noResultsLabel;
 }
 @end
 
@@ -374,6 +377,25 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
     _emptyLibraryView.identifier = VLCLibraryPlaceholderAudioViewIdentifier;
 }
 
+- (void)presentNoResultsView
+{
+    if (_noResultsLabel == nil) {
+        _noResultsLabel = [[VLCNoResultsLabel alloc] init];
+        _noResultsLabel.translatesAutoresizingMaskIntoConstraints = NO;
+    }
+
+    if ([self.libraryTargetView.subviews containsObject:self.loadingOverlayView]) {
+        self.libraryTargetView.subviews = @[_noResultsLabel, self.loadingOverlayView];
+    } else {
+        self.libraryTargetView.subviews = @[_noResultsLabel];
+    }
+
+    [NSLayoutConstraint activateConstraints:@[
+        [_noResultsLabel.centerXAnchor constraintEqualToAnchor:self.libraryTargetView.centerXAnchor],
+        [_noResultsLabel.centerYAnchor constraintEqualToAnchor:self.libraryTargetView.centerYAnchor]
+    ]];
+}
+
 - (void)prepareAudioLibraryView
 {
     self.audioLibraryView.translatesAutoresizingMaskIntoConstraints = NO;
@@ -458,9 +480,9 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
 - (void)updatePresentedView
 {
     self.audioDataSource.audioLibrarySegment = [self currentLibrarySegmentToAudioLibrarySegment];
-    if (_audioDataSource.libraryModel.numberOfAudioMedia == 0) {
-        [self presentPlaceholderAudioView];
-    } else {
+    const BOOL anyAudioMedia = self.audioDataSource.libraryModel.numberOfAudioMedia > 0;
+
+    if (anyAudioMedia) {
         [self prepareAudioLibraryView];
         [self hideAllViews];
 
@@ -475,6 +497,10 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
         }
 
         [VLCMain.sharedInstance.libraryWindow updateGridVsListViewModeSegmentedControl];
+    } else if (self.audioDataSource.libraryModel.filterString.length > 0) {
+        [self presentNoResultsView];
+    } else {
+        [self presentPlaceholderAudioView];
     }
 }
 


=====================================
modules/gui/macosx/library/video-library/VLCLibraryVideoViewController.m
=====================================
@@ -47,6 +47,7 @@
 #import "main/VLCMain.h"
 
 #import "views/VLCLoadingOverlayView.h"
+#import "views/VLCNoResultsLabel.h"
 
 #import "windows/video/VLCVoutView.h"
 #import "windows/video/VLCMainVideoViewController.h"
@@ -61,6 +62,8 @@
     id<VLCMediaLibraryItemProtocol> _awaitingPresentingLibraryItem;
 
     NSArray<NSLayoutConstraint *> *_loadingOverlayViewConstraints;
+
+    VLCNoResultsLabel *_noResultsLabel;
 }
 @end
 
@@ -265,10 +268,13 @@
 
 - (void)updatePresentedView
 {
-    if (_libraryVideoDataSource.libraryModel.numberOfVideoMedia == 0) { // empty library
-        [self presentPlaceholderVideoLibraryView];
-    } else {
+    const BOOL anyVideoMedia = self.libraryVideoDataSource.libraryModel.numberOfVideoMedia > 0;
+    if (anyVideoMedia) {
         [self presentVideoLibraryView];
+    } else if (self.libraryVideoDataSource.libraryModel.filterString.length > 0) {
+        [self presentNoResultsView];
+    } else {
+        [self presentPlaceholderVideoLibraryView];
     }
 }
 
@@ -301,6 +307,25 @@
     _placeholderLabel.stringValue = _NS("Your favorite videos will appear here.\nGo to the Browse section to add videos you love.");
 }
 
+- (void)presentNoResultsView
+{
+    if (_noResultsLabel == nil) {
+        _noResultsLabel = [[VLCNoResultsLabel alloc] init];
+        _noResultsLabel.translatesAutoresizingMaskIntoConstraints = NO;
+    }
+
+    if ([self.libraryTargetView.subviews containsObject:self.loadingOverlayView]) {
+        self.libraryTargetView.subviews = @[_noResultsLabel, self.loadingOverlayView];
+    } else {
+        self.libraryTargetView.subviews = @[_noResultsLabel];
+    }
+
+    [NSLayoutConstraint activateConstraints:@[
+        [_noResultsLabel.centerXAnchor constraintEqualToAnchor:self.libraryTargetView.centerXAnchor],
+        [_noResultsLabel.centerYAnchor constraintEqualToAnchor:self.libraryTargetView.centerYAnchor]
+    ]];
+}
+
 - (void)presentVideoLibraryView
 {
     _videoLibraryView.translatesAutoresizingMaskIntoConstraints = NO;


=====================================
modules/gui/macosx/views/VLCNoResultsLabel.h
=====================================
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ * VLCNoResultsLabel.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2024 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>
+
+NS_ASSUME_NONNULL_BEGIN
+
+ at interface VLCNoResultsLabel : NSTextField
+
+ at end
+
+NS_ASSUME_NONNULL_END


=====================================
modules/gui/macosx/views/VLCNoResultsLabel.m
=====================================
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * VLCNoResultsLabel.m: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2024 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 "VLCNoResultsLabel.h"
+
+#import "extensions/NSFont+VLCAdditions.h"
+#import "extensions/NSString+Helpers.h"
+
+ at implementation VLCNoResultsLabel
+
+- (instancetype)init
+{
+    self = [super init];
+    if (self) {
+        [self setup];
+    }
+    return self;
+}
+
+- (instancetype)initWithCoder:(NSCoder *)coder
+{
+    self = [super initWithCoder:coder];
+    if (self) {
+        [self setup];
+    }
+    return self;
+}
+
+- (instancetype)initWithFrame:(NSRect)frameRect
+{
+    self = [super initWithFrame:frameRect];
+    if (self) {
+        [self setup];
+    }
+    return self;
+}
+
+- (void)setup
+{
+    self.editable = NO;
+    self.selectable = NO;
+    self.bezeled = NO;
+    self.drawsBackground = NO;
+    self.stringValue = _NS("No results");
+    self.font = NSFont.VLClibrarySectionHeaderFont;
+}
+
+ at end



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/45005675ce57d341b19cc56a9169dc1ee886a06c...7cdad4b03b6484a0e52fcc4007297b9953d3c890

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