Skip to content

Commit

Permalink
Merge pull request #654 from valeriyvan/inference
Browse files Browse the repository at this point in the history
Removes excessive type info
  • Loading branch information
glouel authored Nov 15, 2018
2 parents 1083bf0 + 75f0187 commit f1952b5
Showing 1 changed file with 51 additions and 61 deletions.
112 changes: 51 additions & 61 deletions Aerial/Source/Controllers/PreferencesWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo

// Grab preferred language as proper string
let printOutputLocale: NSLocale = NSLocale(localeIdentifier: Locale.preferredLanguages[0])
if let deviceLanguageName: String = printOutputLocale.displayName(forKey: NSLocale.Key.identifier, value: Locale.preferredLanguages[0]) {
if let deviceLanguageName: String = printOutputLocale.displayName(forKey: .identifier, value: Locale.preferredLanguages[0]) {
currentLocaleLabel.stringValue = "Preferred language: \(deviceLanguageName)"
} else {
currentLocaleLabel.stringValue = ""
Expand All @@ -318,13 +318,13 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
playerView.player = player
playerView.controlsStyle = .none
if #available(OSX 10.10, *) {
playerView.videoGravity = AVLayerVideoGravity.resizeAspectFill
playerView.videoGravity = .resizeAspectFill
}

// To loop playback, we catch the end of the video to rewind
NotificationCenter.default.addObserver(self,
selector: #selector(playerItemDidReachEnd(notification:)),
name: Notification.Name.AVPlayerItemDidPlayToEndTime,
selector: #selector(playerItemDidReachEnd),
name: .AVPlayerItemDidPlayToEndTime,
object: player.currentItem)

if #available(OSX 10.12, *) {
Expand Down Expand Up @@ -470,29 +470,29 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
// Handle the time radios
switch preferences.timeMode {
case Preferences.TimeMode.nightShift.rawValue:
timeNightShiftRadio.state = NSControl.StateValue.on
timeNightShiftRadio.state = .on
case Preferences.TimeMode.manual.rawValue:
timeManualRadio.state = NSControl.StateValue.on
timeManualRadio.state = .on
case Preferences.TimeMode.lightDarkMode.rawValue:
timeLightDarkModeRadio.state = NSControl.StateValue.on
timeLightDarkModeRadio.state = .on
case Preferences.TimeMode.coordinates.rawValue:
timeCalculateRadio.state = .on
default:
timeDisabledRadio.state = NSControl.StateValue.on
timeDisabledRadio.state = .on
}

// Handle the corner radios
switch preferences.descriptionCorner {
case Preferences.DescriptionCorner.topLeft.rawValue:
cornerTopLeft.state = NSControl.StateValue.on
cornerTopLeft.state = .on
case Preferences.DescriptionCorner.topRight.rawValue:
cornerTopRight.state = NSControl.StateValue.on
cornerTopRight.state = .on
case Preferences.DescriptionCorner.bottomLeft.rawValue:
cornerBottomLeft.state = NSControl.StateValue.on
cornerBottomLeft.state = .on
case Preferences.DescriptionCorner.bottomRight.rawValue:
cornerBottomRight.state = NSControl.StateValue.on
cornerBottomRight.state = .on
default:
cornerRandom.state = NSControl.StateValue.on
cornerRandom.state = .on
}

solarModePopup.selectItem(at: preferences.solarMode!)
Expand Down Expand Up @@ -582,38 +582,32 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
let color = NSColor(calibratedRed: 0.18, green: 0.39, blue: 0.76, alpha: 1)
var coloredLink = NSMutableAttributedString(attributedString: projectPageLink.attributedTitle)
var fullRange = NSRange(location: 0, length: coloredLink.length)
coloredLink.addAttribute(NSAttributedString.Key.foregroundColor,
value: color,
range: fullRange)
coloredLink.addAttribute(.foregroundColor, value: color, range: fullRange)
projectPageLink.attributedTitle = coloredLink

// We have an extra project link on the video format popover, color it too
coloredLink = NSMutableAttributedString(attributedString: secondProjectPageLink.attributedTitle)
fullRange = NSRange(location: 0, length: coloredLink.length)
coloredLink.addAttribute(NSAttributedString.Key.foregroundColor,
value: color,
range: fullRange)
coloredLink.addAttribute(.foregroundColor, value: color, range: fullRange)
secondProjectPageLink.attributedTitle = coloredLink

// We have an extra project link on the video format popover, color it too
coloredLink = NSMutableAttributedString(attributedString: linkTimeWikipediaButton.attributedTitle)
fullRange = NSRange(location: 0, length: coloredLink.length)
coloredLink.addAttribute(NSAttributedString.Key.foregroundColor,
value: color,
range: fullRange)
coloredLink.addAttribute(.foregroundColor, value: color, range: fullRange)
linkTimeWikipediaButton.attributedTitle = coloredLink
}

