Skip to content
Permalink
Browse files

Use Preference wrapper of UserDefaults

  • Loading branch information...
alejx committed Apr 5, 2019
1 parent 091d4e7 commit 00d18c2f658e52e78eeb0d8a0e7d9e1a1768fac7
Showing with 5 additions and 5 deletions.
  1. +2 −2 iina/KeyMapping.swift
  2. +3 −3 iina/PrefKeyBindingViewController.swift
@@ -19,7 +19,7 @@ class KeyMapping: NSObject {

@objc var keyForDisplay: String {
get {
return UserDefaults.standard.bool(forKey: "displayKeyBindingRawValues") ? key : prettyKey
return Preference.bool(for: .displayKeyBindingRawValues) ? key : prettyKey
}
set {
key = newValue
@@ -29,7 +29,7 @@ class KeyMapping: NSObject {

@objc var actionForDisplay: String {
get {
return UserDefaults.standard.bool(forKey: "displayKeyBindingRawValues") ? readableAction : prettyCommand
return Preference.bool(for: .displayKeyBindingRawValues) ? readableAction : prettyCommand
}
set {
rawAction = newValue
@@ -61,7 +61,7 @@ class PrefKeyBindingViewController: NSViewController, PreferenceWindowEmbeddable
super.viewDidLoad()

kbTableView.delegate = self
kbTableView.doubleAction = UserDefaults.standard.bool(forKey: "displayKeyBindingRawValues") ? nil : #selector(editRow)
kbTableView.doubleAction = Preference.bool(for: .displayKeyBindingRawValues) ? nil : #selector(editRow)
confTableView.dataSource = self
confTableView.delegate = self

@@ -302,7 +302,7 @@ class PrefKeyBindingViewController: NSViewController, PreferenceWindowEmbeddable
}

@IBAction func displayRawValueAction(_ sender: NSButton) {
kbTableView.doubleAction = UserDefaults.standard.bool(forKey: "displayKeyBindingRawValues") ? nil : #selector(editRow)
kbTableView.doubleAction = Preference.bool(for: .displayKeyBindingRawValues) ? nil : #selector(editRow)
kbTableView.reloadData()
}

@@ -403,7 +403,7 @@ extension PrefKeyBindingViewController: NSTableViewDelegate, NSTableViewDataSour
func tableView(_ tableView: NSTableView, shouldEdit tableColumn: NSTableColumn?, row: Int) -> Bool {
if tableView == kbTableView {
return UserDefaults.standard.bool(forKey: "displayKeyBindingRawValues")
return Preference.bool(for: .displayKeyBindingRawValues)
} else {
return false
}

0 comments on commit 00d18c2

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