Add a contextual menu item to check only the tracks with the same languages as the selected tracks.
This commit is contained in:
1 parent
127237a60a
commit
0a179287c0
2 files changed
+57
-7
No files matched your search
@@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="16A238m" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11198.2" systemVersion="16A304a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<deployment identifier="macosx"/>
|
<deployment identifier="macosx"/>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11198.2"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<objects>
|
<objects>
|
||||||
<customObject id="-2" userLabel="File's Owner" customClass="SBFileImport">
|
<customObject id="-2" userLabel="File's Owner" customClass="SBFileImport">
|
||||||
@@ -221,6 +221,13 @@ Gw
|
|||||||
<action selector="checkSelected:" target="-2" id="eqx-lP-ybu"/>
|
<action selector="checkSelected:" target="-2" id="eqx-lP-ybu"/>
|
||||||
</connections>
|
</connections>
|
||||||
</menuItem>
|
</menuItem>
|
||||||
|
<menuItem isSeparatorItem="YES" id="JaS-f9-O6W"/>
|
||||||
|
<menuItem title="Check only tracks with the same language" id="D3Y-pV-hxZ">
|
||||||
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="checkOnlyTracksWithSameLanguage:" target="-2" id="3Gg-ed-oeo"/>
|
||||||
|
</connections>
|
||||||
|
</menuItem>
|
||||||
</items>
|
</items>
|
||||||
</menu>
|
</menu>
|
||||||
</objects>
|
</objects>
|
||||||
|
|||||||
+48
-5
@@ -373,7 +373,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)toggleSelectionCheck:(BOOL)value
|
- (BOOL)canBeChecked:(id)rowItem
|
||||||
|
{
|
||||||
|
MP42Track *track = rowItem;
|
||||||
|
if ([track isKindOfClass:[MP42Track class]] &&
|
||||||
|
(isTrackMuxable(track.format) || trackNeedConversion(track.format))) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSIndexSet *)targetRows
|
||||||
{
|
{
|
||||||
NSIndexSet *selection = tracksTableView.selectedRowIndexes;
|
NSIndexSet *selection = tracksTableView.selectedRowIndexes;
|
||||||
NSInteger clickedRow = tracksTableView.clickedRow;
|
NSInteger clickedRow = tracksTableView.clickedRow;
|
||||||
@@ -382,10 +392,15 @@
|
|||||||
selection = [NSIndexSet indexSetWithIndex:clickedRow];
|
selection = [NSIndexSet indexSetWithIndex:clickedRow];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return selection;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)toggleSelectionCheck:(BOOL)value
|
||||||
|
{
|
||||||
|
NSIndexSet *selection = [self targetRows];
|
||||||
|
|
||||||
[selection enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
|
[selection enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
|
||||||
MP42Track *track = self->_tracks[idx];
|
if ([self canBeChecked:self->_tracks[idx]]) {
|
||||||
if ([track isKindOfClass:[MP42Track class]] &&
|
|
||||||
(isTrackMuxable(track.format) || trackNeedConversion(track.format))) {
|
|
||||||
self->_importCheckArray[idx] = @(value);
|
self->_importCheckArray[idx] = @(value);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
@@ -403,11 +418,39 @@
|
|||||||
[self toggleSelectionCheck:NO];
|
[self toggleSelectionCheck:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (IBAction)checkOnlyTracksWithSameLanguage:(id)sender
|
||||||
|
{
|
||||||
|
NSIndexSet *selection = [self targetRows];
|
||||||
|
NSMutableSet *languages = [NSMutableSet set];
|
||||||
|
|
||||||
|
[selection enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
|
||||||
|
if ([self canBeChecked:self->_tracks[idx]]) {
|
||||||
|
MP42Track *track = self->_tracks[idx];
|
||||||
|
[languages addObject:track.language];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
NSUInteger idx = 0;
|
||||||
|
for (MP42Track *track in _tracks) {
|
||||||
|
if ([self canBeChecked:track] && [languages containsObject:track.language]) {
|
||||||
|
self->_importCheckArray[idx] = @YES;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self->_importCheckArray[idx] = @NO;
|
||||||
|
}
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
[tracksTableView reloadData];
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)validateUserInterfaceItem:(id < NSValidatedUserInterfaceItem >)anItem
|
- (BOOL)validateUserInterfaceItem:(id < NSValidatedUserInterfaceItem >)anItem
|
||||||
{
|
{
|
||||||
SEL action = anItem.action;
|
SEL action = anItem.action;
|
||||||
|
|
||||||
if (action == @selector(uncheckSelected:) || action == @selector(checkSelected:))
|
if (action == @selector(uncheckSelected:) ||
|
||||||
|
action == @selector(checkSelected:) ||
|
||||||
|
action == @selector(checkOnlyTracksWithSameLanguage:))
|
||||||
if (tracksTableView.selectedRow != -1 || tracksTableView.clickedRow != -1)
|
if (tracksTableView.selectedRow != -1 || tracksTableView.clickedRow != -1)
|
||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user