Display the mouseover link in the status bar, and remove it on mouseexit.
This commit is contained in:
parent
3fcede7fb4
commit
8401d0f2f9
@ -18,13 +18,18 @@ final class StatusBarView: NSView {
|
|||||||
@IBOutlet var progressLabel: NSTextField!
|
@IBOutlet var progressLabel: NSTextField!
|
||||||
@IBOutlet var urlLabel: NSTextField!
|
@IBOutlet var urlLabel: NSTextField!
|
||||||
|
|
||||||
fileprivate var isAnimatingProgress = false
|
private var isAnimatingProgress = false
|
||||||
fileprivate var article: Article? {
|
private var article: Article? {
|
||||||
didSet {
|
didSet {
|
||||||
updateURLLabel()
|
updateURLLabel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private var mouseoverLink: String? {
|
||||||
|
didSet {
|
||||||
|
updateURLLabel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override var isFlipped: Bool {
|
override var isFlipped: Bool {
|
||||||
get {
|
get {
|
||||||
return true
|
return true
|
||||||
@ -65,7 +70,7 @@ final class StatusBarView: NSView {
|
|||||||
guard let link = appInfo.url else {
|
guard let link = appInfo.url else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
print(link)
|
mouseoverLink = link
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc dynamic func mouseDidExitLink(_ notification: Notification) {
|
@objc dynamic func mouseDidExitLink(_ notification: Notification) {
|
||||||
@ -79,7 +84,7 @@ final class StatusBarView: NSView {
|
|||||||
guard let link = appInfo.url else {
|
guard let link = appInfo.url else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
print(link)
|
mouseoverLink = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Notifications
|
// MARK: Notifications
|
||||||
@ -88,6 +93,7 @@ final class StatusBarView: NSView {
|
|||||||
|
|
||||||
let timelineView = note.appInfo?.view
|
let timelineView = note.appInfo?.view
|
||||||
if timelineView?.window === self.window {
|
if timelineView?.window === self.window {
|
||||||
|
mouseoverLink = nil
|
||||||
article = note.appInfo?.article
|
article = note.appInfo?.article
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,20 +120,30 @@ private extension StatusBarView {
|
|||||||
func updateURLLabel() {
|
func updateURLLabel() {
|
||||||
|
|
||||||
needsLayout = true
|
needsLayout = true
|
||||||
|
|
||||||
guard let article = article else {
|
guard let article = article else {
|
||||||
urlLabel.stringValue = ""
|
setURLLabel("")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let mouseoverLink = mouseoverLink, !mouseoverLink.isEmpty {
|
||||||
|
setURLLabel(mouseoverLink)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if let s = article.preferredLink {
|
if let s = article.preferredLink {
|
||||||
urlLabel.stringValue = (s as NSString).rs_stringByStrippingHTTPOrHTTPSScheme()
|
setURLLabel(s)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
urlLabel.stringValue = ""
|
setURLLabel("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setURLLabel(_ link: String) {
|
||||||
|
|
||||||
|
urlLabel.stringValue = (link as NSString).rs_stringByStrippingHTTPOrHTTPSScheme()
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Progress
|
// MARK: Progress
|
||||||
|
|
||||||
func stopProgressIfNeeded() {
|
func stopProgressIfNeeded() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user