Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ddddxxx committed Jan 20, 2019
1 parent d2cf345 commit 12e625f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 21 deletions.
6 changes: 2 additions & 4 deletions LyricsX/Component/TouchBarCurrentPlayingItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@ class TouchBarArtworkViewController: NSViewController {

override func viewDidLoad() {
reloadImage()
observation = NotificationCenter.default.addObserver(forName: .currentTrackChange, object: AppController.shared, queue: .main) { [unowned self] _ in
self.reloadImage()
}
NotificationCenter.default.addObserver(self, selector: #selector(reloadImage), name: .currentTrackChange, object: nil)
}

func reloadImage() {
@objc func reloadImage() {
guard let player = AppController.shared.playerManager.player else {
artworkView.image = nil
return
Expand Down
9 changes: 2 additions & 7 deletions LyricsX/Component/TouchBarLyricsItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,8 @@ class TouchBarLyricsItem: NSCustomTouchBarItem {
}

func commonInit() {
view.addSubview(lyricsTextField)
lyricsTextField.snp.makeConstraints { make in
make.top.bottom.right.equalToSuperview()
// For some reason the left edge get clipped without the offset.
make.left.equalToSuperview().offset(4)
}
lyricsTextField.alignment = .center
view = lyricsTextField
handleLyricsDisplay()
NotificationCenter.default.addObserver(self, selector: #selector(self.handleLyricsDisplay), name: .lyricsShouldDisplay, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.handleLyricsDisplay), name: .currentLyricsChange, object: nil)
}
Expand Down
11 changes: 7 additions & 4 deletions LyricsX/Controller/KaraokeLyricsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@ class KaraokeLyricsWindowController: NSWindowController {
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
self.lyricsView.displayLrc("")
self.handleLyricsDisplay()
self.observeNotification(name: .lyricsShouldDisplay, using: { [unowned self] _ in
self.observeNotification(name: .lyricsShouldDisplay) { [unowned self] _ in
self.handleLyricsDisplay()
})
self.observeNotification(name: .currentLyricsChange, using: { [unowned self] _ in
}
self.observeNotification(name: .currentLyricsChange) { [unowned self] _ in
self.handleLyricsDisplay()
}
self.observeDefaults(keys: [.PreferBilingualLyrics, .DesktopLyricsOneLineMode]) { [unowned self] in
self.handleLyricsDisplay()
})
}
}
}

Expand Down
6 changes: 1 addition & 5 deletions LyricsX/Controller/TouchBarLyrics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ class TouchBarLyrics: NSObject, NSTouchBarDelegate {

lyricsItem.bind(\.progressColor, withUnmatchedDefaultName: .DesktopLyricsProgressColor)

let nc = NSUserNotificationCenter.default
nc.observeNotification(name: NSApplication.didBecomeActiveNotification) { _ in
self.systemTrayItem.setControlStripPresence(false)
}
nc.observeNotification(name: NSApplication.didResignActiveNotification) { _ in
NSUserNotificationCenter.default.observeNotification(name: NSApplication.didBecomeActiveNotification) { _ in
self.systemTrayItem.setControlStripPresence(true)
}
}
Expand Down
2 changes: 1 addition & 1 deletion LyricsX/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>1.4.3</string>
<key>CFBundleVersion</key>
<string>2046</string>
<string>2056</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down

0 comments on commit 12e625f

Please sign in to comment.