mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 17:38:38 +00:00
commit
60384561d2
@ -9,8 +9,8 @@
|
||||
import Cocoa
|
||||
|
||||
class CustomButtonTouchBarItem: NSCustomTouchBarItem, NSGestureRecognizerDelegate {
|
||||
private let tapClosure: () -> ()?
|
||||
private let longTapClosure: () -> ()?
|
||||
private let tapClosure: (() -> ())?
|
||||
private let longTapClosure: (() -> ())?
|
||||
private(set) var button: NSButton!
|
||||
|
||||
private var singleClick: NSClickGestureRecognizer!
|
||||
@ -59,7 +59,7 @@ class CustomButtonTouchBarItem: NSCustomTouchBarItem, NSGestureRecognizerDelegat
|
||||
switch gr.state {
|
||||
case .ended:
|
||||
hf.tap(strong: 2)
|
||||
self.tapClosure()
|
||||
self.tapClosure?()
|
||||
break
|
||||
default:
|
||||
break
|
||||
@ -70,12 +70,12 @@ class CustomButtonTouchBarItem: NSCustomTouchBarItem, NSGestureRecognizerDelegat
|
||||
let hf: HapticFeedback = HapticFeedback()
|
||||
switch gr.state {
|
||||
case .began:
|
||||
if self.longTapClosure != nil {
|
||||
if let closure = self.longTapClosure {
|
||||
hf.tap(strong: 2)
|
||||
self.longTapClosure()
|
||||
} else {
|
||||
closure()
|
||||
} else if let closure = self.tapClosure {
|
||||
hf.tap(strong: 6)
|
||||
self.tapClosure()
|
||||
closure()
|
||||
print("long click")
|
||||
}
|
||||
break
|
||||
|
||||
@ -231,7 +231,7 @@ class AppScrubberTouchBarItem: NSCustomTouchBarItem, NSScrubberDelegate, NSScrub
|
||||
public func getDockPersistentAppsList() -> [DockItem] {
|
||||
var returnable: [DockItem] = []
|
||||
|
||||
for (index, bundleIdentifier) in persistentAppIdentifiers.enumerated() {
|
||||
for bundleIdentifier in persistentAppIdentifiers {
|
||||
if !self.runningAppsIdentifiers.contains(bundleIdentifier) {
|
||||
let dockItem = DockItem(bundleIdentifier: bundleIdentifier, icon: getIcon(forBundleIdentifier: bundleIdentifier))
|
||||
returnable.append(dockItem)
|
||||
|
||||
@ -35,13 +35,12 @@ class BatteryInfo: NSObject {
|
||||
var ACPower: String = ""
|
||||
var timeRemaining: String = ""
|
||||
|
||||
var button: NSButton?
|
||||
var button: NSButton
|
||||
var loop:CFRunLoopSource?
|
||||
|
||||
init(button: NSButton) {
|
||||
super.init()
|
||||
|
||||
self.button = button
|
||||
super.init()
|
||||
self.start()
|
||||
}
|
||||
|
||||
@ -135,11 +134,12 @@ class BatteryInfo: NSObject {
|
||||
color = NSColor.red
|
||||
}
|
||||
|
||||
let newTitle = NSMutableAttributedString(string: title as String, attributes: [NSAttributedStringKey.foregroundColor: color, NSAttributedStringKey.font: button?.attributedTitle.attribute(NSAttributedStringKey.font, at: 0, effectiveRange: nil), NSAttributedStringKey.baselineOffset: 1])
|
||||
let regularFont = button.attributedTitle.attribute(.font, at: 0, effectiveRange: nil) as? NSFont ?? NSFont.systemFont(ofSize: 15)
|
||||
let newTitle = NSMutableAttributedString(string: title as String, attributes: [.foregroundColor: color, .font: regularFont, .baselineOffset: 1])
|
||||
let newTitleSecond = NSMutableAttributedString(string: timeRemaining as String, attributes: [NSAttributedStringKey.foregroundColor: color, NSAttributedStringKey.font: NSFont.systemFont(ofSize: 8, weight: .regular), NSAttributedStringKey.baselineOffset: 7])
|
||||
newTitle.append(newTitleSecond)
|
||||
newTitle.setAlignment(.center, range: NSRange(location: 0, length: title.count))
|
||||
button?.attributedTitle = newTitle
|
||||
button.attributedTitle = newTitle
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -109,7 +109,8 @@ class CurrencyBarItem: CustomButtonTouchBarItem {
|
||||
|
||||
let title = String(format: "%@%.2f", self.prefix, value)
|
||||
|
||||
let newTitle = NSMutableAttributedString(string: title as String, attributes: [NSAttributedStringKey.foregroundColor: color, NSAttributedStringKey.font: button.attributedTitle.attribute(NSAttributedStringKey.font, at: 0, effectiveRange: nil)])
|
||||
let regularFont = button.attributedTitle.attribute(.font, at: 0, effectiveRange: nil) as? NSFont ?? NSFont.systemFont(ofSize: 15)
|
||||
let newTitle = NSMutableAttributedString(string: title as String, attributes: [.foregroundColor: color, .font: regularFont])
|
||||
newTitle.setAlignment(.center, range: NSRange(location: 0, length: title.count))
|
||||
button.attributedTitle = newTitle
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user