mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 12:00:09 +02:00
👌 Make sure 'refresh' reopens the menu afterwards (#24)
This commit is contained in:
@ -171,6 +171,19 @@ class MainMenu: NSObject, NSWindowDelegate {
|
||||
update()
|
||||
}
|
||||
|
||||
@objc func reloadPhpMonitorMenu() {
|
||||
waitAndExecute({
|
||||
// This automatically reloads the menu
|
||||
print("Reloading information about the PHP installation...")
|
||||
}, completion: {
|
||||
// Add a slight delay to make sure it loads the new menu
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
||||
// Open the menu again
|
||||
MainMenu.shared.statusItem.button?.performClick(nil)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@objc func setBusyImage() {
|
||||
DispatchQueue.main.async { [self] in
|
||||
setStatusBar(image: NSImage(named: NSImage.Name("StatusBarIcon"))!)
|
||||
|
@ -110,7 +110,7 @@ class StatusMenu : NSMenu {
|
||||
self.addExtensionItem(phpExtension)
|
||||
}
|
||||
|
||||
self.addItem(NSMenuItem(title: "mi_php_refresh".localized, action: #selector(MainMenu.updatePhpVersionInStatusBar), keyEquivalent: "r"))
|
||||
self.addItem(NSMenuItem(title: "mi_php_refresh".localized, action: #selector(MainMenu.reloadPhpMonitorMenu), keyEquivalent: "r"))
|
||||
}
|
||||
|
||||
private func addExtensionItem(_ phpExtension: PhpExtension) {
|
||||
@ -120,6 +120,7 @@ class StatusMenu : NSMenu {
|
||||
)
|
||||
menuItem.state = phpExtension.enabled ? .on : .off
|
||||
menuItem.phpExtension = phpExtension
|
||||
|
||||
self.addItem(menuItem)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user