// MARK: - Video panel
@IBAction func overrideOnBatteryClick(_ sender: NSButton) {
let onState = (sender.state == NSControl.StateValue.on)
let onState = sender.state == .on
preferences.overrideOnBattery = onState
changeBatteryOverrideState(to: onState)
debugLog("UI overrideOnBattery \(onState)")
}

@IBAction func powerSavingOnLowClick(_ sender: NSButton) {
let onState = (sender.state == NSControl.StateValue.on)
let onState = sender.state == .on
preferences.powerSavingOnLowBattery = onState
debugLog("UI powerSavingOnLow \(onState)")
}
Expand Down Expand Up @@ -767,7 +761,7 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo

@IBAction func showDescriptionsClick(button: NSButton?) {
let state = showDescriptionsCheckbox.state
let onState = (state == NSControl.StateValue.on)
let onState = state == .on
preferences.showDescriptions = onState
debugLog("UI showDescriptions: \(onState)")

Expand Down Expand Up @@ -814,14 +808,14 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo

@IBAction func useCommunityClick(_ button: NSButton) {
let state = useCommunityCheckbox.state
let onState = (state == NSControl.StateValue.on)
let onState = state == .on
preferences.useCommunityDescriptions = onState
debugLog("UI useCommunity: \(onState)")
}

@IBAction func localizeForTvOS12Click(button: NSButton?) {
let state = localizeForTvOS12Checkbox.state
let onState = (state == NSControl.StateValue.on)
let onState = state == .on
preferences.localizeDescriptions = onState
debugLog("UI localizeDescriptions: \(onState)")
}
Expand Down Expand Up @@ -907,20 +901,20 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
}

@IBAction func showClockClick(_ sender: NSButton) {
let onState = (sender.state == NSControl.StateValue.on)
let onState = sender.state == .on
preferences.showClock = onState
withSecondsCheckbox.isEnabled = onState
debugLog("UI showClock: \(onState)")
}

@IBAction func withSecondsClick(_ sender: NSButton) {
let onState = (sender.state == NSControl.StateValue.on)
let onState = sender.state == .on
preferences.withSeconds = onState
debugLog("UI withSeconds: \(onState)")
}

@IBAction func showExtraMessageClick(_ sender: NSButton) {
let onState = (sender.state == NSControl.StateValue.on)
let onState = sender.state == .on
// We also need to enable/disable our message field
extraMessageTextField.isEnabled = onState
editExtraMessageButton.isEnabled = onState
Expand All @@ -939,7 +933,7 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
}

@IBAction func changeMarginsToCornerClick(_ sender: NSButton) {
let onState = (sender.state == NSControl.StateValue.on)
let onState = sender.state == .on
debugLog("UI changeMarginsToCorner: \(onState)")

marginHorizontalTextfield.isEnabled = onState
Expand Down Expand Up @@ -989,19 +983,19 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
}

@IBAction func cacheAerialsAsTheyPlayClick(_ button: NSButton!) {
let onState = (button.state == NSControl.StateValue.on)
let onState = button.state == .on
preferences.cacheAerials = onState
debugLog("UI cacheAerialAsTheyPlay: \(onState)")
}

@IBAction func neverStreamVideosClick(_ button: NSButton!) {
let onState = (button.state == NSControl.StateValue.on)
let onState = button.state == .on
preferences.neverStreamVideos = onState
debugLog("UI neverStreamVideos: \(onState)")
}

@IBAction func neverStreamPreviewsClick(_ button: NSButton!) {
let onState = (button.state == NSControl.StateValue.on)
let onState = button.state == .on
preferences.neverStreamPreviews = onState
debugLog("UI neverStreamPreviews: \(onState)")
}
Expand Down Expand Up @@ -1053,7 +1047,7 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
// MARK: - Time panel

@IBAction func overrideNightOnDarkModeClick(_ button: NSButton) {
let onState = (button.state == NSControl.StateValue.on)
let onState = button.state == .on
preferences.darkModeNightOverride = onState
debugLog("UI overrideNightDarkMode: \(onState)")
}
Expand Down Expand Up @@ -1196,27 +1190,27 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
}

