mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-12 01:48:38 +00:00
fix wrong preset on close group
This commit is contained in:
parent
958f93f440
commit
ec228fddde
@ -59,6 +59,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
|
|
||||||
var touchBar: NSTouchBar!
|
var touchBar: NSTouchBar!
|
||||||
|
|
||||||
|
fileprivate var lastPresetPath = ""
|
||||||
var jsonItems: [BarItemDefinition] = []
|
var jsonItems: [BarItemDefinition] = []
|
||||||
var itemDefinitions: [NSTouchBarItem.Identifier: BarItemDefinition] = [:]
|
var itemDefinitions: [NSTouchBarItem.Identifier: BarItemDefinition] = [:]
|
||||||
var items: [NSTouchBarItem.Identifier: NSTouchBarItem] = [:]
|
var items: [NSTouchBarItem.Identifier: NSTouchBarItem] = [:]
|
||||||
@ -95,8 +96,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
SupportedTypesHolder.sharedInstance.register(typename: "close") { _ in
|
SupportedTypesHolder.sharedInstance.register(typename: "close") { _ in
|
||||||
return (item: .staticButton(title: ""), action: .custom(closure: { [weak self] in
|
return (item: .staticButton(title: ""), action: .custom(closure: { [weak self] in
|
||||||
guard let `self` = self else { return }
|
guard let `self` = self else { return }
|
||||||
self.touchbarNeedRefresh = true
|
self.reloadPreset(path: self.lastPresetPath)
|
||||||
self.reloadStandardConfig() //fixme current config, not standard one!
|
|
||||||
}), longAction: .none, parameters: [.width: .width(30), .image: .image(source: (NSImage(named: .stopProgressFreestandingTemplate))!)])
|
}), longAction: .none, parameters: [.width: .width(30), .image: .image(source: (NSImage(named: .stopProgressFreestandingTemplate))!)])
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didTerminateApplicationNotification, object: nil)
|
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didTerminateApplicationNotification, object: nil)
|
||||||
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didActivateApplicationNotification, object: nil)
|
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(activeApplicationChanged), name: NSWorkspace.didActivateApplicationNotification, object: nil)
|
||||||
|
|
||||||
reloadPreset(path: standardConfigPath)
|
reloadStandardConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
func createAndUpdatePreset(newJsonItems: [BarItemDefinition]) {
|
func createAndUpdatePreset(newJsonItems: [BarItemDefinition]) {
|
||||||
@ -166,6 +166,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func reloadPreset(path: String) {
|
func reloadPreset(path: String) {
|
||||||
|
lastPresetPath = path
|
||||||
let items = path.fileData?.barItemDefinitions() ?? [BarItemDefinition(type: .staticButton(title: "bad preset"), action: .none, longAction: .none, additionalParameters: [:])]
|
let items = path.fileData?.barItemDefinitions() ?? [BarItemDefinition(type: .staticButton(title: "bad preset"), action: .none, longAction: .none, additionalParameters: [:])]
|
||||||
touchbarNeedRefresh = true
|
touchbarNeedRefresh = true
|
||||||
createAndUpdatePreset(newJsonItems: items)
|
createAndUpdatePreset(newJsonItems: items)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user