diff --git a/Quality.xcodeproj/project.pbxproj b/Quality.xcodeproj/project.pbxproj index ff1e64d..78c5f3a 100644 --- a/Quality.xcodeproj/project.pbxproj +++ b/Quality.xcodeproj/project.pbxproj @@ -338,7 +338,7 @@ CODE_SIGN_ENTITLEMENTS = Quality/Quality.entitlements; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 8; + CURRENT_PROJECT_VERSION = 9; DEVELOPMENT_ASSET_PATHS = "\"Quality/Preview Content\""; DEVELOPMENT_TEAM = 3X69W4AQD6; ENABLE_HARDENED_RUNTIME = YES; @@ -372,7 +372,7 @@ CODE_SIGN_ENTITLEMENTS = Quality/Quality.entitlements; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 8; + CURRENT_PROJECT_VERSION = 9; DEVELOPMENT_ASSET_PATHS = "\"Quality/Preview Content\""; DEVELOPMENT_TEAM = 3X69W4AQD6; ENABLE_HARDENED_RUNTIME = YES; diff --git a/Quality/AppDelegate.swift b/Quality/AppDelegate.swift index 2dfab1f..a2b9848 100644 --- a/Quality/AppDelegate.swift +++ b/Quality/AppDelegate.swift @@ -116,10 +116,16 @@ class AppDelegate: NSObject, NSApplicationDelegate { var idx = 0 for device in outputDevices.outputDevices { + let uid = device.uid let name = device.name let item = DeviceMenuItem(title: name, action: #selector(deviceSelection(_:)), keyEquivalent: "", device: device) item.tag = idx - item.state = .off + if let uid, uid == Defaults.shared.selectedDeviceUID { + item.state = .on + } + else { + item.state = .off + } idx += 1 self.devicesMenu.addItem(item) } @@ -129,6 +135,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { self.devicesMenu.items.forEach({$0.state = .off}) sender.state = .on outputDevices.selectedOutputDevice = sender.device + Defaults.shared.selectedDeviceUID = sender.device?.uid } func statusItemDisplay() { diff --git a/Quality/Defaults.swift b/Quality/Defaults.swift index d7a8817..c146a2b 100644 --- a/Quality/Defaults.swift +++ b/Quality/Defaults.swift @@ -10,6 +10,7 @@ import Foundation class Defaults { static let shared = Defaults() private let kUserPreferIconStatusBarItem = "com.vincent-neo.LosslessSwitcher-Key-UserPreferIconStatusBarItem" + private let kSelectedDeviceUID = "com.vincent-neo.LosslessSwitcher-Key-SelectedDeviceUID" private init() { UserDefaults.standard.register(defaults: [kUserPreferIconStatusBarItem : true]) @@ -24,6 +25,15 @@ class Defaults { } } + var selectedDeviceUID: String? { + get { + return UserDefaults.standard.string(forKey: kSelectedDeviceUID) + } + set { + UserDefaults.standard.set(newValue, forKey: kSelectedDeviceUID) + } + } + var statusBarItemTitle: String { let title = self.userPreferIconStatusBarItem ? "Show Sample Rate" : "Show Icon" return title