Menu Items and Hotkeys

This commit is contained in:
Michael Mock authored and Damiano Galassi committed 2025-08-08 17:11:39 +02:00
1 parent 13f1f301e3
commit 20a8714974
2 files changed
+52 -15

No files matched your search

+20 -1
View File
@@ -62,7 +62,7 @@ final class DocumentController : NSDocumentController {
}
@NSApplicationMain
final class AppDelegate: NSObject, NSApplicationDelegate {
final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
@IBOutlet weak var sendToExternalApp: NSMenuItem!
@@ -213,6 +213,25 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
return false
}
@IBAction func toggleStartStop(_ sender: Any?) {
QueueController.shared.toggleStartStop(sender)
}
func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
let action = menuItem.action
if action == #selector(toggleStartStop(_:)) {
let state = QueueController.shared.status
if state == .working {
menuItem.title = NSLocalizedString("Stop Queue", comment: "Main Menu -> Stop Queue")
} else {
menuItem.title = NSLocalizedString("Start Queue", comment: "Main Menu -> Start Queue")
}
}
return true
}
// MARK: actions
@IBAction func openInQueue(_ sender: Any) {