Restore the keyPressEvent overload for Preferences

This commit is contained in:
Veronica Berglyd Olsen
2024-06-10 01:03:20 +02:00
parent f8c1ee90ce
commit 29b61c07b0
+11 -1
View File
@@ -27,7 +27,7 @@ from __future__ import annotations
import logging import logging
from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot
from PyQt5.QtGui import QCloseEvent from PyQt5.QtGui import QCloseEvent, QKeyEvent, QKeySequence
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
QAbstractButton, QCompleter, QDialogButtonBox, QFileDialog, QHBoxLayout, QAbstractButton, QCompleter, QDialogButtonBox, QFileDialog, QHBoxLayout,
QLineEdit, QPushButton, QVBoxLayout, QWidget QLineEdit, QPushButton, QVBoxLayout, QWidget
@@ -770,6 +770,16 @@ class GuiPreferences(NDialog):
self.softDelete() self.softDelete()
return return
def keyPressEvent(self, event: QKeyEvent) -> None:
"""Overload keyPressEvent and only accept escape. The main
purpose here is to prevent Enter/Return from closing the dialog
as it is used for the search box.
"""
if event.matches(QKeySequence.StandardKey.Cancel):
self.close()
event.ignore()
return
## ##
# Private Slots # Private Slots
## ##