1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-11 17:38:38 +00:00

hide button property, cleanup nasty code

This commit is contained in:
Serg 2018-05-12 12:02:45 +07:00
parent f7eb49e5de
commit bbea465500
7 changed files with 6 additions and 17 deletions

View File

@ -14,7 +14,7 @@ class AppleScriptTouchBarItem: CustomButtonTouchBarItem {
return return
} }
self.script = script self.script = script
button.bezelColor = .clear self.isBordered = false
DispatchQueue.main.async { DispatchQueue.main.async {
var error: NSDictionary? var error: NSDictionary?
guard script.compileAndReturnError(&error) else { guard script.compileAndReturnError(&error) else {

View File

@ -11,7 +11,7 @@ import Cocoa
class CustomButtonTouchBarItem: NSCustomTouchBarItem, NSGestureRecognizerDelegate { class CustomButtonTouchBarItem: NSCustomTouchBarItem, NSGestureRecognizerDelegate {
var tapClosure: (() -> ())? var tapClosure: (() -> ())?
var longTapClosure: (() -> ())? var longTapClosure: (() -> ())?
private(set) var button: NSButton! //todo hide completely private var button: NSButton!
private var singleClick: NSClickGestureRecognizer! private var singleClick: NSClickGestureRecognizer!
private var longClick: NSPressGestureRecognizer! private var longClick: NSPressGestureRecognizer!

View File

@ -10,7 +10,6 @@ class ScrollViewItem: NSCustomTouchBarItem {
stackView.orientation = .horizontal stackView.orientation = .horizontal
let scrollView = NSScrollView(frame: CGRect(origin: .zero, size: stackView.fittingSize)) let scrollView = NSScrollView(frame: CGRect(origin: .zero, size: stackView.fittingSize))
scrollView.documentView = stackView scrollView.documentView = stackView
// scrollView.documentView?.bounds.origin = CGPoint(x: 0.0, y: -2.5)
self.view = scrollView self.view = scrollView
} }

View File

@ -50,8 +50,6 @@ class CurrencyBarItem: CustomButtonTouchBarItem {
super.init(identifier: identifier, title: "") super.init(identifier: identifier, title: "")
self.view = button
activity.repeats = true activity.repeats = true
activity.qualityOfService = .utility activity.qualityOfService = .utility
activity.schedule { (completion: NSBackgroundActivityScheduler.CompletionHandler) in activity.schedule { (completion: NSBackgroundActivityScheduler.CompletionHandler) in

View File

@ -19,9 +19,9 @@ class InputSourceBarItem: CustomButtonTouchBarItem {
observeIputSourceChangedNotification(); observeIputSourceChangedNotification();
textInputSourceDidChange() textInputSourceDidChange()
self.tapClosure = { [weak self] in
self.button.cell?.action = #selector(switchInputSource) self?.switchInputSource()
self.button.action = #selector(switchInputSource) }
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
@ -32,11 +32,6 @@ class InputSourceBarItem: CustomButtonTouchBarItem {
CFNotificationCenterRemoveEveryObserver(notificationCenter, UnsafeRawPointer(Unmanaged.passUnretained(self).toOpaque())); CFNotificationCenterRemoveEveryObserver(notificationCenter, UnsafeRawPointer(Unmanaged.passUnretained(self).toOpaque()));
} }
@objc override func handleGestureSingle(gr: NSClickGestureRecognizer) {
super.handleGestureSingle(gr: gr)
switchInputSource()
}
@objc public func textInputSourceDidChange() { @objc public func textInputSourceDidChange() {
let currentSource = TISCopyCurrentKeyboardInputSource().takeUnretainedValue() let currentSource = TISCopyCurrentKeyboardInputSource().takeUnretainedValue()

View File

@ -8,8 +8,7 @@ class TimeTouchBarItem: CustomButtonTouchBarItem {
dateFormatter.setLocalizedDateFormatFromTemplate(formatTemplate) dateFormatter.setLocalizedDateFormatFromTemplate(formatTemplate)
super.init(identifier: identifier, title: " ") super.init(identifier: identifier, title: " ")
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(updateTime), userInfo: nil, repeats: true) timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(updateTime), userInfo: nil, repeats: true)
self.view = button self.isBordered = false
button.bezelColor = .clear
updateTime() updateTime()
} }

View File

@ -43,8 +43,6 @@ class WeatherBarItem: CustomButtonTouchBarItem, CLLocationManagerDelegate {
} }
super.init(identifier: identifier, title: "") super.init(identifier: identifier, title: "")
self.view = button
let status = CLLocationManager.authorizationStatus() let status = CLLocationManager.authorizationStatus()
if status == .restricted || status == .denied { if status == .restricted || status == .denied {