mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 17:38:38 +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 jsonData = path.fileData
|
||||||
let jsonItems = jsonData?.barItemDefinitions() ?? [BarItemDefinition(type: .staticButton(title: "bad preset"), action: .none, longAction: .none, additionalParameters: [:])]
|
let jsonItems = jsonData?.barItemDefinitions() ?? [BarItemDefinition(type: .staticButton(title: "bad preset"), action: .none, longAction: .none, additionalParameters: [:])]
|
||||||
|
|
||||||
|
TouchBarController.shared.touchbarNeedRefresh = true;
|
||||||
TouchBarController.shared.createAndUpdatePreset(newJsonItems: jsonItems)
|
TouchBarController.shared.createAndUpdatePreset(newJsonItems: jsonItems)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,6 +114,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
let jsonData = file.path.fileData
|
let jsonData = file.path.fileData
|
||||||
let jsonItems = jsonData?.barItemDefinitions() ?? [BarItemDefinition(type: .staticButton(title: "bad preset"), action: .none, longAction: .none, additionalParameters: [:])]
|
let jsonItems = jsonData?.barItemDefinitions() ?? [BarItemDefinition(type: .staticButton(title: "bad preset"), action: .none, longAction: .none, additionalParameters: [:])]
|
||||||
|
|
||||||
|
TouchBarController.shared.touchbarNeedRefresh = true;
|
||||||
TouchBarController.shared.createAndUpdatePreset(newJsonItems: jsonItems)
|
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 blacklistAppIdentifiers: [String] = []
|
||||||
var frontmostApplicationIdentifier: 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: "exitTouchbar", item: .staticButton(title: "exit"), action: .custom(closure: { [weak self] in self?.dismissTouchBar()}), longAction: .none)
|
||||||
|
|
||||||
SupportedTypesHolder.sharedInstance.register(typename: "close") { _ in
|
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") {
|
if let blackListed = UserDefaults.standard.stringArray(forKey: "com.toxblh.mtmr.blackListedApps") {
|
||||||
@ -146,10 +146,10 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
func updateActiveApp() {
|
func updateActiveApp() {
|
||||||
if self.blacklistAppIdentifiers.index(of: self.frontmostApplicationIdentifier!) != nil {
|
if self.blacklistAppIdentifiers.index(of: self.frontmostApplicationIdentifier!) != nil {
|
||||||
DFRElementSetControlStripPresenceForIdentifier(.controlStripItem, false)
|
DFRElementSetControlStripPresenceForIdentifier(.controlStripItem, false)
|
||||||
self.touchbarHidden = true
|
self.touchbarNeedRefresh = true
|
||||||
} else {
|
} else {
|
||||||
presentTouchBar()
|
presentTouchBar()
|
||||||
self.touchbarHidden = false
|
self.touchbarNeedRefresh = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc private func presentTouchBar() {
|
@objc private func presentTouchBar() {
|
||||||
if touchbarHidden {
|
if touchbarNeedRefresh {
|
||||||
if self.controlStripState {
|
if self.controlStripState {
|
||||||
NSTouchBar.presentSystemModalFunctionBar(touchBar, systemTrayItemIdentifier: .controlStripItem)
|
NSTouchBar.presentSystemModalFunctionBar(touchBar, systemTrayItemIdentifier: .controlStripItem)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user