1
0
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:
2021-03-29 22:24:15 +02:00
parent 485001403d
commit 6e574b9154
2 changed files with 15 additions and 1 deletions

View File

@ -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"))!)

View File

@ -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)
}
}