Add a check all and uncheck all menu items to the file importer
This commit is contained in:
2 files changed
+38
-9
No files matched your search
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="23504" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22690"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23504"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -36,8 +36,21 @@
|
||||
<action selector="checkOnlyTracksWithSameLanguage:" target="-2" id="3Gg-ed-oeo"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="XqU-K4-wr2"/>
|
||||
<menuItem title="Uncheck all" id="CSo-l5-OQn">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="uncheckAll:" target="-2" id="1ij-4B-ZXg"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Check all" id="ivD-V3-8h5">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="checkAll:" target="-2" id="3F4-ah-wZn"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
<point key="canvasLocation" x="139" y="146"/>
|
||||
<point key="canvasLocation" x="-421" y="140"/>
|
||||
</menu>
|
||||
<view id="XhE-7o-ek3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="683" height="283"/>
|
||||
@@ -267,7 +280,7 @@
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<popUpButtonCell key="cell" type="bevel" bezelStyle="rounded" alignment="left" controlSize="small" lineBreakMode="truncatingTail" imageScaling="proportionallyDown" inset="2" id="FNV-pf-MUt">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="menu"/>
|
||||
<font key="font" metaFont="message"/>
|
||||
<menu key="menu" id="i8l-4s-h93"/>
|
||||
</popUpButtonCell>
|
||||
<connections>
|
||||
|
||||
@@ -257,14 +257,22 @@ final class FileImportController: ViewController, NSTableViewDataSource, NSTable
|
||||
}
|
||||
|
||||
func validateUserInterfaceItem(_ item: NSValidatedUserInterfaceItem) -> Bool {
|
||||
if let action = item.action,
|
||||
action == #selector(self.checkSelected(_:)) ||
|
||||
action == #selector(self.uncheckSelected(_:)) ||
|
||||
action == #selector(self.checkOnlyTracksWithSameLanguage(_:)) {
|
||||
guard let action = item.action else { return false }
|
||||
|
||||
switch action {
|
||||
case #selector(self.checkSelected(_:)): fallthrough
|
||||
case #selector(self.uncheckSelected(_:)): fallthrough
|
||||
case #selector(self.checkOnlyTracksWithSameLanguage(_:)):
|
||||
if tracksTableView.selectedRow != -1 || tracksTableView.clickedRow != -1 {
|
||||
return true
|
||||
}
|
||||
case #selector(self.checkAll(_:)): fallthrough
|
||||
case #selector(self.uncheckAll(_:)):
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -275,7 +283,15 @@ final class FileImportController: ViewController, NSTableViewDataSource, NSTable
|
||||
@IBAction func uncheckSelected(_ sender: Any) {
|
||||
setCheck(value: false, forIndexes: tracksTableView.targetedRowIndexes)
|
||||
}
|
||||
|
||||
|
||||
@IBAction func checkAll(_ sender: Any) {
|
||||
setCheck(value: true, forIndexes: IndexSet(integersIn: 0..<items.count))
|
||||
}
|
||||
|
||||
@IBAction func uncheckAll(_ sender: Any) {
|
||||
setCheck(value: false, forIndexes: IndexSet(integersIn: 0..<items.count))
|
||||
}
|
||||
|
||||
@IBAction func checkOnlyTracksWithSameLanguage(_ sender: Any) {
|
||||
let languages = tracksTableView.targetedRowIndexes.compactMap { (index: Int) -> String? in
|
||||
let item = items[index]
|
||||
|
||||
Reference in new issue
Block a user