From 4737f72b74c4532d0f6fea9ff366dd3110b58fbb Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Wed, 7 Aug 2019 17:37:18 +0200 Subject: [PATCH] =?UTF-8?q?PICARD-1282:=20Allow=20closing=20dialogs=20with?= =?UTF-8?q?=20=E2=8C=98W=20on=20macOS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- picard/ui/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/picard/ui/__init__.py b/picard/ui/__init__.py index ab579fbbc..03e6ed951 100644 --- a/picard/ui/__init__.py +++ b/picard/ui/__init__.py @@ -26,6 +26,7 @@ from PyQt5 import ( ) from picard import config +from picard.const.sys import IS_MACOS from picard.util import restore_method @@ -63,6 +64,13 @@ class PicardDialog(QtWidgets.QDialog, PreserveGeometry): def __init__(self, parent=None): super().__init__(parent, self.flags) + def keyPressEvent(self, event): + if (IS_MACOS and event.modifiers() & QtCore.Qt.ControlModifier + and event.key() == QtCore.Qt.Key_W): + self.close() + else: + super().keyPressEvent(event) + # With py3, QObjects are no longer hashable unless they have # an explicit __hash__ implemented.