diff --git a/CHANGELOG.md b/CHANGELOG.md index bb484ea..540fbfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.10.4] - 2026-11-04 + +### Added +- Right-click (or Control-click) the menu-bar icon for a menu: **Check for Updates…** (or **Install Update X.Y.Z…** once one is found), Settings, About and Quit. + ## [2.10.3] - 2026-11-04 ### Changed diff --git a/Maccy.xcodeproj/project.pbxproj b/Maccy.xcodeproj/project.pbxproj index b051676..d240de6 100644 --- a/Maccy.xcodeproj/project.pbxproj +++ b/Maccy.xcodeproj/project.pbxproj @@ -2017,7 +2017,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 83; + CURRENT_PROJECT_VERSION = 84; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; @@ -2034,7 +2034,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 14.0; - MARKETING_VERSION = 2.10.3; + MARKETING_VERSION = 2.10.4; PRODUCT_BUNDLE_IDENTIFIER = com.royp.MaccyPlus; PRODUCT_NAME = "MaccyPlus"; PRODUCT_MODULE_NAME = Maccy; @@ -2056,7 +2056,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 83; + CURRENT_PROJECT_VERSION = 84; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; @@ -2072,7 +2072,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 14.0; - MARKETING_VERSION = 2.10.3; + MARKETING_VERSION = 2.10.4; PRODUCT_BUNDLE_IDENTIFIER = com.royp.MaccyPlus; PRODUCT_NAME = "MaccyPlus"; PRODUCT_MODULE_NAME = Maccy; diff --git a/Maccy/AppDelegate.swift b/Maccy/AppDelegate.swift index c1bbb8b..087bb45 100644 --- a/Maccy/AppDelegate.swift +++ b/Maccy/AppDelegate.swift @@ -12,6 +12,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) statusItem.behavior = .removalAllowed statusItem.button?.action = #selector(performStatusItemClick) + statusItem.button?.sendAction(on: [.leftMouseDown, .rightMouseUp]) // MaccyPlus: right-click menu statusItem.button?.image = Defaults[.menuIcon].image statusItem.button?.imagePosition = .imageLeft statusItem.button?.target = self @@ -216,6 +217,12 @@ class AppDelegate: NSObject, NSApplicationDelegate { .union(NSEvent.modifierFlags) .intersection(.deviceIndependentFlagsMask) + // MaccyPlus: right-click or control-click opens the menu; left-click is unchanged. + if NSApp.currentEvent?.type == .rightMouseUp || modifierFlags.contains(.control) { + showStatusMenu() + return + } + if modifierFlags.contains(.option) { Defaults[.ignoreEvents].toggle() @@ -229,6 +236,28 @@ class AppDelegate: NSObject, NSApplicationDelegate { panel.toggle(height: AppState.shared.popup.height, at: .statusItem) } + private func showStatusMenu() { + guard let button = statusItem.button else { return } + let menu = NSMenu() + func item(_ title: String, _ action: Selector, key: String = "") { + let item = NSMenuItem(title: title, action: action, keyEquivalent: key) + item.target = self + menu.addItem(item) + } + item(SoftwareUpdater.shared.menuTitle, #selector(statusMenuCheckForUpdates)) + menu.addItem(.separator()) + item("Settings…", #selector(statusMenuSettings), key: ",") + item("About MaccyPlus", #selector(statusMenuAbout)) + menu.addItem(.separator()) + item("Quit MaccyPlus", #selector(NSApplication.terminate(_:)), key: "q") + menu.items.last?.target = NSApp + menu.popUp(positioning: nil, at: NSPoint(x: 0, y: button.bounds.height + 5), in: button) + } + + @objc private func statusMenuCheckForUpdates() { SoftwareUpdater.shared.checkForUpdates() } + @objc private func statusMenuSettings() { AppState.shared.openPreferences() } + @objc private func statusMenuAbout() { AppState.shared.openAbout() } + private func synchronizeMenuIconText() { _ = withObservationTracking { AppState.shared.menuIconText diff --git a/Maccy/SoftwareUpdater.swift b/Maccy/SoftwareUpdater.swift index 33b51e2..917d8ea 100644 --- a/Maccy/SoftwareUpdater.swift +++ b/Maccy/SoftwareUpdater.swift @@ -13,12 +13,19 @@ class SoftwareUpdater { } } + /// Version of an update Sparkle found that is not installed yet; nil when none is known. + var availableVersion: String? + /// Title for the status-item menu: offers a found update, else a manual check. + var menuTitle: String { + availableVersion.map { "Install Update \($0)…" } ?? "Check for Updates…" + } + private var updater: SPUUpdater private var automaticallyChecksForUpdatesObservation: NSKeyValueObservation? private let updaterController = SPUStandardUpdaterController( startingUpdater: true, - updaterDelegate: nil, + updaterDelegate: UpdateAlertPresenter.shared, userDriverDelegate: UpdateAlertPresenter.shared ) @@ -46,9 +53,19 @@ class SoftwareUpdater { /// MaccyPlus: a menu-bar-only app's scheduled update alert opens behind other windows, with no Dock /// icon to find it by. Dock icon + front while the alert is up, back to accessory when it closes. // @unchecked Sendable: no stored state. -nonisolated final class UpdateAlertPresenter: NSObject, SPUStandardUserDriverDelegate, @unchecked Sendable { +nonisolated final class UpdateAlertPresenter: NSObject, SPUUpdaterDelegate, SPUStandardUserDriverDelegate, @unchecked Sendable { static let shared = UpdateAlertPresenter() + // Sparkle calls these on the main thread; its header just doesn't say so to Swift. + func updater(_ updater: SPUUpdater, didFindValidUpdate item: SUAppcastItem) { + let version = item.displayVersionString + MainActor.assumeIsolated { SoftwareUpdater.shared.availableVersion = version } + } + + func updaterDidNotFindUpdate(_ updater: SPUUpdater, error: any Error) { + MainActor.assumeIsolated { SoftwareUpdater.shared.availableVersion = nil } + } + var supportsGentleScheduledUpdateReminders: Bool { true } // Sparkle calls these on the main thread; its header just doesn't say so to Swift.