Added Check-Only-Selected Item

** How was it Changed? **
- importing media to a video, a dialog appears with the tracks to be imported. All tracks are enabled
- there is already a context-menu-item to only check the selected language
- i added another item to the context menu to only check the selected tracks
- the logic is simple:
   - if nothing is selected, the target item is the only checked item
   - if there's selection, these items will then be checked
   - target-item has precedence from selected items because it's more precise but can also be fixed by reopening the menu by targeting the selection

** Why was it changed? **
- i often encounter videos that have all required languages and after conversion but they lack the forced subtitle track
- dragging the source media on the video will open a dialog and tons of subtitle tracks are all selected
- even choosing the "check selected language" item would still select multiple tracks, most of which would need to be deselected in a second step
This commit is contained in:
Karsten authored and Damiano Galassi committed 2025-03-11 11:01:57 +01:00
1 parent b26bcea29a
commit 5fdf9efa80
2 files changed
+25 -1

No files matched your search

+19 -1
View File
@@ -262,7 +262,8 @@ final class FileImportController: ViewController, NSTableViewDataSource, NSTable
if let action = item.action,
action == #selector(self.checkSelected(_:)) ||
action == #selector(self.uncheckSelected(_:)) ||
action == #selector(self.checkOnlyTracksWithSameLanguage(_:)) {
action == #selector(self.checkOnlyTracksWithSameLanguage(_:)) ||
action == #selector(self.checkOnlySelectedTracks(_:)) {
if tracksTableView.selectedRow != -1 || tracksTableView.clickedRow != -1 {
return true
}
@@ -292,6 +293,23 @@ final class FileImportController: ViewController, NSTableViewDataSource, NSTable
settings.forEach { $0.checked = $0.importable && languages.contains($0.track.language) }
reloadCheckColumn(forRowIndexes: IndexSet(integersIn: items.indices))
}
@IBAction func checkOnlySelectedTracks(_ sender: Any) {
let targetedIndices = tracksTableView.targetedRowIndexes;
var selectedIndices = tracksTableView.selectedRowIndexes;
if (!selectedIndices.contains(targetedIndices.first!))
{
// This is a shortcut for quickly selecting specific rows.
// If the rows are selected and right-clicked, the target is within the selection.
// If the user didn't both first selecting rows, use the target index (visible with a selection-border in the UI).
// If the user did select but targets another row, use the target row
// because if it was intentional, only the targeted row is selected
// and if it was not intentional, it's easy to fix and open the menu on top of an actual selected row.
selectedIndices = targetedIndices;
}
settings.enumerated().forEach { (index, item) in item.checked = selectedIndices.contains(index + 1) }
reloadCheckColumn(forRowIndexes: IndexSet(integersIn: items.indices))
}
// MARK: IBActions