[vlc-commits] [Git][videolan/vlc][master] 4 commits: macosx: Handle case when right-clicked collection view item is not selected

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sun Jun 9 16:25:21 UTC 2024



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
6e000aec by Claudio Cambra at 2024-06-09T16:11:39+00:00
macosx: Handle case when right-clicked collection view item is not selected

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

- - - - -
16f59826 by Claudio Cambra at 2024-06-09T16:11:39+00:00
macosx: Ensure we correctly check if a collection view's item is selected

NSArray's indexOf: will just check if it is the same object in the NSArray.
Instead check for a matching libraryId.

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

- - - - -
47b1b312 by Claudio Cambra at 2024-06-09T16:11:39+00:00
macosx: Match right-click unselected collection view item behaviour with Finder

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

- - - - -
1f7ffcef by Claudio Cambra at 2024-06-09T16:11:39+00:00
macosx: Fix handling of clicked row vs selected row for library table view context menu

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

- - - - -


2 changed files:

- modules/gui/macosx/library/VLCLibraryCollectionViewItem.m
- modules/gui/macosx/library/VLCLibraryTableView.m


Changes:

=====================================
modules/gui/macosx/library/VLCLibraryCollectionViewItem.m
=====================================
@@ -296,8 +296,21 @@ const CGFloat VLCLibraryCollectionViewItemMaximumDisplayedProgress = 0.95;
         NSObject<VLCLibraryCollectionViewDataSource> * const dataSource = 
             (NSObject<VLCLibraryCollectionViewDataSource> *)collectionView.dataSource;
         NSSet<NSIndexPath *> * const indexPaths = collectionView.selectionIndexPaths;
-        NSArray<VLCLibraryRepresentedItem *> * const items = 
+        NSArray<VLCLibraryRepresentedItem *> * const selectedItems =
             [dataSource representedItemsAtIndexPaths:indexPaths forCollectionView:collectionView];
+        const NSInteger representedItemIndex = [selectedItems indexOfObjectPassingTest:^BOOL(
+            VLCLibraryRepresentedItem * const repItem, const NSUInteger idx, BOOL * const stop
+        ) {
+            return repItem.item.libraryID == self.representedItem.item.libraryID;
+        }];
+        NSArray<VLCLibraryRepresentedItem *> *items = nil;
+
+        if (representedItemIndex == NSNotFound) {
+            items = @[self.representedItem];
+        } else {
+            items = selectedItems;
+        }
+
         _menuController.representedItems = items;
     } else {
         _menuController.representedItems = @[self.representedItem];


=====================================
modules/gui/macosx/library/VLCLibraryTableView.m
=====================================
@@ -80,15 +80,28 @@
         const id<VLCLibraryTableViewDataSource> vlcLibraryDataSource = 
             (id<VLCLibraryTableViewDataSource>)self.dataSource;
 
-        [indices enumerateIndexesUsingBlock:^(const NSUInteger index, BOOL * const stop) {
+        if ([indices containsIndex:self.clickedRow]) {
+            [indices enumerateIndexesUsingBlock:^(const NSUInteger index, BOOL * const stop) {
+                const id<VLCMediaLibraryItemProtocol> mediaItem =
+                    [vlcLibraryDataSource libraryItemAtRow:index forTableView:self];
+                const VLCMediaLibraryParentGroupType parentType =
+                    vlcLibraryDataSource.currentParentType;
+                VLCLibraryRepresentedItem * const representedItem =
+                    [[VLCLibraryRepresentedItem alloc] initWithItem:mediaItem
+                                                         parentType:parentType];
+                [representedItems addObject:representedItem];
+            }];
+        } else {
             const id<VLCMediaLibraryItemProtocol> mediaItem = 
-                [vlcLibraryDataSource libraryItemAtRow:index forTableView:self];
+                [vlcLibraryDataSource libraryItemAtRow:self.clickedRow forTableView:self];
             const VLCMediaLibraryParentGroupType parentType = 
                 vlcLibraryDataSource.currentParentType;
             VLCLibraryRepresentedItem * const representedItem = 
-                [[VLCLibraryRepresentedItem alloc] initWithItem:mediaItem parentType:parentType];
+                [[VLCLibraryRepresentedItem alloc] initWithItem:mediaItem
+                                                     parentType:parentType];
             [representedItems addObject:representedItem];
-        }];
+        }
+
         _menuController.representedItems = representedItems;
 
     } else if (self.dataSource.class == VLCMediaSourceDataSource.class) {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/4156b1105c98d33b79c7d1155945d29f3bd95aee...1f7ffcef4d37c55eeaa0011bedc9a16ec5f0cddf

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