Skip to content
Permalink
Browse files

Add search bar to filter keybindings

TODO: localization
  • Loading branch information...
alejx committed Feb 28, 2019
1 parent a2e9c6d commit bad40af0c690e6a53921e35725a526874e1c2a16
Showing with 41 additions and 16 deletions.
  1. +32 −13 iina/Base.lproj/PrefKeyBindingViewController.xib
  2. +3 −3 iina/KeyMapping.swift
  3. +6 −0 iina/PrefKeyBindingViewController.swift
@@ -14,6 +14,7 @@
<outlet property="deleteConfFileBtn" destination="EpF-t6-PtC" id="3NC-Xb-5kT"/>
<outlet property="duplicateConfigBtn" destination="5WK-s3-J9x" id="Ri8-b5-d3s"/>
<outlet property="kbTableView" destination="1Z4-NL-6P3" id="OyE-OE-MSd"/>
<outlet property="keyMappingSearchField" destination="x6N-6q-HiV" id="mRh-rd-I8d"/>
<outlet property="mappingController" destination="xGz-Vh-hMb" id="hDG-Z5-OmL"/>
<outlet property="newConfigBtn" destination="iCp-ho-SlQ" id="LI0-TX-tNs"/>
<outlet property="removeKmBtn" destination="uFG-OF-DJ5" id="XWN-Lt-tmc"/>
@@ -25,10 +26,10 @@
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="Hz6-mo-xeY">
<rect key="frame" x="0.0" y="0.0" width="695" height="505"/>
<rect key="frame" x="0.0" y="0.0" width="695" height="531"/>
<subviews>
<button translatesAutoresizingMaskIntoConstraints="NO" id="LU9-QU-BFL">
<rect key="frame" x="6" y="481" width="117" height="18"/>
<rect key="frame" x="6" y="507" width="117" height="18"/>
<constraints>
<constraint firstAttribute="height" constant="14" id="lOm-I3-MpB"/>
</constraints>
@@ -41,7 +42,7 @@
</connections>
</button>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="ER0-iU-7fy">
<rect key="frame" x="8" y="444" width="679" height="5"/>
<rect key="frame" x="8" y="470" width="679" height="5"/>
</box>
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2pX-29-I87">
<rect key="frame" x="196" y="63" width="491" height="320"/>
@@ -113,7 +114,7 @@
</tableHeaderView>
</scrollView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ZWR-gT-S2p">
<rect key="frame" x="8" y="413" width="91" height="17"/>
<rect key="frame" x="8" y="439" width="91" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Configuration:" id="au5-6f-s55">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -188,7 +189,7 @@
<color key="fillColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</box>
<button translatesAutoresizingMaskIntoConstraints="NO" id="LAx-AE-9wU">
<rect key="frame" x="6" y="461" width="203" height="18"/>
<rect key="frame" x="6" y="487" width="203" height="18"/>
<buttonCell key="cell" type="check" title="Enable Apple Remote support" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="e70-25-5E4">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@@ -198,7 +199,7 @@
</connections>
</button>
<button horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="bm5-rb-Qjb">
<rect key="frame" x="664" y="476" width="25" height="25"/>
<rect key="frame" x="664" y="502" width="25" height="25"/>
<buttonCell key="cell" type="help" bezelStyle="helpButton" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="vf9-A9-dKA">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@@ -208,13 +209,13 @@
</connections>
</button>
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Mhk-DT-3CM">
<rect key="frame" x="8" y="63" width="180" height="320"/>
<rect key="frame" x="8" y="63" width="180" height="350"/>
<clipView key="contentView" id="4gB-i6-I71">
<rect key="frame" x="1" y="1" width="178" height="318"/>
<rect key="frame" x="1" y="1" width="178" height="348"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnReordering="NO" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" floatsGroupRows="NO" id="AYj-6d-niF">
<rect key="frame" x="0.0" y="0.0" width="178" height="318"/>
<rect key="frame" x="0.0" y="0.0" width="178" height="348"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -348,15 +349,15 @@
<color key="fillColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</box>
<textField identifier="SectionTitleSettings" hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="OY4-8W-63j">
<rect key="frame" x="642" y="488" width="55" height="17"/>
<rect key="frame" x="642" y="514" width="55" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Settings" id="veZ-Si-Hv5">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="tP6-Ua-acA">
<rect key="frame" x="8" y="391" width="679" height="18"/>
<rect key="frame" x="8" y="421" width="679" height="14"/>
<textFieldCell key="cell" controlSize="small" title="Label" id="M4N-eg-JA8">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
@@ -373,6 +374,22 @@
<action selector="importConfigBtnAction:" target="-2" id="m3a-yn-NIE"/>
</connections>
</button>
<searchField wantsLayer="YES" verticalHuggingPriority="750" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="x6N-6q-HiV">
<rect key="frame" x="197" y="391" width="489" height="22"/>
<searchFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" borderStyle="bezel" usesSingleLineMode="YES" bezelStyle="round" id="onw-J2-ic8">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</searchFieldCell>
<connections>
<binding destination="xGz-Vh-hMb" name="predicate" keyPath="filterPredicate" id="uHo-xu-Tfc">
<dictionary key="options">
<string key="NSDisplayName">Search</string>
<string key="NSPredicateFormat">(readableAction contains $value) OR (prettyCommand contains $value)</string>
</dictionary>
</binding>
</connections>
</searchField>
</subviews>
<constraints>
<constraint firstItem="KZA-hu-vhZ" firstAttribute="top" secondItem="0le-1T-r5f" secondAttribute="bottom" constant="14" id="2Pk-ll-iUo"/>
@@ -382,20 +399,22 @@
<constraint firstAttribute="trailing" secondItem="tP6-Ua-acA" secondAttribute="trailing" constant="10" id="AGg-nV-dJe"/>
<constraint firstItem="bm5-rb-Qjb" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="LU9-QU-BFL" secondAttribute="trailing" constant="8" id="ASF-wJ-2pT"/>
<constraint firstItem="Le4-ai-PiB" firstAttribute="top" secondItem="Mhk-DT-3CM" secondAttribute="bottom" constant="-1" id="BKz-av-lUx"/>
<constraint firstItem="x6N-6q-HiV" firstAttribute="trailing" secondItem="1Z4-NL-6P3" secondAttribute="trailing" id="BNb-HG-BLr"/>
<constraint firstItem="x6N-6q-HiV" firstAttribute="top" secondItem="tP6-Ua-acA" secondAttribute="bottom" constant="8" id="Cf7-8P-UBX"/>
<constraint firstItem="Le4-ai-PiB" firstAttribute="trailing" secondItem="Mhk-DT-3CM" secondAttribute="trailing" id="DeO-7U-TYb"/>
<constraint firstItem="AuR-Lj-Iz4" firstAttribute="firstBaseline" secondItem="KZA-hu-vhZ" secondAttribute="firstBaseline" id="Hrm-F3-qj5"/>
<constraint firstItem="AuR-Lj-Iz4" firstAttribute="leading" secondItem="KZA-hu-vhZ" secondAttribute="trailing" constant="12" id="LWW-j6-UPY"/>
<constraint firstItem="mLe-eI-lIk" firstAttribute="top" secondItem="2pX-29-I87" secondAttribute="bottom" constant="-1" id="LeQ-qP-FVe"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="AuR-Lj-Iz4" secondAttribute="trailing" constant="8" id="M6E-Ra-d8q"/>
<constraint firstItem="Mhk-DT-3CM" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="8" id="OLU-oB-Se7"/>
<constraint firstItem="2pX-29-I87" firstAttribute="top" secondItem="Mhk-DT-3CM" secondAttribute="top" id="Pc1-MC-ctF"/>
<constraint firstAttribute="bottom" secondItem="KZA-hu-vhZ" secondAttribute="bottom" constant="8" id="QtF-OP-vXc"/>
<constraint firstItem="ER0-iU-7fy" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="8" id="Rc3-GT-Hhr"/>
<constraint firstAttribute="trailing" secondItem="mLe-eI-lIk" secondAttribute="trailing" constant="8" id="U9K-pE-0CL"/>
<constraint firstItem="Mhk-DT-3CM" firstAttribute="top" secondItem="tP6-Ua-acA" secondAttribute="bottom" constant="8" id="Ud4-VR-43k"/>
<constraint firstItem="2pX-29-I87" firstAttribute="leading" secondItem="Mhk-DT-3CM" secondAttribute="trailing" constant="8" id="VX8-3k-wdZ"/>
<constraint firstAttribute="trailing" secondItem="ER0-iU-7fy" secondAttribute="trailing" constant="8" id="Y4g-9e-aDt"/>
<constraint firstItem="ZWR-gT-S2p" firstAttribute="top" secondItem="ER0-iU-7fy" secondAttribute="bottom" constant="16" id="ZX7-1F-af0"/>
<constraint firstItem="2pX-29-I87" firstAttribute="top" secondItem="x6N-6q-HiV" secondAttribute="bottom" constant="8" id="aGz-Kt-wfl"/>
<constraint firstItem="Mhk-DT-3CM" firstAttribute="bottom" secondItem="2pX-29-I87" secondAttribute="bottom" id="bIy-L9-gJ1"/>
<constraint firstItem="Le4-ai-PiB" firstAttribute="leading" secondItem="Mhk-DT-3CM" secondAttribute="leading" id="bgz-zS-geZ"/>
<constraint firstItem="bm5-rb-Qjb" firstAttribute="centerY" secondItem="LU9-QU-BFL" secondAttribute="centerY" id="dVn-Pj-vDl"/>
@@ -405,7 +424,7 @@
<constraint firstAttribute="trailing" secondItem="OY4-8W-63j" secondAttribute="trailing" id="fZe-ej-w66"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="LAx-AE-9wU" secondAttribute="trailing" constant="20" symbolic="YES" id="jNW-B9-uvv"/>
<constraint firstItem="tP6-Ua-acA" firstAttribute="top" secondItem="ZWR-gT-S2p" secondAttribute="bottom" constant="4" id="krb-us-D9G"/>
<constraint firstItem="Mhk-DT-3CM" firstAttribute="top" secondItem="ZWR-gT-S2p" secondAttribute="bottom" constant="30" id="mYB-35-8YR"/>
<constraint firstItem="x6N-6q-HiV" firstAttribute="leading" secondItem="1Z4-NL-6P3" secondAttribute="leading" id="oGi-TP-9ub"/>
<constraint firstItem="tP6-Ua-acA" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="10" id="olF-Fw-cWs"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="ZWR-gT-S2p" secondAttribute="trailing" constant="8" id="tWl-b9-AcQ"/>
<constraint firstAttribute="trailing" secondItem="2pX-29-I87" secondAttribute="trailing" constant="8" id="tl2-El-aGp"/>
@@ -29,7 +29,7 @@ class KeyMapping: NSObject {

@objc var actionForDisplay: String {
get {
return UserDefaults.standard.bool(forKey: "displayRawValue") ? prettyCommand : readableAction
return UserDefaults.standard.bool(forKey: "displayRawValue") ? readableAction : prettyCommand
}
set {
rawAction = newValue
@@ -64,7 +64,7 @@ class KeyMapping: NSObject {

var comment: String?

var readableAction: String {
@objc var readableAction: String {
get {
let joined = action.joined(separator: " ")
return isIINACommand ? ("@iina " + joined) : joined
@@ -81,7 +81,7 @@ class KeyMapping: NSObject {
}
}

var prettyCommand: String {
@objc var prettyCommand: String {
return KeyBindingTranslator.readableCommand(fromAction: action, isIINACommand: isIINACommand)
}

@@ -54,6 +54,7 @@ class PrefKeyBindingViewController: NSViewController, PreferenceWindowEmbeddable
@IBOutlet weak var newConfigBtn: NSButton!
@IBOutlet weak var duplicateConfigBtn: NSButton!
@IBOutlet weak var useMediaKeysButton: NSButton!
@IBOutlet weak var keyMappingSearchField: NSSearchField!
@IBOutlet var mappingController: NSArrayController!

override func viewDidLoad() {
@@ -384,6 +385,8 @@ class PrefKeyBindingViewController: NSViewController, PreferenceWindowEmbeddable
extension PrefKeyBindingViewController: NSTableViewDelegate, NSTableViewDataSource {

// NSTableViewDataSource
func numberOfRows(in tableView: NSTableView) -> Int {
return userConfigNames.count
}
@@ -396,6 +399,8 @@ extension PrefKeyBindingViewController: NSTableViewDelegate, NSTableViewDataSour
]
}

// NSTableViewDelegate
func tableView(_ tableView: NSTableView, shouldEdit tableColumn: NSTableColumn?, row: Int) -> Bool {
if tableView == kbTableView {
return UserDefaults.standard.bool(forKey: "displayRawValue")
@@ -429,4 +434,5 @@ extension PrefKeyBindingViewController: NSTableViewDelegate, NSTableViewDataSour
}
removeKmBtn.isEnabled = shouldEnableEdit && kbTableView.selectedRow != -1
}

}

0 comments on commit bad40af

Please sign in to comment.
You can’t perform that action at this time.