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