mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-10 17:08:39 +00:00
* touchbarNeedRefresh
This commit is contained in:
parent
e7c949209d
commit
9f2dd277fb
@ -83,6 +83,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
let jsonData = path.fileData
|
||||
let jsonItems = jsonData?.barItemDefinitions() ?? [BarItemDefinition(type: .staticButton(title: "bad preset"), action: .none, longAction: .none, additionalParameters: [:])]
|
||||
|
||||
TouchBarController.shared.touchbarNeedRefresh = true;
|
||||
TouchBarController.shared.createAndUpdatePreset(newJsonItems: jsonItems)
|
||||
}
|
||||
}
|
||||
@ -113,6 +114,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
let jsonData = file.path.fileData
|
||||
let jsonItems = jsonData?.barItemDefinitions() ?? [BarItemDefinition(type: .staticButton(title: "bad preset"), action: .none, longAction: .none, additionalParameters: [:])]
|
||||
|
||||
TouchBarController.shared.touchbarNeedRefresh = true;
|
||||
TouchBarController.shared.createAndUpdatePreset(newJsonItems: jsonItems)
|
||||
}
|
||||
})
|
||||
|
||||
@ -75,7 +75,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
var touchbarHidden: Bool = true
|
||||
var touchbarNeedRefresh: Bool = true
|
||||
|
||||
var blacklistAppIdentifiers: [String] = []
|
||||
var frontmostApplicationIdentifier: String? {
|
||||
@ -90,7 +90,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
SupportedTypesHolder.sharedInstance.register(typename: "exitTouchbar", item: .staticButton(title: "exit"), action: .custom(closure: { [weak self] in self?.dismissTouchBar()}), longAction: .none)
|
||||
|
||||
SupportedTypesHolder.sharedInstance.register(typename: "close") { _ in
|
||||
return (item: .staticButton(title: ""), action: .custom(closure: { [weak self] in self?.touchbarHidden = true; self?.createAndUpdatePreset() }), longAction: .none, parameters: [.width: .width(30), .image: .image(source: (NSImage(named: .stopProgressFreestandingTemplate))!)])
|
||||
return (item: .staticButton(title: ""), action: .custom(closure: { [weak self] in self?.touchbarNeedRefresh = true; self?.createAndUpdatePreset() }), longAction: .none, parameters: [.width: .width(30), .image: .image(source: (NSImage(named: .stopProgressFreestandingTemplate))!)])
|
||||
}
|
||||
|
||||
if let blackListed = UserDefaults.standard.stringArray(forKey: "com.toxblh.mtmr.blackListedApps") {
|
||||
@ -146,10 +146,10 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
func updateActiveApp() {
|
||||
if self.blacklistAppIdentifiers.index(of: self.frontmostApplicationIdentifier!) != nil {
|
||||
DFRElementSetControlStripPresenceForIdentifier(.controlStripItem, false)
|
||||
self.touchbarHidden = true
|
||||
self.touchbarNeedRefresh = true
|
||||
} else {
|
||||
presentTouchBar()
|
||||
self.touchbarHidden = false
|
||||
self.touchbarNeedRefresh = false
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,7 +206,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
}
|
||||
|
||||
@objc private func presentTouchBar() {
|
||||
if touchbarHidden {
|
||||
if touchbarNeedRefresh {
|
||||
if self.controlStripState {
|
||||
NSTouchBar.presentSystemModalFunctionBar(touchBar, systemTrayItemIdentifier: .controlStripItem)
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user