diff --git a/Clocker/Overall App/ConfigExport.swift b/Clocker/Overall App/ConfigExport.swift index f96e5bc..feb4fe5 100644 --- a/Clocker/Overall App/ConfigExport.swift +++ b/Clocker/Overall App/ConfigExport.swift @@ -1,7 +1,7 @@ // Copyright © 2015 Abhishek Banthia -import CoreModelKit import CoreLoggerKit +import CoreModelKit import Foundation struct ConfigExport { diff --git a/Clocker/Overall App/DataStore.swift b/Clocker/Overall App/DataStore.swift index 8ed0f6a..fa836e1 100644 --- a/Clocker/Overall App/DataStore.swift +++ b/Clocker/Overall App/DataStore.swift @@ -112,11 +112,13 @@ class DataStore: NSObject { } // MARK: Date (May 8th) in Compact Menubar + func shouldShowDateInMenubar() -> Bool { return shouldDisplay(.dateInMenubar) } - + // MARK: Day (Sun, Mon etc.) in Compact Menubar + func shouldShowDayInMenubar() -> Bool { return shouldDisplay(.dayInMenubar) } @@ -207,8 +209,9 @@ class DataStore: NSObject { } return value.isEqual(to: NSNumber(value: 0)) } - + // MARK: Some values are stored as plain integers; objectForKey: will return nil, so using integerForKey: + private func shouldDisplayNonObjectHelper(_ key: String) -> Bool { let value = userDefaults.integer(forKey: key) return value == 0 diff --git a/Clocker/Panel/ParentPanelController.swift b/Clocker/Panel/ParentPanelController.swift index 8745d30..8715082 100644 --- a/Clocker/Panel/ParentPanelController.swift +++ b/Clocker/Panel/ParentPanelController.swift @@ -586,9 +586,9 @@ class ParentPanelController: NSWindowController { } private lazy var menubarTitleHandler = MenubarTitleProvider(with: DataStore.shared(), eventStore: EventCenter.sharedCenter()) - - static private let attributes: [NSAttributedString.Key : Any] = [NSAttributedString.Key.font: NSFont.monospacedDigitSystemFont(ofSize: 13.0, weight: NSFont.Weight.regular), - NSAttributedString.Key.baselineOffset : 0.1] + + private static let attributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.font: NSFont.monospacedDigitSystemFont(ofSize: 13.0, weight: NSFont.Weight.regular), + NSAttributedString.Key.baselineOffset: 0.1] @objc func updateTime() { let store = DataStore.shared() @@ -615,6 +615,7 @@ class ParentPanelController: NSWindowController { } } + let hoverRow = mainTableView.hoverRow stride(from: 0, to: preferences.count, by: 1).forEach { let current = preferences[$0] @@ -628,11 +629,16 @@ class ParentPanelController: NSWindowController { if modernContainerView != nil, modernSlider.isHidden == false, modernContainerView.currentlyInFocus { return } + let dataOperation = TimezoneDataOperations(with: model, store: DataStore.shared()) cellView.time.stringValue = dataOperation.time(with: futureSliderValue) cellView.sunriseSetTime.stringValue = dataOperation.formattedSunriseTime(with: futureSliderValue) cellView.sunriseSetTime.lineBreakMode = .byClipping - cellView.relativeDate.stringValue = dataOperation.date(with: futureSliderValue, displayType: .panel) + + if $0 != hoverRow { + cellView.relativeDate.stringValue = dataOperation.date(with: futureSliderValue, displayType: .panel) + } + cellView.currentLocationIndicator.isHidden = !model.isSystemTimezone cellView.sunriseImage.image = model.isSunriseOrSunset ? Themer.shared().sunriseImage() : Themer.shared().sunsetImage() if #available(macOS 10.14, *) { diff --git a/Clocker/Panel/UI/TimezoneDataSource.swift b/Clocker/Panel/UI/TimezoneDataSource.swift index 1d74463..f04c071 100644 --- a/Clocker/Panel/UI/TimezoneDataSource.swift +++ b/Clocker/Panel/UI/TimezoneDataSource.swift @@ -205,8 +205,27 @@ extension TimezoneDataSource: PanelTableViewDelegate { } rowCellView.extraOptions.alphaValue = (rowIndex == row) ? 1 : 0.5 + if rowIndex == row, let hoverString = hoverStringForSelectedRow(row: row) { + rowCellView.relativeDate.stringValue = hoverString + } + } + } + } + + private func hoverStringForSelectedRow(row: Int) -> String? { + let currentModel = timezones[row] + if let timezone = TimeZone(identifier: currentModel.timezone()) { + let offSet = Double(timezone.secondsFromGMT()) / 3600 + let localizedName = timezone.localizedName(for: .shortDaylightSaving, locale: Locale.autoupdatingCurrent) ?? "Error" + if offSet == 0.0 { + return "\(localizedName)" + } else { + let offSetSign = offSet > 0 ? "+" : CLEmptyString + let offsetString = "UTC\(offSetSign)\(offSet)" + return "\(localizedName) (\(offsetString))" } } + return nil } } diff --git a/Clocker/Preferences/Menu Bar/StatusItemHandler.swift b/Clocker/Preferences/Menu Bar/StatusItemHandler.swift index f4b40ad..d07f564 100644 --- a/Clocker/Preferences/Menu Bar/StatusItemHandler.swift +++ b/Clocker/Preferences/Menu Bar/StatusItemHandler.swift @@ -365,9 +365,9 @@ class StatusItemHandler: NSObject { setClockerIcon() return } - + let attributes = [NSAttributedString.Key.font: NSFont.monospacedDigitSystemFont(ofSize: 13.0, weight: NSFont.Weight.regular), - NSAttributedString.Key.baselineOffset : 0.1] as [NSAttributedString.Key : Any] + NSAttributedString.Key.baselineOffset: 0.1] as [NSAttributedString.Key: Any] statusItem.button?.attributedTitle = NSAttributedString(string: menubarText, attributes: attributes) statusItem.button?.image = nil statusItem.button?.imagePosition = .imageLeft