diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj index 88cfed343525e7f2e5649142cfc68cf32a6af922..e2aef9ee67641d156aba53b344e85f0d84fb532e 100644 --- a/extras/package/macosx/VLC.xcodeproj/project.pbxproj +++ b/extras/package/macosx/VLC.xcodeproj/project.pbxproj @@ -105,6 +105,7 @@ 7D1BF28A22A153E20027C50F /* VLCRoundedCornerTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D1BF28922A153E20027C50F /* VLCRoundedCornerTextField.m */; }; 7D1BF28D22A192000027C50F /* VLCPlaylistSortingMenuController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D1BF28C22A192000027C50F /* VLCPlaylistSortingMenuController.m */; }; 7D20081A2289835C002679DF /* VLCTrackingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D2008192289835C002679DF /* VLCTrackingView.m */; }; + 7D22A8F422BC14F80063ECD2 /* VLCLibrarySortingMenuController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D22A8F322BC14F80063ECD2 /* VLCLibrarySortingMenuController.m */; }; 7D28E6362275B4820098D30E /* NSColor+VLCAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D28E6352275B4820098D30E /* NSColor+VLCAdditions.m */; }; 7D28E6392275B7340098D30E /* NSFont+VLCAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D28E6382275B7340098D30E /* NSFont+VLCAdditions.m */; }; 7D2E0EDB20CD204D0033A221 /* VLCWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D2E0ED920CD204D0033A221 /* VLCWindow.m */; }; @@ -457,6 +458,8 @@ 7D1BF28C22A192000027C50F /* VLCPlaylistSortingMenuController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCPlaylistSortingMenuController.m; sourceTree = "<group>"; }; 7D2008182289835C002679DF /* VLCTrackingView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCTrackingView.h; sourceTree = "<group>"; }; 7D2008192289835C002679DF /* VLCTrackingView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCTrackingView.m; sourceTree = "<group>"; }; + 7D22A8F222BC14F80063ECD2 /* VLCLibrarySortingMenuController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibrarySortingMenuController.h; sourceTree = "<group>"; }; + 7D22A8F322BC14F80063ECD2 /* VLCLibrarySortingMenuController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLibrarySortingMenuController.m; sourceTree = "<group>"; }; 7D28E6342275B4820098D30E /* NSColor+VLCAdditions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSColor+VLCAdditions.h"; sourceTree = "<group>"; }; 7D28E6352275B4820098D30E /* NSColor+VLCAdditions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSColor+VLCAdditions.m"; sourceTree = "<group>"; }; 7D28E6372275B7340098D30E /* NSFont+VLCAdditions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSFont+VLCAdditions.h"; sourceTree = "<group>"; }; @@ -1030,6 +1033,8 @@ 7DE2F0432282C84A0040DD0A /* VLCLibraryAudioDataSource.m */, 7DFBDCAF226A518400B700A5 /* VLCLibraryMenuController.h */, 7DFBDCB0226A518400B700A5 /* VLCLibraryMenuController.m */, + 7D22A8F222BC14F80063ECD2 /* VLCLibrarySortingMenuController.h */, + 7D22A8F322BC14F80063ECD2 /* VLCLibrarySortingMenuController.m */, 7DFBDCBF226DC16200B700A5 /* VLCInputItem.h */, 7DFBDCC0226DC16200B700A5 /* VLCInputItem.m */, ); @@ -1737,6 +1742,7 @@ 7D0F64062202047900FDB91F /* VLCLibraryCollectionViewItem.m in Sources */, 7D713D322201AE350042BEB7 /* VLCLibraryWindow.m in Sources */, 7DF14FBD2270CB1C0008ABE4 /* VLCMediaSourceCollectionViewItem.m in Sources */, + 7D22A8F422BC14F80063ECD2 /* VLCLibrarySortingMenuController.m in Sources */, 1C3113C91E508C6900D4DD76 /* VLCOutput.m in Sources */, 1C1C62011F8260A90052DD4F /* VLCWrappableTextField.m in Sources */, 6BBB05DA1EEFEA29003A1019 /* VLCHUDOutlineView.m in Sources */, diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am index 325858c2dc56e9a0c0ebd0ffefacb27d97805a9c..13931cbf69a9bd8433cfb0d4ad618857afce4450 100644 --- a/modules/gui/macosx/Makefile.am +++ b/modules/gui/macosx/Makefile.am @@ -70,6 +70,8 @@ libmacosx_plugin_la_SOURCES = \ gui/macosx/library/VLCLibraryMenuController.m \ gui/macosx/library/VLCLibraryModel.h \ gui/macosx/library/VLCLibraryModel.m \ + gui/macosx/library/VLCLibrarySortingMenuController.h \ + gui/macosx/library/VLCLibrarySortingMenuController.m \ gui/macosx/library/VLCLibraryTableCellView.h \ gui/macosx/library/VLCLibraryTableCellView.m \ gui/macosx/library/VLCLibraryVideoDataSource.h \ diff --git a/modules/gui/macosx/UI/VLCLibraryWindow.xib b/modules/gui/macosx/UI/VLCLibraryWindow.xib index 646999ac2ca8aaf51b7779c9e71876f6fc03d55f..cc505f6055be16d3b773f9fa41003af66437169f 100644 --- a/modules/gui/macosx/UI/VLCLibraryWindow.xib +++ b/modules/gui/macosx/UI/VLCLibraryWindow.xib @@ -461,6 +461,9 @@ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="system"/> </buttonCell> + <connections> + <action selector="sortLibrary:" target="QvC-M9-y7g" id="VJd-p4-owD"/> + </connections> </button> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Rhu-eh-ywm"> <rect key="frame" x="56" y="328" width="45" height="32"/> @@ -561,7 +564,7 @@ <rect key="frame" x="0.0" y="498" width="242" height="310"/> <clipView key="contentView" copiesOnScroll="NO" id="J5s-sy-il6"> <rect key="frame" x="0.0" y="0.0" width="242" height="310"/> - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <autoresizingMask key="autoresizingMask"/> <subviews> <collectionView selectable="YES" id="hnE-Hj-MZo"> <rect key="frame" x="0.0" y="0.0" width="242" height="310"/> @@ -591,7 +594,7 @@ <rect key="frame" x="0.0" y="0.0" width="242" height="498"/> <clipView key="contentView" copiesOnScroll="NO" id="OKa-dt-1yY"> <rect key="frame" x="0.0" y="0.0" width="242" height="498"/> - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <autoresizingMask key="autoresizingMask"/> <subviews> <collectionView selectable="YES" id="B8x-e8-7zp"> <rect key="frame" x="0.0" y="0.0" width="242" height="498"/> @@ -639,7 +642,7 @@ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <clipView key="contentView" id="tI4-x3-55j"> <rect key="frame" x="0.0" y="0.0" width="242" height="291"/> - <autoresizingMask key="autoresizingMask"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <collectionView id="r7v-GI-W1U"> <rect key="frame" x="0.0" y="0.0" width="242" height="291"/> @@ -669,7 +672,7 @@ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <clipView key="contentView" id="dmB-cB-az6"> <rect key="frame" x="0.0" y="0.0" width="155" height="327"/> - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <autoresizingMask key="autoresizingMask"/> <subviews> <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnReordering="NO" columnSelection="YES" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" rowHeight="36" rowSizeStyle="large" viewBased="YES" id="dNP-8u-8iI"> <rect key="frame" x="0.0" y="0.0" width="155" height="327"/> @@ -729,7 +732,7 @@ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <clipView key="contentView" id="qva-RZ-DvL"> <rect key="frame" x="0.0" y="0.0" width="154" height="327"/> - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <autoresizingMask key="autoresizingMask"/> <subviews> <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnReordering="NO" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" viewBased="YES" id="LNt-ot-2wU"> <rect key="frame" x="0.0" y="0.0" width="154" height="327"/> @@ -789,7 +792,7 @@ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <clipView key="contentView" id="xCC-h9-931"> <rect key="frame" x="0.0" y="0.0" width="197" height="327"/> - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <autoresizingMask key="autoresizingMask"/> <subviews> <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnReordering="NO" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="4ll-T2-J16"> <rect key="frame" x="0.0" y="0.0" width="197" height="327"/> @@ -860,7 +863,7 @@ <rect key="frame" x="0.0" y="0.0" width="500" height="302"/> <clipView key="contentView" id="2oa-WL-dxA"> <rect key="frame" x="0.0" y="0.0" width="500" height="302"/> - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <autoresizingMask key="autoresizingMask"/> <subviews> <collectionView id="QAt-jP-zE7"> <rect key="frame" x="0.0" y="0.0" width="500" height="302"/> diff --git a/modules/gui/macosx/library/VLCLibraryController.h b/modules/gui/macosx/library/VLCLibraryController.h index 93e0371a7efe2f4f9e9d1370c0795c2d553b048c..0c16554b1c25987c00e0885c81493299128891d0 100644 --- a/modules/gui/macosx/library/VLCLibraryController.h +++ b/modules/gui/macosx/library/VLCLibraryController.h @@ -22,6 +22,8 @@ #import <Foundation/Foundation.h> +#import <vlc_media_library.h> + @class VLCLibraryModel; @class VLCMediaLibraryMediaItem; @@ -42,6 +44,29 @@ NS_ASSUME_NONNULL_BEGIN - (int)clearHistory; +/** + * Sort the entire library representation based on: + * @param sortCriteria the criteria used for sorting + * @param descending sort ascending or descending. + */ +- (void)sortByCriteria:(enum vlc_ml_sorting_criteria_t)sortCriteria andDescending:(bool)descending; + +/** + * Initially, the library is unsorted until the user decides to do so + * Until then, the unsorted state is retained. + */ +@property (readonly) BOOL unsorted; + +/** + * The last key used for sorting + */ +@property (readonly) enum vlc_ml_sorting_criteria_t lastSortingCriteria; + +/** + * The last order used for sorting + */ +@property (readonly) bool descendingLibrarySorting; + @end NS_ASSUME_NONNULL_END diff --git a/modules/gui/macosx/library/VLCLibraryController.m b/modules/gui/macosx/library/VLCLibraryController.m index 30f76131bbe2cc89dadcfafb595b4bd77926a9fb..0d882e72e39b5a7aa640bae3cf9c5d26189ed7e2 100644 --- a/modules/gui/macosx/library/VLCLibraryController.m +++ b/modules/gui/macosx/library/VLCLibraryController.m @@ -44,6 +44,7 @@ if (self) { _p_libraryInstance = vlc_ml_instance_get(getIntf()); _libraryModel = [[VLCLibraryModel alloc] initWithLibrary:_p_libraryInstance]; + _unsorted = YES; NSNotificationCenter *defaultNotificationCenter = [NSNotificationCenter defaultCenter]; [defaultNotificationCenter addObserver:self @@ -154,4 +155,12 @@ return vlc_ml_clear_history(_p_libraryInstance); } +- (void)sortByCriteria:(enum vlc_ml_sorting_criteria_t)sortCriteria andDescending:(bool)descending +{ + _unsorted = NO; + _lastSortingCriteria = sortCriteria; + _descendingLibrarySorting = descending; + [_libraryModel sortByCriteria:sortCriteria andDescending:descending]; +} + @end diff --git a/modules/gui/macosx/library/VLCLibraryModel.h b/modules/gui/macosx/library/VLCLibraryModel.h index 80e04dd06c603e2b1dcb062f3acc3337341466e3..28cf9769793cd7c99387c5673e248201043c9ce9 100644 --- a/modules/gui/macosx/library/VLCLibraryModel.h +++ b/modules/gui/macosx/library/VLCLibraryModel.h @@ -67,6 +67,8 @@ extern NSString *VLCLibraryModelMediaItemUpdated; - (nullable NSArray <VLCMediaLibraryAlbum *>*)listAlbumsOfParentType:(enum vlc_ml_parent_type)parentType forID:(int64_t)ID; +- (void)sortByCriteria:(enum vlc_ml_sorting_criteria_t)sortCriteria andDescending:(bool)descending; + @end NS_ASSUME_NONNULL_END diff --git a/modules/gui/macosx/library/VLCLibraryModel.m b/modules/gui/macosx/library/VLCLibraryModel.m index 09ae2c3532e5c2861caa83a4d8d556e17bc2ce32..bfd0bd71f1a0e0ed4aa264fab0d3dd4144eb2303 100644 --- a/modules/gui/macosx/library/VLCLibraryModel.m +++ b/modules/gui/macosx/library/VLCLibraryModel.m @@ -45,6 +45,9 @@ NSString *VLCLibraryModelMediaItemUpdated = @"VLCLibraryModelMediaItemUpdated"; NSArray *_cachedVideoMedia; NSArray *_cachedRecentMedia; NSNotificationCenter *_defaultNotificationCenter; + + enum vlc_ml_sorting_criteria_t _sortCriteria; + bool _sortDescending; } - (void)updateCachedListOfAudioMedia; @@ -88,6 +91,8 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event) { self = [super init]; if (self) { + _sortCriteria = VLC_ML_SORTING_DEFAULT; + _sortDescending = NO; _p_mediaLibrary = library; _p_eventCallback = vlc_ml_event_register_callback(_p_mediaLibrary, libraryCallback, (__bridge void *)self); _defaultNotificationCenter = [NSNotificationCenter defaultCenter]; @@ -249,7 +254,12 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event) - (void)updateCachedListOfVideoMedia { - vlc_ml_media_list_t *p_media_list = vlc_ml_list_video_media(_p_mediaLibrary, NULL); + vlc_ml_query_params_t queryParameters; + memset(&queryParameters, 0, sizeof(vlc_ml_query_params_t)); + queryParameters.i_nbResults = 20; + queryParameters.i_sort = _sortCriteria; + queryParameters.b_desc = _sortDescending; + vlc_ml_media_list_t *p_media_list = vlc_ml_list_video_media(_p_mediaLibrary, &queryParameters); if (p_media_list == NULL) { return; } @@ -278,6 +288,7 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event) vlc_ml_query_params_t queryParameters; memset(&queryParameters, 0, sizeof(vlc_ml_query_params_t)); queryParameters.i_nbResults = 20; + // we don't set the sorting criteria here as they are not applicable to history vlc_ml_media_list_t *p_media_list = vlc_ml_list_history(_p_mediaLibrary, &queryParameters); if (p_media_list == NULL) { return; @@ -348,4 +359,17 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event) return [mutableArray copy]; } +- (void)sortByCriteria:(enum vlc_ml_sorting_criteria_t)sortCriteria andDescending:(bool)descending +{ + _sortCriteria = sortCriteria; + _sortDescending = descending; + [self dropCaches]; +} + +- (void)dropCaches +{ + _cachedVideoMedia = nil; + [_defaultNotificationCenter postNotificationName:VLCLibraryModelVideoMediaListUpdated object:nil]; +} + @end diff --git a/modules/gui/macosx/library/VLCLibrarySortingMenuController.h b/modules/gui/macosx/library/VLCLibrarySortingMenuController.h new file mode 100644 index 0000000000000000000000000000000000000000..2dfe4109ca87f249f44709373fedbd23780e2909 --- /dev/null +++ b/modules/gui/macosx/library/VLCLibrarySortingMenuController.h @@ -0,0 +1,33 @@ +/***************************************************************************** + * VLCLibrarySortingMenuController.h: MacOS X interface module + ***************************************************************************** + * Copyright (C) 2019 VLC authors and VideoLAN + * + * Authors: Felix Paul Kühne <fkuehne # videolan -dot- org> + * + * 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 + +@interface VLCLibrarySortingMenuController : NSObject + +@property (readonly) NSMenu *librarySortingMenu; + +@end + +NS_ASSUME_NONNULL_END diff --git a/modules/gui/macosx/library/VLCLibrarySortingMenuController.m b/modules/gui/macosx/library/VLCLibrarySortingMenuController.m new file mode 100644 index 0000000000000000000000000000000000000000..a14798e39799191de176c07e8beb905d7957c307 --- /dev/null +++ b/modules/gui/macosx/library/VLCLibrarySortingMenuController.m @@ -0,0 +1,134 @@ +/***************************************************************************** + * VLCLibrarySortingMenuController.m: MacOS X interface module + ***************************************************************************** + * Copyright (C) 2019 VLC authors and VideoLAN + * + * Authors: Felix Paul Kühne <fkuehne # videolan -dot- org> + * + * 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 "VLCLibrarySortingMenuController.h" + +#import "library/VLCLibraryController.h" +#import "extensions/NSString+Helpers.h" +#import "main/VLCMain.h" + +#import <vlc_media_library.h> + +@interface VLCLibrarySortingMenuController () <NSMenuDelegate> +{ + VLCLibraryController *_libraryController; + NSMenu *_librarySortingMenu; +} +@end + +@implementation VLCLibrarySortingMenuController + +- (instancetype)init +{ + self = [super init]; + if (self) { + [self createMenu]; + _libraryController = [[VLCMain sharedInstance] libraryController]; + } + return self; +} + +- (void)createMenu +{ + _librarySortingMenu = [[NSMenu alloc] init]; + + NSArray *titles = @[_NS("Default"), + _NS("Alphabetically"), + _NS("Duration"), + _NS("Insertion Date"), + _NS("Last Modification Date"), + _NS("Release Date"), + _NS("File Size"), + _NS("Artist"), + _NS("Play Count"), + _NS("Album"), + _NS("Filename"), + _NS("Track Number")]; + NSUInteger count = titles.count; + for (NSUInteger x = 0; x < count; x++) { + NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:titles[x] action:@selector(selectSortKey:) keyEquivalent:@""]; + menuItem.target = self; + menuItem.tag = x; + [_librarySortingMenu addItem:menuItem]; + } + + [_librarySortingMenu addItem:[NSMenuItem separatorItem]]; + + titles = @[_NS("Ascending"), + _NS("Descending")]; + count = titles.count; + for (NSUInteger x = 0; x < count; x++) { + NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:titles[x] action:@selector(selectSortOrder:) keyEquivalent:@""]; + menuItem.target = self; + menuItem.tag = x + 100; + [_librarySortingMenu addItem:menuItem]; + } + + _librarySortingMenu.delegate = self; +} + +- (void)menuNeedsUpdate:(NSMenu *)menu +{ + if (_libraryController.unsorted) { + return; + } + NSInteger count = _librarySortingMenu.numberOfItems; + for (NSInteger x = 0; x < count; x++) { + NSMenuItem *menuItem = [_librarySortingMenu itemAtIndex:x]; + menuItem.state = NSOffState; + } + + NSMenuItem *menuItem = [_librarySortingMenu itemWithTag:_libraryController.lastSortingCriteria]; + menuItem.state = NSOnState; + + menuItem = [_librarySortingMenu itemWithTag:_libraryController.descendingLibrarySorting + 100]; + menuItem.state = NSOnState; +} + +- (void)selectSortKey:(id)sender +{ + enum vlc_ml_sorting_criteria_t sortCriteria = (enum vlc_ml_sorting_criteria_t)[sender tag]; + bool descending; + if (_libraryController.unsorted) { + /* we don't have an order and the user can only do a single selection - pick the most popular */ + descending = NO; + } else { + descending = YES; + } + + [_libraryController sortByCriteria:sortCriteria andDescending:descending]; +} + +- (void)selectSortOrder:(id)sender +{ + enum vlc_ml_sorting_criteria_t sortCriteria = (enum vlc_ml_sorting_criteria_t)[sender tag]; + bool descending = ([sender tag] - 100); + if (_libraryController.unsorted) { + /* we don't have a key and the user can only do a single selection - pick the most popular */ + sortCriteria = VLC_ML_SORTING_DEFAULT; + } else { + sortCriteria = _libraryController.lastSortingCriteria; + } + + [_libraryController sortByCriteria:sortCriteria andDescending:descending]; +} +@end diff --git a/modules/gui/macosx/library/VLCLibraryWindow.h b/modules/gui/macosx/library/VLCLibraryWindow.h index 7d1ac8fed67aa286ee34dc0e494efb83c8c50a37..e74163cc68b66eb74d748aa95027dcf9b91394d1 100644 --- a/modules/gui/macosx/library/VLCLibraryWindow.h +++ b/modules/gui/macosx/library/VLCLibraryWindow.h @@ -74,6 +74,7 @@ NS_ASSUME_NONNULL_BEGIN - (IBAction)repeatAction:(id)sender; - (IBAction)clearPlaylist:(id)sender; - (IBAction)sortPlaylist:(id)sender; +- (IBAction)sortLibrary:(id)sender; - (IBAction)openMedia:(id)sender; - (IBAction)showAndHidePlaylist:(id)sender; diff --git a/modules/gui/macosx/library/VLCLibraryWindow.m b/modules/gui/macosx/library/VLCLibraryWindow.m index f19475b84baf388fbcdf17de847395518a8f5110..c5d6bbe17b11d317291f84e45d053badf2423433 100644 --- a/modules/gui/macosx/library/VLCLibraryWindow.m +++ b/modules/gui/macosx/library/VLCLibraryWindow.m @@ -39,6 +39,7 @@ #import "library/VLCLibraryModel.h" #import "library/VLCLibraryCollectionViewSupplementaryElementView.h" #import "library/VLCLibraryAlternativeAudioViewController.h" +#import "library/VLCLibrarySortingMenuController.h" #import "media-source/VLCMediaSourceCollectionViewItem.h" #import "media-source/VLCMediaSourceDataSource.h" @@ -70,6 +71,7 @@ const CGFloat VLCLibraryWindowDefaultPlaylistWidth = 340.; VLCLibraryVideoDataSource *_libraryVideoDataSource; VLCLibraryAudioDataSource *_libraryAudioDataSource; VLCLibraryGroupDataSource *_libraryAudioGroupDataSource; + VLCLibrarySortingMenuController *_librarySortingMenuController; VLCMediaSourceDataSource *_mediaSourceDataSource; VLCLibraryAlternativeAudioViewController *_alternativeAudioViewController; VLCPlaylistSortingMenuController *_playlistSortingMenuController; @@ -465,6 +467,14 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, [NSMenu popUpContextMenu:_playlistSortingMenuController.playlistSortingMenu withEvent:[NSApp currentEvent] forView:sender]; } +- (IBAction)sortLibrary:(id)sender +{ + if (!_librarySortingMenuController) { + _librarySortingMenuController = [[VLCLibrarySortingMenuController alloc] init]; + } + [NSMenu popUpContextMenu:_librarySortingMenuController.librarySortingMenu withEvent:[NSApp currentEvent] forView:sender]; +} + - (IBAction)openMedia:(id)sender { [[[VLCMain sharedInstance] open] openFileGeneric]; diff --git a/po/POTFILES.in b/po/POTFILES.in index e6f5357be71ba49b80ea7b2ad83c9bded73101db..9a3e4b312f76a88852664271178114404fff1740 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -475,6 +475,8 @@ modules/gui/macosx/library/VLCLibraryMenuController.h modules/gui/macosx/library/VLCLibraryMenuController.m modules/gui/macosx/library/VLCLibraryModel.h modules/gui/macosx/library/VLCLibraryModel.m +modules/gui/macosx/library/VLCLibrarySortingMenuController.h +modules/gui/macosx/library/VLCLibrarySortingMenuController.m modules/gui/macosx/library/VLCLibraryTableCellView.h modules/gui/macosx/library/VLCLibraryTableCellView.m modules/gui/macosx/library/VLCLibraryVideoDataSource.h