@IBAction func overrideFadeDurationClick(_ sender: NSButton) {
let onState = (sender.state == .on)
let onState = sender.state == .on
preferences.overrideDimInMinutes = onState
changeBrightnessState(to: preferences.dimBrightness)
debugLog("UI dimBrightness: \(onState)")
}

@IBAction func dimBrightnessClick(_ button: NSButton) {
let onState = (button.state == .on)
let onState = button.state == .on
preferences.dimBrightness = onState
changeBrightnessState(to: onState)
debugLog("UI dimBrightness: \(onState)")
}

@IBAction func dimOnlyAtNightClick(_ button: NSButton) {
let onState = (button.state == .on)
let onState = button.state == .on
preferences.dimOnlyAtNight = onState
debugLog("UI dimOnlyAtNight: \(onState)")
}

@IBAction func dimOnlyOnBattery(_ button: NSButton) {
let onState = (button.state == .on)
let onState = button.state == .on
preferences.dimOnlyOnBattery = onState
debugLog("UI dimOnlyOnBattery: \(onState)")
}
Expand Down Expand Up @@ -1312,21 +1306,21 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo

let pasteBoard = NSPasteboard.general
pasteBoard.clearContents()
pasteBoard.setString(clipboard, forType: NSPasteboard.PasteboardType.string)
pasteBoard.setString(clipboard, forType: .string)
}

@IBAction func logRefreshClick(_ sender: NSButton) {
logTableView.reloadData()
}

@IBAction func debugModeClick(_ button: NSButton) {
let onState = (button.state == NSControl.StateValue.on)
let onState = button.state == .on
preferences.debugMode = onState
debugLog("UI debugMode: \(onState)")
}

@IBAction func logToDiskClick(_ button: NSButton) {
let onState = (button.state == NSControl.StateValue.on)
let onState = button.state == .on
preferences.logToDisk = onState
debugLog("UI logToDisk: \(onState)")
}
Expand All @@ -1351,18 +1345,18 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
}

switch highestLevel! {
case ErrorLevel.debug:
case .debug:
showLogBottomClick.title = "Show Debug"
showLogBottomClick.image = NSImage.init(named: NSImage.actionTemplateName)
case ErrorLevel.info:
showLogBottomClick.image = NSImage(named: NSImage.actionTemplateName)
case .info:
showLogBottomClick.title = "Show Info"
showLogBottomClick.image = NSImage.init(named: NSImage.infoName)
case ErrorLevel.warning:
showLogBottomClick.image = NSImage(named: NSImage.infoName)
case .warning:
showLogBottomClick.title = "Show Warning"
showLogBottomClick.image = NSImage.init(named: NSImage.cautionName)
showLogBottomClick.image = NSImage(named: NSImage.cautionName)
default:
showLogBottomClick.title = "Show Error"
showLogBottomClick.image = NSImage.init(named: NSImage.stopProgressFreestandingTemplateName)
showLogBottomClick.image = NSImage(named: NSImage.stopProgressFreestandingTemplateName)
}

showLogBottomClick.isHidden = false
Expand Down Expand Up @@ -1681,11 +1675,7 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo

let isInRotation = preferences.videoIsInRotation(videoID: video.id)

if isInRotation {
view.checkButton.state = NSControl.StateValue.on
} else {
view.checkButton.state = NSControl.StateValue.off
}
view.checkButton.state = isInRotation ? .on : .off

view.onCheck = { checked in
self.preferences.setVideo(videoID: video.id,
Expand Down Expand Up @@ -1902,14 +1892,14 @@ extension PreferencesWindowController: NSTableViewDelegate {
cellIdentifier = CellIdentifiers.DateCell
} else if tableColumn == tableView.tableColumns[1] {
switch item.level {
case ErrorLevel.info:
image = NSImage.init(named: NSImage.infoName)
case ErrorLevel.warning:
image = NSImage.init(named: NSImage.cautionName)
case ErrorLevel.error:
image = NSImage.init(named: NSImage.stopProgressFreestandingTemplateName)
case .info:
image = NSImage(named: NSImage.infoName)
case .warning:
image = NSImage(named: NSImage.cautionName)
case .error:
image = NSImage(named: NSImage.stopProgressFreestandingTemplateName)
default:
image = NSImage.init(named: NSImage.actionTemplateName)
image = NSImage(named: NSImage.actionTemplateName)
}
//image =
text = item.message
Expand Down

0 comments on commit f1952b5

Please sign in to comment.