diff --git a/Aerial/Source/Views/PrefPanel/InfoWeatherView.swift b/Aerial/Source/Views/PrefPanel/InfoWeatherView.swift index e5e7d4c7..b66dece6 100644 --- a/Aerial/Source/Views/PrefPanel/InfoWeatherView.swift +++ b/Aerial/Source/Views/PrefPanel/InfoWeatherView.swift @@ -21,6 +21,9 @@ class InfoWeatherView: NSView { @IBOutlet var windModePopup: NSPopUpButton! + @IBOutlet weak var testButtonLocation: NSButton! + @IBOutlet weak var testButtonCity: NSButton! + // Init(ish) func setStates() { locationMode.selectItem(at: PrefsInfo.weather.locationMode.rawValue) @@ -58,6 +61,20 @@ class InfoWeatherView: NSView { @IBAction func locationModeChange(_ sender: NSPopUpButton) { PrefsInfo.weather.locationMode = InfoLocationMode(rawValue: sender.indexOfSelectedItem)! + + if PrefsInfo.weather.locationMode == .useCurrent { + // Get the location + let location = Locations.sharedInstance + + location.getCoordinates(failure: { (_) in + // swiftlint:disable:next line_length + Aerial.helper.showInfoAlert(title: "Could not get your location", text: "Make sure you enabled location services on your Mac (and Wi-Fi!), and that Aerial (or legacyScreenSaver on macOS 10.15 and later) is allowed to use your location. If you use Aerial Companion, you will also need also allow location services for it.", button1: "OK", caution: true) + }, success: { (coordinates) in + self.locationLabel.stringValue = "Location found (\(String(format: "%.2f", coordinates.latitude)), \(String(format: "%.2f", coordinates.longitude)))" + + }) + } + updateLocationMode() } @@ -79,10 +96,12 @@ class InfoWeatherView: NSView { func updateLocationMode() { if PrefsInfo.weather.locationMode == .manuallySpecify { locationString.isHidden = false - // locationLabel.isHidden = true + testButtonLocation.isHidden = true + testButtonCity.isHidden = false } else { locationString.isHidden = true - // locationLabel.isHidden = false + testButtonLocation.isHidden = false + testButtonCity.isHidden = true } } diff --git a/Resources/MainUI/Settings panels/OverlaysViewController.xib b/Resources/MainUI/Settings panels/OverlaysViewController.xib index 5a7e6a83..2eedccda 100644 --- a/Resources/MainUI/Settings panels/OverlaysViewController.xib +++ b/Resources/MainUI/Settings panels/OverlaysViewController.xib @@ -786,7 +786,7 @@ - + @@ -847,7 +847,7 @@ - + @@ -879,7 +879,7 @@ - + @@ -887,7 +887,7 @@ + - + - + + + @@ -1009,6 +1022,7 @@ + @@ -1017,7 +1031,6 @@ - @@ -1025,13 +1038,15 @@ + + - + diff --git a/Resources/MainUI/Settings panels/TimeViewController.swift b/Resources/MainUI/Settings panels/TimeViewController.swift index 527176cf..3d6f67fd 100644 --- a/Resources/MainUI/Settings panels/TimeViewController.swift +++ b/Resources/MainUI/Settings panels/TimeViewController.swift @@ -230,7 +230,7 @@ class TimeViewController: NSViewController { location.getCoordinates(failure: { (_) in // swiftlint:disable:next line_length - Aerial.helper.showInfoAlert(title: "Could not get your location", text: "Make sure you enabled location services on your Mac (and Wi-Fi!), and that Aerial (or legacyScreenSaver on macOS 10.15 and later) is allowed to use your location.", button1: "OK", caution: true) + Aerial.helper.showInfoAlert(title: "Could not get your location", text: "Make sure you enabled location services on your Mac (and Wi-Fi!), and that Aerial (or legacyScreenSaver on macOS 10.15 and later) is allowed to use your location. If you use Aerial Companion, you will also need also allow location services for it.", button1: "OK", caution: true) }, success: { (coordinates) in let lat = String(format: "%.2f", coordinates.latitude) let lon = String(format: "%.2f", coordinates.longitude)