Skip to content

Commit

Permalink
fixes for new battery options
Browse files Browse the repository at this point in the history
  • Loading branch information
glouel committed Oct 31, 2018
1 parent ec5ca4a commit a791b2b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Aerial/Source/Controllers/PreferencesWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -578,11 +578,16 @@ class PreferencesWindowController: NSWindowController, NSOutlineViewDataSource,
@IBAction func alternateVideoFormatChange(_ sender: NSPopUpButton) {
debugLog("UI alternatePopupVideoFormat: \(sender.indexOfSelectedItem)")
preferences.alternateVideoFormat = sender.indexOfSelectedItem
changeBatteryOverrideState(to: true)
}

func changeBatteryOverrideState(to: Bool) {
powerSavingOnLowBatteryCheckbox.isEnabled = to
alternatePopupVideoFormat.isEnabled = to
if !to || (to && preferences.alternateVideoFormat != Preferences.AlternateVideoFormat.powerSaving.rawValue) {
powerSavingOnLowBatteryCheckbox.isEnabled = to
} else {
powerSavingOnLowBatteryCheckbox.isEnabled = false
}
}

@IBAction func popupVideoFormatChange(_ sender: NSPopUpButton) {
Expand Down
3 changes: 2 additions & 1 deletion Aerial/Source/Views/AerialView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ class AerialView: ScreenSaverView {
let preferences = Preferences.sharedInstance
let timeManagement = TimeManagement.sharedInstance

if preferences.overrideOnBattery && timeManagement.isOnBattery() {
if preferences.overrideOnBattery && timeManagement.isOnBattery() && !isPreview {
if preferences.alternateVideoFormat == Preferences.AlternateVideoFormat.powerSaving.rawValue ||
(preferences.powerSavingOnLowBattery && timeManagement.isBatteryLow()) {
isDisabled = true
timeManagement.setBrightness(level: 0.0)
return
}
Expand Down

0 comments on commit a791b2b

Please sign in to comment.