Add a dialog parent class that handles escape key presses

This commit is contained in:
Veronica Berglyd Olsen
2024-05-27 22:53:30 +02:00
parent 206ca6040e
commit f7cdc7da0c
11 changed files with 49 additions and 39 deletions
+7 -12
View File
@@ -27,10 +27,10 @@ from __future__ import annotations
import logging
from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot
from PyQt5.QtGui import QCloseEvent, QKeyEvent, QKeySequence
from PyQt5.QtGui import QCloseEvent
from PyQt5.QtWidgets import (
QAbstractButton, QApplication, QCompleter, QDialog, QDialogButtonBox,
QFileDialog, QHBoxLayout, QLineEdit, QPushButton, QVBoxLayout, QWidget
QAbstractButton, QApplication, QCompleter, QDialogButtonBox, QFileDialog,
QHBoxLayout, QLineEdit, QPushButton, QVBoxLayout, QWidget
)
from novelwriter import CONFIG, SHARED
@@ -38,7 +38,9 @@ from novelwriter.common import describeFont
from novelwriter.constants import nwConst, nwUnicode
from novelwriter.dialogs.quotes import GuiQuoteSelect
from novelwriter.extensions.configlayout import NColourLabel, NScrollableForm
from novelwriter.extensions.modified import NComboBox, NDoubleSpinBox, NIconToolButton, NSpinBox
from novelwriter.extensions.modified import (
NComboBox, NDialog, NDoubleSpinBox, NIconToolButton, NSpinBox
)
from novelwriter.extensions.pagedsidebar import NPagedSideBar
from novelwriter.extensions.switch import NSwitch
from novelwriter.types import (
@@ -49,7 +51,7 @@ from novelwriter.types import (
logger = logging.getLogger(__name__)
class GuiPreferences(QDialog):
class GuiPreferences(NDialog):
newPreferencesReady = pyqtSignal(bool, bool, bool, bool)
@@ -772,13 +774,6 @@ class GuiPreferences(QDialog):
self.deleteLater()
return
def keyPressEvent(self, event: QKeyEvent) -> None:
"""Overload keyPressEvent to block enter key to save."""
if event.matches(QKeySequence.StandardKey.Cancel):
self.close()
event.ignore()
return
##
# Private Slots
##