]> gitweb.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
qt: let Cmd+Q close the launcher on macOS
authorStefan Reinauer <stefan.reinauer@coreboot.org>
Tue, 7 Jul 2026 06:39:11 +0000 (23:39 -0700)
committerStefan Reinauer <stefan.reinauer@coreboot.org>
Tue, 7 Jul 2026 21:00:59 +0000 (14:00 -0700)
The launcher runs as a modal QDialog::exec() with no application event
loop and no menu bar. Escape works because QDialog maps it to reject()
internally, but macOS disables the auto-generated application menu (and
its Cmd+Q) while a modal session is active, so Cmd+Q was swallowed by
the OS and never closed the dialog. Bind QKeySequence::Quit directly on
the dialog so it is handled inside the modal loop, mirroring Escape.

od-unix/qt/launcher.cpp

index 924cecc8cec4e1f342b193d4777008d4117b43e9..8b7c0d00105e2031fc9c5e2d07fe4286eb86f97c 100644 (file)
@@ -5434,6 +5434,12 @@ public:
         connect(start, &QPushButton::clicked, this, [this]() { startEmulator(); });
         connect(help, &QPushButton::clicked, this, [this]() { openHelp(); });
 
+        // macOS disables the application menu (and its Cmd+Q) while the launcher
+        // runs as a modal dialog, so Cmd+Q never reaches us the way it would in
+        // a normal app. Bind it explicitly to Cancel, mirroring Escape.
+        QShortcut *quitShortcut = new QShortcut(QKeySequence::Quit, this);
+        connect(quitShortcut, &QShortcut::activated, this, &QDialog::reject);
+
         QHBoxLayout *buttons = new QHBoxLayout;
         buttons->setContentsMargins(0, 0, 0, 0);
         buttons->addWidget(reset);