[vlc-commits] [Git][videolan/vlc][3.0.x] 2 commits: macosx: move playlist sorting into separate function

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Thu Dec 2 19:32:49 UTC 2021



Hugo Beauzée-Luyssen pushed to branch 3.0.x at VideoLAN / VLC


Commits:
0601a14d by Marvin Scholz at 2021-12-02T18:43:40+00:00
macosx: move playlist sorting into separate function

- - - - -
f5dfb2f8 by Marvin Scholz at 2021-12-02T18:43:40+00:00
macosx: add ability to shuffle playlist

- - - - -


5 changed files:

- modules/gui/macosx/UI/PlaylistMenu.xib
- modules/gui/macosx/VLCPLModel.h
- modules/gui/macosx/VLCPLModel.m
- modules/gui/macosx/VLCPlaylist.h
- modules/gui/macosx/VLCPlaylist.m


Changes:

=====================================
modules/gui/macosx/UI/PlaylistMenu.xib
=====================================
@@ -17,6 +17,7 @@
                 <outlet property="recursiveExpandPlaylistMenuItem" destination="5" id="vFK-br-qmx"/>
                 <outlet property="revealInFinderPlaylistMenuItem" destination="3" id="IrJ-gR-Zqp"/>
                 <outlet property="selectAllPlaylistMenuItem" destination="14" id="drx-ij-QhT"/>
+                <outlet property="shufflePlaylistMenuItem" destination="DEp-am-rqj" id="5Ds-42-jCY"/>
             </connections>
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
@@ -65,6 +66,12 @@
                     </connections>
                 </menuItem>
                 <menuItem isSeparatorItem="YES" id="sUF-9g-Rxq"/>
+                <menuItem title="Shuffle playlist" id="DEp-am-rqj">
+                    <modifierMask key="keyEquivalentModifierMask"/>
+                    <connections>
+                        <action selector="shufflePlaylist:" target="-2" id="gwd-uc-rZn"/>
+                    </connections>
+                </menuItem>
                 <menuItem title="Add Files" id="lGc-nc-8Yq">
                     <modifierMask key="keyEquivalentModifierMask"/>
                     <connections>


=====================================
modules/gui/macosx/VLCPLModel.h
=====================================
@@ -74,6 +74,7 @@ typedef enum {
 - (void)playbackModeUpdated;
 
 // sorting / searching
+- (void)sortPlaylistBy:(int)mode withOrder:(int)order;
 - (void)sortForColumn:(NSString *)o_column withMode:(int)i_mode;
 
 - (void)searchUpdate:(NSString *)o_search;


=====================================
modules/gui/macosx/VLCPLModel.m
=====================================
@@ -425,6 +425,22 @@ static int VolumeUpdated(vlc_object_t *p_this, const char *psz_var,
 #pragma mark -
 #pragma mark Sorting / Searching
 
+- (void)sortPlaylistBy:(int)mode withOrder:(int)order
+{
+    PL_LOCK;
+    playlist_item_t *p_root = playlist_ItemGetById(p_playlist, [_rootItem plItemId]);
+    if (!p_root) {
+        PL_UNLOCK;
+        return;
+    }
+
+    playlist_RecursiveNodeSort(p_playlist, p_root, mode, order);
+
+    [self rebuildVLCPLItem:_rootItem];
+    [_outlineView reloadData];
+    PL_UNLOCK;
+}
+
 - (void)sortForColumn:(NSString *)o_column withMode:(int)i_mode
 {
     int i_column = 0;
@@ -447,18 +463,7 @@ static int VolumeUpdated(vlc_object_t *p_this, const char *psz_var,
     else
         return;
 
-    PL_LOCK;
-    playlist_item_t *p_root = playlist_ItemGetById(p_playlist, [_rootItem plItemId]);
-    if (!p_root) {
-        PL_UNLOCK;
-        return;
-    }
-
-    playlist_RecursiveNodeSort(p_playlist, p_root, i_column, i_mode);
-
-    [self rebuildVLCPLItem:_rootItem];
-    [_outlineView reloadData];
-    PL_UNLOCK;
+    [self sortPlaylistBy:i_column withOrder:i_mode];
 }
 
 - (void)searchUpdate:(NSString *)o_search


=====================================
modules/gui/macosx/VLCPlaylist.h
=====================================
@@ -37,6 +37,7 @@
 @property (readwrite, weak) IBOutlet NSMenuItem *recursiveExpandPlaylistMenuItem;
 @property (readwrite, weak) IBOutlet NSMenuItem *recursiveCollapsePlaylistMenuItem;
 @property (readwrite, weak) IBOutlet NSMenuItem *addFilesToPlaylistMenuItem;
+ at property (readwrite, weak) IBOutlet NSMenuItem *shufflePlaylistMenuItem;
 
 @property (nonatomic, readwrite, weak) VLCPlaylistView *outlineView;
 @property (nonatomic, readwrite, weak) NSTableHeaderView *playlistHeaderView;
@@ -61,6 +62,7 @@
 - (IBAction)recursiveExpandOrCollapseNode:(id)sender;
 - (IBAction)showInfoPanel:(id)sender;
 - (IBAction)addFilesToPlaylist:(id)sender;
+- (IBAction)shufflePlaylist:(id)sender;
 
 - (NSArray *)draggedItems;
 


=====================================
modules/gui/macosx/VLCPlaylist.m
=====================================
@@ -228,6 +228,7 @@
     [_infoPlaylistMenuItem setTitle: _NS("Media Information...")];
     [_revealInFinderPlaylistMenuItem setTitle: _NS("Reveal in Finder")];
     [_addFilesToPlaylistMenuItem setTitle: _NS("Add File...")];
+    [_shufflePlaylistMenuItem setTitle: _NS("Shuffle playlist")];
 }
 
 - (void)playlistUpdated
@@ -451,6 +452,10 @@
         return [_outlineView numberOfSelectedRows] > 0;
     } else if ([item action] == @selector(showInfoPanel:)) {
         return [_outlineView numberOfSelectedRows] > 0;
+    } else if ([item action] == @selector(shufflePlaylist:)) {
+        return ([_outlineView numberOfRows] > 0 &&
+                [[self model] currentRootType] != ROOT_TYPE_MEDIALIBRARY &&
+                _model.editAllowed);
     }
 
     return YES;
@@ -681,6 +686,14 @@
     }
 }
 
+- (IBAction)shufflePlaylist:(id)sender
+{
+    if ([[self model] currentRootType] == ROOT_TYPE_MEDIALIBRARY)
+        return;
+
+    [[self model] sortPlaylistBy:SORT_RANDOM withOrder:ORDER_NORMAL];
+}
+
 - (NSMenu *)menuForEvent:(NSEvent *)o_event
 {
     if (!b_playlistmenu_nib_loaded)



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9226bae4920ae575f5249fab95c7e5abfeee4031...f5dfb2f8c7269534cb41113e504fe5564ce29d99

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9226bae4920ae575f5249fab95c7e5abfeee4031...f5dfb2f8c7269534cb41113e504fe5564ce29d99
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list