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

Merge pull request #53 from Toxblh/fix-warnings

Fix compiler warnings
This commit is contained in:
Anton Palgunov 2018-04-29 12:55:00 +01:00 committed by GitHub
commit 60384561d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 14 deletions

View File

@ -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

View File

@ -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)

View File

@ -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
}
}

View File

@ -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
}