Use standard key sequences instead of custom checks in keyPressEvent.

Ensures platform specific shortcuts are used.
This commit is contained in:
Philipp Wolfer
2020-01-26 17:29:16 +01:00
parent 8f693aaf4d
commit ab5aa68b4f
2 changed files with 4 additions and 5 deletions

View File

@@ -22,11 +22,11 @@ import uuid
from PyQt5 import (
QtCore,
QtGui,
QtWidgets,
)
from picard import config
from picard.const.sys import IS_MACOS
from picard.util import restore_method
@@ -88,8 +88,7 @@ class PicardDialog(QtWidgets.QDialog, PreserveGeometry):
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):
if event.matches(QtGui.QKeySequence.Close):
self.close()
else:
super().keyPressEvent(event)

View File

@@ -19,6 +19,7 @@
from PyQt5 import (
QtCore,
QtGui,
QtWidgets,
)
@@ -30,8 +31,7 @@ class EditableListView(QtWidgets.QListView):
self.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
def keyPressEvent(self, event):
if (event.modifiers() == QtCore.Qt.NoModifier
and event.key() == QtCore.Qt.Key_Delete):
if event.matches(QtGui.QKeySequence.Delete):
self.remove_selected_rows()
else:
super().keyPressEvent(event)