From 05f17ea950fcbead7fcc21b3a8774f09feb9f1b2 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Mon, 30 May 2022 22:23:02 -0700 Subject: [PATCH] [Menu] Add Stop after Selection to context menu Since the existing code already supports setting any arbitrary track as a stopping point, add a menu interface to toggle Stop After for any track in the playlist. Stop After will be removed from the given track after it has been played. Stop After will not be remembered on disk. Signed-off-by: Christopher Snowhill --- Base.lproj/MainMenu.xib | 6 ++++++ Playlist/PlaylistController.m | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Base.lproj/MainMenu.xib b/Base.lproj/MainMenu.xib index 535b9b29c..01e6cebdf 100644 --- a/Base.lproj/MainMenu.xib +++ b/Base.lproj/MainMenu.xib @@ -2136,6 +2136,12 @@ Gw + + + + + + diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index 581fd36c8..37d15d86e 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -1455,6 +1455,19 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc [self.tableView reloadDataForRowIndexes:refreshSet columnIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, columns)]]; } +- (IBAction)stopAfterSelection:(id)sender { + NSMutableIndexSet *refreshSet = [[NSMutableIndexSet alloc] init]; + + for(PlaylistEntry *pe in [self selectedObjects]) { + pe.stopAfter = !pe.stopAfter; + [refreshSet addIndex:pe.index]; + } + + // Refresh entire row of all affected items to update tooltips + unsigned long columns = [[self.tableView tableColumns] count]; + [self.tableView reloadDataForRowIndexes:refreshSet columnIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, columns)]]; +} + - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { SEL action = [menuItem action];