mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 01:18:39 +00:00
recreate touchbar to clear it's cache (items survive otherwise, still doing their job)
This commit is contained in:
parent
60384561d2
commit
2aa602d77d
@ -35,7 +35,7 @@ class AppleScriptTouchBarItem: CustomButtonTouchBarItem {
|
|||||||
|
|
||||||
func refreshAndSchedule() {
|
func refreshAndSchedule() {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
print("refresh happened")
|
print("refresh happened (interval \(self.interval)), self \(self.identifier.rawValue))")
|
||||||
#endif
|
#endif
|
||||||
let scriptResult = self.execute()
|
let scriptResult = self.execute()
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
|||||||
@ -50,7 +50,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
|
|
||||||
static let shared = TouchBarController()
|
static let shared = TouchBarController()
|
||||||
|
|
||||||
let touchBar = NSTouchBar()
|
var touchBar: NSTouchBar!
|
||||||
|
|
||||||
var itemDefinitions: [NSTouchBarItem.Identifier: BarItemDefinition] = [:]
|
var itemDefinitions: [NSTouchBarItem.Identifier: BarItemDefinition] = [:]
|
||||||
var items: [NSTouchBarItem.Identifier: NSTouchBarItem] = [:]
|
var items: [NSTouchBarItem.Identifier: NSTouchBarItem] = [:]
|
||||||
@ -69,6 +69,10 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createAndUpdatePreset(jsonItems: [BarItemDefinition]? = nil) {
|
func createAndUpdatePreset(jsonItems: [BarItemDefinition]? = nil) {
|
||||||
|
if let oldBar = self.touchBar {
|
||||||
|
NSTouchBar.minimizeSystemModalFunctionBar(oldBar)
|
||||||
|
}
|
||||||
|
self.touchBar = NSTouchBar()
|
||||||
var jsonItems = jsonItems
|
var jsonItems = jsonItems
|
||||||
self.itemDefinitions = [:]
|
self.itemDefinitions = [:]
|
||||||
self.items = [:]
|
self.items = [:]
|
||||||
@ -110,8 +114,11 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func loadItemDefinitions(jsonItems: [BarItemDefinition]) {
|
func loadItemDefinitions(jsonItems: [BarItemDefinition]) {
|
||||||
|
let dateFormatter = DateFormatter()
|
||||||
|
dateFormatter.dateFormat = "HH-mm-ss"
|
||||||
|
let time = dateFormatter.string(from: Date())
|
||||||
for item in jsonItems {
|
for item in jsonItems {
|
||||||
let identifierString = item.type.identifierBase.appending(UUID().uuidString)
|
let identifierString = item.type.identifierBase.appending(time + "--" + UUID().uuidString)
|
||||||
let identifier = NSTouchBarItem.Identifier(identifierString)
|
let identifier = NSTouchBarItem.Identifier(identifierString)
|
||||||
itemDefinitions[identifier] = item
|
itemDefinitions[identifier] = item
|
||||||
if item.align == .left {
|
if item.align == .left {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user