PICARD-1282: Allow closing dialogs with ⌘W on macOS

This commit is contained in:
Philipp Wolfer
2019-08-07 17:37:18 +02:00
parent 63c697b1cc
commit 4737f72b74

View File

@@ -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.