Merge branch 'main' into dialogue_highlight
This commit is contained in:
@@ -85,7 +85,7 @@ class GuiAbout(NDialog):
|
||||
|
||||
# Buttons
|
||||
self.btnBox = QDialogButtonBox(QtDialogClose, self)
|
||||
self.btnBox.rejected.connect(self.close)
|
||||
self.btnBox.rejected.connect(self.reject)
|
||||
|
||||
# Assemble
|
||||
self.innerBox = QVBoxLayout()
|
||||
|
||||
@@ -27,7 +27,7 @@ from __future__ import annotations
|
||||
import logging
|
||||
|
||||
from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot
|
||||
from PyQt5.QtGui import QCloseEvent
|
||||
from PyQt5.QtGui import QCloseEvent, QKeyEvent, QKeySequence
|
||||
from PyQt5.QtWidgets import (
|
||||
QAbstractButton, QCompleter, QDialogButtonBox, QFileDialog, QHBoxLayout,
|
||||
QLineEdit, QPushButton, QVBoxLayout, QWidget
|
||||
@@ -770,6 +770,16 @@ class GuiPreferences(NDialog):
|
||||
self.softDelete()
|
||||
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
|
||||
##
|
||||
|
||||
@@ -92,7 +92,7 @@ class GuiProjectSettings(NDialog):
|
||||
# Buttons
|
||||
self.buttonBox = QDialogButtonBox(QtDialogSave | QtDialogCancel, self)
|
||||
self.buttonBox.accepted.connect(self._doSave)
|
||||
self.buttonBox.rejected.connect(self.close)
|
||||
self.buttonBox.rejected.connect(self.reject)
|
||||
|
||||
# Content
|
||||
SHARED.project.countStatus()
|
||||
|
||||
@@ -109,7 +109,7 @@ class GuiWordList(NDialog):
|
||||
# Buttons
|
||||
self.buttonBox = QDialogButtonBox(QtDialogSave | QtDialogClose, self)
|
||||
self.buttonBox.accepted.connect(self._doSave)
|
||||
self.buttonBox.rejected.connect(self.close)
|
||||
self.buttonBox.rejected.connect(self.reject)
|
||||
|
||||
# Assemble
|
||||
self.outerBox = QVBoxLayout()
|
||||
|
||||
@@ -30,8 +30,8 @@ from __future__ import annotations
|
||||
from enum import Enum
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from PyQt5.QtCore import QSize, Qt
|
||||
from PyQt5.QtGui import QKeyEvent, QKeySequence, QWheelEvent
|
||||
from PyQt5.QtCore import QSize, Qt, pyqtSlot
|
||||
from PyQt5.QtGui import QWheelEvent
|
||||
from PyQt5.QtWidgets import (
|
||||
QApplication, QComboBox, QDialog, QDoubleSpinBox, QSpinBox, QToolButton,
|
||||
QWidget
|
||||
@@ -54,11 +54,11 @@ class NDialog(QDialog):
|
||||
self.setParent(None) # type: ignore
|
||||
return
|
||||
|
||||
def keyPressEvent(self, event: QKeyEvent) -> None:
|
||||
"""Overload keyPressEvent and forward escape to close."""
|
||||
if event.matches(QKeySequence.StandardKey.Cancel):
|
||||
self.close()
|
||||
event.ignore()
|
||||
@pyqtSlot()
|
||||
def reject(self) -> None:
|
||||
"""Overload the reject slot and also call close."""
|
||||
super().reject()
|
||||
self.close()
|
||||
return
|
||||
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ class GuiDictionaries(NNonBlockingDialog):
|
||||
|
||||
# Buttons
|
||||
self.buttonBox = QDialogButtonBox(QtDialogClose, self)
|
||||
self.buttonBox.rejected.connect(self._doClose)
|
||||
self.buttonBox.rejected.connect(self.reject)
|
||||
|
||||
# Assemble
|
||||
self.innerBox = QVBoxLayout()
|
||||
@@ -220,12 +220,6 @@ class GuiDictionaries(NNonBlockingDialog):
|
||||
SHARED.error("Path not found.")
|
||||
return
|
||||
|
||||
@pyqtSlot()
|
||||
def _doClose(self) -> None:
|
||||
"""Close the dialog."""
|
||||
self.close()
|
||||
return
|
||||
|
||||
##
|
||||
# Internal Functions
|
||||
##
|
||||
|
||||
@@ -26,7 +26,7 @@ from __future__ import annotations
|
||||
import logging
|
||||
import random
|
||||
|
||||
from PyQt5.QtCore import Qt, pyqtSlot
|
||||
from PyQt5.QtCore import pyqtSlot
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QGridLayout, QHBoxLayout, QLabel, QSpinBox, QVBoxLayout,
|
||||
QWidget
|
||||
@@ -48,13 +48,10 @@ class GuiLipsum(NDialog):
|
||||
|
||||
logger.debug("Create: GuiLipsum")
|
||||
self.setObjectName("GuiLipsum")
|
||||
if CONFIG.osDarwin:
|
||||
self.setWindowFlag(Qt.WindowType.Tool)
|
||||
self.setWindowTitle(self.tr("Insert Placeholder Text"))
|
||||
|
||||
self._lipsumText = ""
|
||||
|
||||
self.setWindowTitle(self.tr("Insert Placeholder Text"))
|
||||
|
||||
vSp = CONFIG.pxInt(4)
|
||||
nPx = CONFIG.pxInt(64)
|
||||
|
||||
@@ -96,7 +93,7 @@ class GuiLipsum(NDialog):
|
||||
|
||||
# Buttons
|
||||
self.buttonBox = QDialogButtonBox(self)
|
||||
self.buttonBox.rejected.connect(self.close)
|
||||
self.buttonBox.rejected.connect(self.reject)
|
||||
|
||||
self.btnClose = self.buttonBox.addButton(QtDialogClose)
|
||||
self.btnClose.setAutoDefault(False)
|
||||
@@ -105,8 +102,6 @@ class GuiLipsum(NDialog):
|
||||
self.btnInsert.clicked.connect(self._doInsert)
|
||||
self.btnInsert.setAutoDefault(False)
|
||||
|
||||
self.rejected.connect(self.close)
|
||||
|
||||
# Assemble
|
||||
self.outerBox = QVBoxLayout()
|
||||
self.outerBox.addLayout(self.innerBox)
|
||||
|
||||
@@ -97,7 +97,7 @@ class GuiNovelDetails(NNonBlockingDialog):
|
||||
|
||||
# Buttons
|
||||
self.buttonBox = QDialogButtonBox(QtDialogClose, self)
|
||||
self.buttonBox.rejected.connect(self.close)
|
||||
self.buttonBox.rejected.connect(self.reject)
|
||||
|
||||
# Assemble
|
||||
self.topBox = QHBoxLayout()
|
||||
|
||||
Reference in New Issue
Block a user