Add closeEvents to dialogs and set the deleteLater command
This commit is contained in:
@@ -28,8 +28,8 @@ import novelwriter
|
|||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from PyQt5.QtGui import QCursor
|
from PyQt5.QtGui import QCloseEvent, QCursor
|
||||||
from PyQt5.QtCore import Qt, pyqtSlot
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
qApp, QDialog, QDialogButtonBox, QHBoxLayout, QLabel, QTabWidget,
|
qApp, QDialog, QDialogButtonBox, QHBoxLayout, QLabel, QTabWidget,
|
||||||
QTextBrowser, QVBoxLayout, QWidget
|
QTextBrowser, QVBoxLayout, QWidget
|
||||||
@@ -101,7 +101,7 @@ class GuiAbout(QDialog):
|
|||||||
|
|
||||||
# OK Button
|
# OK Button
|
||||||
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok)
|
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok)
|
||||||
self.buttonBox.accepted.connect(self._doClose)
|
self.buttonBox.accepted.connect(self.close)
|
||||||
|
|
||||||
self.outerBox.addLayout(self.innerBox)
|
self.outerBox.addLayout(self.innerBox)
|
||||||
self.outerBox.addWidget(self.buttonBox)
|
self.outerBox.addWidget(self.buttonBox)
|
||||||
@@ -132,13 +132,12 @@ class GuiAbout(QDialog):
|
|||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Private Slots
|
# Events
|
||||||
##
|
##
|
||||||
|
|
||||||
@pyqtSlot()
|
def closeEvent(self, event: QCloseEvent) -> None:
|
||||||
def _doClose(self) -> None:
|
"""Capture the close event and perform cleanup."""
|
||||||
"""Close the dialog"""
|
event.accept()
|
||||||
self.close()
|
|
||||||
self.deleteLater()
|
self.deleteLater()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, QSize
|
from PyQt5.QtGui import QCloseEvent
|
||||||
|
from PyQt5.QtCore import Qt, QSize, pyqtSlot
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QAbstractItemView, QDialog, QDialogButtonBox, QGridLayout, QLabel,
|
QAbstractItemView, QDialog, QDialogButtonBox, QGridLayout, QLabel,
|
||||||
QListWidget, QListWidgetItem, QVBoxLayout, QWidget
|
QListWidget, QListWidgetItem, QVBoxLayout, QWidget
|
||||||
@@ -125,10 +126,21 @@ class GuiDocMerge(QDialog):
|
|||||||
|
|
||||||
return self._data
|
return self._data
|
||||||
|
|
||||||
|
##
|
||||||
|
# Events
|
||||||
|
##
|
||||||
|
|
||||||
|
def closeEvent(self, event: QCloseEvent) -> None:
|
||||||
|
"""Capture the close event and perform cleanup."""
|
||||||
|
event.accept()
|
||||||
|
self.deleteLater()
|
||||||
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Private Slots
|
# Private Slots
|
||||||
##
|
##
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _resetList(self) -> None:
|
def _resetList(self) -> None:
|
||||||
"""Reset the content of the list box to its original state."""
|
"""Reset the content of the list box to its original state."""
|
||||||
logger.debug("Resetting list box content")
|
logger.debug("Resetting list box content")
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from PyQt5.QtGui import QCloseEvent
|
||||||
from PyQt5.QtCore import Qt, pyqtSlot
|
from PyQt5.QtCore import Qt, pyqtSlot
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QAbstractItemView, QComboBox, QDialog, QDialogButtonBox, QGridLayout,
|
QAbstractItemView, QComboBox, QDialog, QDialogButtonBox, QGridLayout,
|
||||||
@@ -167,6 +168,7 @@ class GuiDocSplit(QDialog):
|
|||||||
self._data["docHierarchy"] = docHierarchy
|
self._data["docHierarchy"] = docHierarchy
|
||||||
self._data["moveToTrash"] = moveToTrash
|
self._data["moveToTrash"] = moveToTrash
|
||||||
|
|
||||||
|
logger.debug("Saving State: GuiDocSplit")
|
||||||
pOptions = SHARED.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiDocSplit", "spLevel", spLevel)
|
pOptions.setValue("GuiDocSplit", "spLevel", spLevel)
|
||||||
pOptions.setValue("GuiDocSplit", "intoFolder", intoFolder)
|
pOptions.setValue("GuiDocSplit", "intoFolder", intoFolder)
|
||||||
@@ -174,6 +176,16 @@ class GuiDocSplit(QDialog):
|
|||||||
|
|
||||||
return self._data, self._text
|
return self._data, self._text
|
||||||
|
|
||||||
|
##
|
||||||
|
# Events
|
||||||
|
##
|
||||||
|
|
||||||
|
def closeEvent(self, event: QCloseEvent) -> None:
|
||||||
|
"""Capture the close event and perform cleanup."""
|
||||||
|
event.accept()
|
||||||
|
self.deleteLater()
|
||||||
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Private Slots
|
# Private Slots
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -88,6 +88,9 @@ class GuiEditLabel(QDialog):
|
|||||||
def getLabel(cls, parent: QWidget, text: str) -> tuple[str, bool]:
|
def getLabel(cls, parent: QWidget, text: str) -> tuple[str, bool]:
|
||||||
cls = GuiEditLabel(parent, text=text)
|
cls = GuiEditLabel(parent, text=text)
|
||||||
cls.exec_()
|
cls.exec_()
|
||||||
return cls.itemLabel, cls.result() == QDialog.Accepted
|
label = cls.itemLabel
|
||||||
|
accepted = cls.result() == QDialog.Accepted
|
||||||
|
cls.deleteLater()
|
||||||
|
return label, accepted
|
||||||
|
|
||||||
# END Class GuiEditLabel
|
# END Class GuiEditLabel
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class GuiPreferences(NPagedDialog):
|
|||||||
self.addTab(self.tabAuto, self.tr("Automation"))
|
self.addTab(self.tabAuto, self.tr("Automation"))
|
||||||
self.addTab(self.tabQuote, self.tr("Quotes"))
|
self.addTab(self.tabQuote, self.tr("Quotes"))
|
||||||
|
|
||||||
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self)
|
||||||
self.buttonBox.accepted.connect(self._doSave)
|
self.buttonBox.accepted.connect(self._doSave)
|
||||||
self.buttonBox.rejected.connect(self._doClose)
|
self.buttonBox.rejected.connect(self._doClose)
|
||||||
self.addControls(self.buttonBox)
|
self.addControls(self.buttonBox)
|
||||||
@@ -169,7 +169,7 @@ class GuiPreferencesGeneral(QWidget):
|
|||||||
minWidth = CONFIG.pxInt(200)
|
minWidth = CONFIG.pxInt(200)
|
||||||
|
|
||||||
# Select Locale
|
# Select Locale
|
||||||
self.guiLocale = QComboBox()
|
self.guiLocale = QComboBox(self)
|
||||||
self.guiLocale.setMinimumWidth(minWidth)
|
self.guiLocale.setMinimumWidth(minWidth)
|
||||||
theLangs = CONFIG.listLanguages(CONFIG.LANG_NW)
|
theLangs = CONFIG.listLanguages(CONFIG.LANG_NW)
|
||||||
for lang, langName in theLangs:
|
for lang, langName in theLangs:
|
||||||
@@ -187,7 +187,7 @@ class GuiPreferencesGeneral(QWidget):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Select Theme
|
# Select Theme
|
||||||
self.guiTheme = QComboBox()
|
self.guiTheme = QComboBox(self)
|
||||||
self.guiTheme.setMinimumWidth(minWidth)
|
self.guiTheme.setMinimumWidth(minWidth)
|
||||||
self.theThemes = SHARED.theme.listThemes()
|
self.theThemes = SHARED.theme.listThemes()
|
||||||
for themeDir, themeName in self.theThemes:
|
for themeDir, themeName in self.theThemes:
|
||||||
@@ -203,7 +203,7 @@ class GuiPreferencesGeneral(QWidget):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Editor Theme
|
# Editor Theme
|
||||||
self.guiSyntax = QComboBox()
|
self.guiSyntax = QComboBox(self)
|
||||||
self.guiSyntax.setMinimumWidth(CONFIG.pxInt(200))
|
self.guiSyntax.setMinimumWidth(CONFIG.pxInt(200))
|
||||||
self.theSyntaxes = SHARED.theme.listSyntax()
|
self.theSyntaxes = SHARED.theme.listSyntax()
|
||||||
for syntaxFile, syntaxName in self.theSyntaxes:
|
for syntaxFile, syntaxName in self.theSyntaxes:
|
||||||
@@ -219,11 +219,11 @@ class GuiPreferencesGeneral(QWidget):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Font Family
|
# Font Family
|
||||||
self.guiFont = QLineEdit()
|
self.guiFont = QLineEdit(self)
|
||||||
self.guiFont.setReadOnly(True)
|
self.guiFont.setReadOnly(True)
|
||||||
self.guiFont.setFixedWidth(CONFIG.pxInt(162))
|
self.guiFont.setFixedWidth(CONFIG.pxInt(162))
|
||||||
self.guiFont.setText(CONFIG.guiFont)
|
self.guiFont.setText(CONFIG.guiFont)
|
||||||
self.fontButton = QPushButton("...")
|
self.fontButton = QPushButton("...", self)
|
||||||
self.fontButton.setMaximumWidth(int(2.5*SHARED.theme.getTextWidth("...")))
|
self.fontButton.setMaximumWidth(int(2.5*SHARED.theme.getTextWidth("...")))
|
||||||
self.fontButton.clicked.connect(self._selectFont)
|
self.fontButton.clicked.connect(self._selectFont)
|
||||||
self.mainForm.addRow(
|
self.mainForm.addRow(
|
||||||
@@ -378,7 +378,7 @@ class GuiPreferencesProjects(QWidget):
|
|||||||
|
|
||||||
# Backup Path
|
# Backup Path
|
||||||
self.backupPath = CONFIG.backupPath()
|
self.backupPath = CONFIG.backupPath()
|
||||||
self.backupGetPath = QPushButton(self.tr("Browse"))
|
self.backupGetPath = QPushButton(self.tr("Browse"), self)
|
||||||
self.backupGetPath.clicked.connect(self._backupFolder)
|
self.backupGetPath.clicked.connect(self._backupFolder)
|
||||||
self.backupPathRow = self.mainForm.addRow(
|
self.backupPathRow = self.mainForm.addRow(
|
||||||
self.tr("Backup storage location"),
|
self.tr("Backup storage location"),
|
||||||
@@ -421,7 +421,7 @@ class GuiPreferencesProjects(QWidget):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Inactive time for idle
|
# Inactive time for idle
|
||||||
self.userIdleTime = QDoubleSpinBox()
|
self.userIdleTime = QDoubleSpinBox(self)
|
||||||
self.userIdleTime.setMinimum(0.5)
|
self.userIdleTime.setMinimum(0.5)
|
||||||
self.userIdleTime.setMaximum(600.0)
|
self.userIdleTime.setMaximum(600.0)
|
||||||
self.userIdleTime.setSingleStep(0.5)
|
self.userIdleTime.setSingleStep(0.5)
|
||||||
@@ -496,11 +496,11 @@ class GuiPreferencesDocuments(QWidget):
|
|||||||
self.mainForm.addGroupLabel(self.tr("Text Style"))
|
self.mainForm.addGroupLabel(self.tr("Text Style"))
|
||||||
|
|
||||||
# Font Family
|
# Font Family
|
||||||
self.textFont = QLineEdit()
|
self.textFont = QLineEdit(self)
|
||||||
self.textFont.setReadOnly(True)
|
self.textFont.setReadOnly(True)
|
||||||
self.textFont.setFixedWidth(CONFIG.pxInt(162))
|
self.textFont.setFixedWidth(CONFIG.pxInt(162))
|
||||||
self.textFont.setText(CONFIG.textFont)
|
self.textFont.setText(CONFIG.textFont)
|
||||||
self.fontButton = QPushButton("...")
|
self.fontButton = QPushButton("...", self)
|
||||||
self.fontButton.setMaximumWidth(int(2.5*SHARED.theme.getTextWidth("...")))
|
self.fontButton.setMaximumWidth(int(2.5*SHARED.theme.getTextWidth("...")))
|
||||||
self.fontButton.clicked.connect(self._selectFont)
|
self.fontButton.clicked.connect(self._selectFont)
|
||||||
self.mainForm.addRow(
|
self.mainForm.addRow(
|
||||||
@@ -960,7 +960,7 @@ class GuiPreferencesAutomation(QWidget):
|
|||||||
self.mainForm.addGroupLabel(self.tr("Automatic Padding"))
|
self.mainForm.addGroupLabel(self.tr("Automatic Padding"))
|
||||||
|
|
||||||
# Pad Before
|
# Pad Before
|
||||||
self.fmtPadBefore = QLineEdit()
|
self.fmtPadBefore = QLineEdit(self)
|
||||||
self.fmtPadBefore.setMaxLength(32)
|
self.fmtPadBefore.setMaxLength(32)
|
||||||
self.fmtPadBefore.setText(CONFIG.fmtPadBefore)
|
self.fmtPadBefore.setText(CONFIG.fmtPadBefore)
|
||||||
self.mainForm.addRow(
|
self.mainForm.addRow(
|
||||||
@@ -970,7 +970,7 @@ class GuiPreferencesAutomation(QWidget):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Pad After
|
# Pad After
|
||||||
self.fmtPadAfter = QLineEdit()
|
self.fmtPadAfter = QLineEdit(self)
|
||||||
self.fmtPadAfter.setMaxLength(32)
|
self.fmtPadAfter.setMaxLength(32)
|
||||||
self.fmtPadAfter.setText(CONFIG.fmtPadAfter)
|
self.fmtPadAfter.setText(CONFIG.fmtPadAfter)
|
||||||
self.mainForm.addRow(
|
self.mainForm.addRow(
|
||||||
@@ -1046,13 +1046,13 @@ class GuiPreferencesQuotes(QWidget):
|
|||||||
self.quoteSym = {}
|
self.quoteSym = {}
|
||||||
|
|
||||||
# Single Quote Style
|
# Single Quote Style
|
||||||
self.quoteSym["SO"] = QLineEdit()
|
self.quoteSym["SO"] = QLineEdit(self)
|
||||||
self.quoteSym["SO"].setMaxLength(1)
|
self.quoteSym["SO"].setMaxLength(1)
|
||||||
self.quoteSym["SO"].setReadOnly(True)
|
self.quoteSym["SO"].setReadOnly(True)
|
||||||
self.quoteSym["SO"].setFixedWidth(qWidth)
|
self.quoteSym["SO"].setFixedWidth(qWidth)
|
||||||
self.quoteSym["SO"].setAlignment(Qt.AlignCenter)
|
self.quoteSym["SO"].setAlignment(Qt.AlignCenter)
|
||||||
self.quoteSym["SO"].setText(CONFIG.fmtSQuoteOpen)
|
self.quoteSym["SO"].setText(CONFIG.fmtSQuoteOpen)
|
||||||
self.btnSingleStyleO = QPushButton("...")
|
self.btnSingleStyleO = QPushButton("...", self)
|
||||||
self.btnSingleStyleO.setMaximumWidth(bWidth)
|
self.btnSingleStyleO.setMaximumWidth(bWidth)
|
||||||
self.btnSingleStyleO.clicked.connect(lambda: self._getQuote("SO"))
|
self.btnSingleStyleO.clicked.connect(lambda: self._getQuote("SO"))
|
||||||
self.mainForm.addRow(
|
self.mainForm.addRow(
|
||||||
@@ -1062,13 +1062,13 @@ class GuiPreferencesQuotes(QWidget):
|
|||||||
button=self.btnSingleStyleO
|
button=self.btnSingleStyleO
|
||||||
)
|
)
|
||||||
|
|
||||||
self.quoteSym["SC"] = QLineEdit()
|
self.quoteSym["SC"] = QLineEdit(self)
|
||||||
self.quoteSym["SC"].setMaxLength(1)
|
self.quoteSym["SC"].setMaxLength(1)
|
||||||
self.quoteSym["SC"].setReadOnly(True)
|
self.quoteSym["SC"].setReadOnly(True)
|
||||||
self.quoteSym["SC"].setFixedWidth(qWidth)
|
self.quoteSym["SC"].setFixedWidth(qWidth)
|
||||||
self.quoteSym["SC"].setAlignment(Qt.AlignCenter)
|
self.quoteSym["SC"].setAlignment(Qt.AlignCenter)
|
||||||
self.quoteSym["SC"].setText(CONFIG.fmtSQuoteClose)
|
self.quoteSym["SC"].setText(CONFIG.fmtSQuoteClose)
|
||||||
self.btnSingleStyleC = QPushButton("...")
|
self.btnSingleStyleC = QPushButton("...", self)
|
||||||
self.btnSingleStyleC.setMaximumWidth(bWidth)
|
self.btnSingleStyleC.setMaximumWidth(bWidth)
|
||||||
self.btnSingleStyleC.clicked.connect(lambda: self._getQuote("SC"))
|
self.btnSingleStyleC.clicked.connect(lambda: self._getQuote("SC"))
|
||||||
self.mainForm.addRow(
|
self.mainForm.addRow(
|
||||||
@@ -1079,13 +1079,13 @@ class GuiPreferencesQuotes(QWidget):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Double Quote Style
|
# Double Quote Style
|
||||||
self.quoteSym["DO"] = QLineEdit()
|
self.quoteSym["DO"] = QLineEdit(self)
|
||||||
self.quoteSym["DO"].setMaxLength(1)
|
self.quoteSym["DO"].setMaxLength(1)
|
||||||
self.quoteSym["DO"].setReadOnly(True)
|
self.quoteSym["DO"].setReadOnly(True)
|
||||||
self.quoteSym["DO"].setFixedWidth(qWidth)
|
self.quoteSym["DO"].setFixedWidth(qWidth)
|
||||||
self.quoteSym["DO"].setAlignment(Qt.AlignCenter)
|
self.quoteSym["DO"].setAlignment(Qt.AlignCenter)
|
||||||
self.quoteSym["DO"].setText(CONFIG.fmtDQuoteOpen)
|
self.quoteSym["DO"].setText(CONFIG.fmtDQuoteOpen)
|
||||||
self.btnDoubleStyleO = QPushButton("...")
|
self.btnDoubleStyleO = QPushButton("...", self)
|
||||||
self.btnDoubleStyleO.setMaximumWidth(bWidth)
|
self.btnDoubleStyleO.setMaximumWidth(bWidth)
|
||||||
self.btnDoubleStyleO.clicked.connect(lambda: self._getQuote("DO"))
|
self.btnDoubleStyleO.clicked.connect(lambda: self._getQuote("DO"))
|
||||||
self.mainForm.addRow(
|
self.mainForm.addRow(
|
||||||
@@ -1095,13 +1095,13 @@ class GuiPreferencesQuotes(QWidget):
|
|||||||
button=self.btnDoubleStyleO
|
button=self.btnDoubleStyleO
|
||||||
)
|
)
|
||||||
|
|
||||||
self.quoteSym["DC"] = QLineEdit()
|
self.quoteSym["DC"] = QLineEdit(self)
|
||||||
self.quoteSym["DC"].setMaxLength(1)
|
self.quoteSym["DC"].setMaxLength(1)
|
||||||
self.quoteSym["DC"].setReadOnly(True)
|
self.quoteSym["DC"].setReadOnly(True)
|
||||||
self.quoteSym["DC"].setFixedWidth(qWidth)
|
self.quoteSym["DC"].setFixedWidth(qWidth)
|
||||||
self.quoteSym["DC"].setAlignment(Qt.AlignCenter)
|
self.quoteSym["DC"].setAlignment(Qt.AlignCenter)
|
||||||
self.quoteSym["DC"].setText(CONFIG.fmtDQuoteClose)
|
self.quoteSym["DC"].setText(CONFIG.fmtDQuoteClose)
|
||||||
self.btnDoubleStyleC = QPushButton("...")
|
self.btnDoubleStyleC = QPushButton("...", self)
|
||||||
self.btnDoubleStyleC.setMaximumWidth(bWidth)
|
self.btnDoubleStyleC.setMaximumWidth(bWidth)
|
||||||
self.btnDoubleStyleC.clicked.connect(lambda: self._getQuote("DC"))
|
self.btnDoubleStyleC.clicked.connect(lambda: self._getQuote("DC"))
|
||||||
self.mainForm.addRow(
|
self.mainForm.addRow(
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ from __future__ import annotations
|
|||||||
import math
|
import math
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from PyQt5.QtGui import QFont
|
from PyQt5.QtGui import QCloseEvent, QFont
|
||||||
from PyQt5.QtCore import Qt, QSize, pyqtSlot
|
from PyQt5.QtCore import Qt, QSize, pyqtSlot
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QAbstractItemView, QDialogButtonBox, QGridLayout, QHBoxLayout, QLabel,
|
QAbstractItemView, QDialogButtonBox, QGridLayout, QHBoxLayout, QLabel,
|
||||||
@@ -89,6 +89,16 @@ class GuiProjectDetails(NPagedDialog):
|
|||||||
self.tabContents.updateValues()
|
self.tabContents.updateValues()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
##
|
||||||
|
# Events
|
||||||
|
##
|
||||||
|
|
||||||
|
def closeEvent(self, event: QCloseEvent) -> None:
|
||||||
|
"""Capture the close event and perform cleanup."""
|
||||||
|
event.accept()
|
||||||
|
self.deleteLater()
|
||||||
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Private Slots
|
# Private Slots
|
||||||
##
|
##
|
||||||
@@ -98,7 +108,6 @@ class GuiProjectDetails(NPagedDialog):
|
|||||||
"""Save settings and close the dialog."""
|
"""Save settings and close the dialog."""
|
||||||
self._saveGuiSettings()
|
self._saveGuiSettings()
|
||||||
self.close()
|
self.close()
|
||||||
self.deleteLater()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
@@ -121,6 +130,7 @@ class GuiProjectDetails(NPagedDialog):
|
|||||||
countFrom = self.tabContents.poValue.value()
|
countFrom = self.tabContents.poValue.value()
|
||||||
clearDouble = self.tabContents.dblValue.isChecked()
|
clearDouble = self.tabContents.dblValue.isChecked()
|
||||||
|
|
||||||
|
logger.debug("Saving State: GuiProjectDetails")
|
||||||
pOptions = SHARED.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiProjectDetails", "winWidth", winWidth)
|
pOptions.setValue("GuiProjectDetails", "winWidth", winWidth)
|
||||||
pOptions.setValue("GuiProjectDetails", "winHeight", winHeight)
|
pOptions.setValue("GuiProjectDetails", "winHeight", winHeight)
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ class GuiProjectSettings(NPagedDialog):
|
|||||||
statusColW = CONFIG.rpxInt(self.tabStatus.listBox.columnWidth(0))
|
statusColW = CONFIG.rpxInt(self.tabStatus.listBox.columnWidth(0))
|
||||||
importColW = CONFIG.rpxInt(self.tabImport.listBox.columnWidth(0))
|
importColW = CONFIG.rpxInt(self.tabImport.listBox.columnWidth(0))
|
||||||
|
|
||||||
|
logger.debug("Saving State: GuiProjectSettings")
|
||||||
pOptions = SHARED.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiProjectSettings", "winWidth", winWidth)
|
pOptions.setValue("GuiProjectSettings", "winWidth", winWidth)
|
||||||
pOptions.setValue("GuiProjectSettings", "winHeight", winHeight)
|
pOptions.setValue("GuiProjectSettings", "winHeight", winHeight)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from PyQt5.QtGui import QFontMetrics
|
from PyQt5.QtGui import QCloseEvent, QFontMetrics
|
||||||
from PyQt5.QtCore import QSize, Qt, pyqtSlot
|
from PyQt5.QtCore import QSize, Qt, pyqtSlot
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialog, QDialogButtonBox, QFrame, QHBoxLayout, QLabel, QListWidget,
|
QDialog, QDialogButtonBox, QFrame, QHBoxLayout, QLabel, QListWidget,
|
||||||
@@ -90,8 +90,8 @@ class GuiQuoteSelect(QDialog):
|
|||||||
|
|
||||||
# Buttons
|
# Buttons
|
||||||
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
||||||
self.buttonBox.accepted.connect(self._doAccept)
|
self.buttonBox.accepted.connect(self.accept)
|
||||||
self.buttonBox.rejected.connect(self._doReject)
|
self.buttonBox.rejected.connect(self.reject)
|
||||||
|
|
||||||
# Assemble
|
# Assemble
|
||||||
self.labelBox.addWidget(self.previewLabel, 0, Qt.AlignTop)
|
self.labelBox.addWidget(self.previewLabel, 0, Qt.AlignTop)
|
||||||
@@ -113,6 +113,16 @@ class GuiQuoteSelect(QDialog):
|
|||||||
logger.debug("Delete: GuiQuoteSelect")
|
logger.debug("Delete: GuiQuoteSelect")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
##
|
||||||
|
# Events
|
||||||
|
##
|
||||||
|
|
||||||
|
def closeEvent(self, event: QCloseEvent) -> None:
|
||||||
|
"""Capture the close event and perform cleanup."""
|
||||||
|
event.accept()
|
||||||
|
self.deleteLater()
|
||||||
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Private Slots
|
# Private Slots
|
||||||
##
|
##
|
||||||
@@ -127,16 +137,4 @@ class GuiQuoteSelect(QDialog):
|
|||||||
self.selectedQuote = theSymbol
|
self.selectedQuote = theSymbol
|
||||||
return
|
return
|
||||||
|
|
||||||
@pyqtSlot()
|
|
||||||
def _doAccept(self) -> None:
|
|
||||||
"""Handle Ok button clicked."""
|
|
||||||
self.accept()
|
|
||||||
return
|
|
||||||
|
|
||||||
@pyqtSlot()
|
|
||||||
def _doReject(self) -> None:
|
|
||||||
"""Handle Cancel button clicked."""
|
|
||||||
self.reject()
|
|
||||||
return
|
|
||||||
|
|
||||||
# END Class GuiQuoteSelect
|
# END Class GuiQuoteSelect
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ from datetime import datetime
|
|||||||
from urllib.request import Request, urlopen
|
from urllib.request import Request, urlopen
|
||||||
|
|
||||||
from PyQt5.QtGui import QCloseEvent, QCursor
|
from PyQt5.QtGui import QCloseEvent, QCursor
|
||||||
from PyQt5.QtCore import Qt, pyqtSlot
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QWidget, qApp, QDialog, QHBoxLayout, QVBoxLayout, QDialogButtonBox, QLabel
|
QWidget, qApp, QDialog, QHBoxLayout, QVBoxLayout, QDialogButtonBox, QLabel
|
||||||
)
|
)
|
||||||
@@ -95,7 +95,7 @@ class GuiUpdates(QDialog):
|
|||||||
|
|
||||||
# Buttons
|
# Buttons
|
||||||
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Close)
|
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Close)
|
||||||
self.buttonBox.rejected.connect(self._doClose)
|
self.buttonBox.rejected.connect(self.close)
|
||||||
|
|
||||||
# Assemble
|
# Assemble
|
||||||
self.innerBox = QHBoxLayout()
|
self.innerBox = QHBoxLayout()
|
||||||
@@ -169,14 +169,4 @@ class GuiUpdates(QDialog):
|
|||||||
self.deleteLater()
|
self.deleteLater()
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
|
||||||
# Private Slots
|
|
||||||
##
|
|
||||||
|
|
||||||
@pyqtSlot()
|
|
||||||
def _doClose(self) -> None:
|
|
||||||
"""Close the dialog."""
|
|
||||||
self.close()
|
|
||||||
return
|
|
||||||
|
|
||||||
# END Class GuiUpdates
|
# END Class GuiUpdates
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ import logging
|
|||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt, pyqtSlot
|
||||||
|
from PyQt5.QtGui import QCloseEvent
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QAbstractItemView, QDialog, QDialogButtonBox, QHBoxLayout, QLabel,
|
QAbstractItemView, QDialog, QDialogButtonBox, QHBoxLayout, QLabel,
|
||||||
QLineEdit, QListWidget, QListWidgetItem, QPushButton, QVBoxLayout
|
QLineEdit, QListWidget, QListWidgetItem, QPushButton, QVBoxLayout
|
||||||
@@ -87,7 +88,7 @@ class GuiWordList(QDialog):
|
|||||||
|
|
||||||
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Save | QDialogButtonBox.Close)
|
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Save | QDialogButtonBox.Close)
|
||||||
self.buttonBox.accepted.connect(self._doSave)
|
self.buttonBox.accepted.connect(self._doSave)
|
||||||
self.buttonBox.rejected.connect(self._doClose)
|
self.buttonBox.rejected.connect(self.close)
|
||||||
|
|
||||||
# Assemble
|
# Assemble
|
||||||
# ========
|
# ========
|
||||||
@@ -113,9 +114,21 @@ class GuiWordList(QDialog):
|
|||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Slots
|
# Events
|
||||||
##
|
##
|
||||||
|
|
||||||
|
def closeEvent(self, event: QCloseEvent) -> None:
|
||||||
|
"""Capture the close event and perform cleanup."""
|
||||||
|
self._saveGuiSettings()
|
||||||
|
event.accept()
|
||||||
|
self.deleteLater()
|
||||||
|
return
|
||||||
|
|
||||||
|
##
|
||||||
|
# Private Slots
|
||||||
|
##
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _doAdd(self) -> None:
|
def _doAdd(self) -> None:
|
||||||
"""Add a new word to the word list."""
|
"""Add a new word to the word list."""
|
||||||
word = self.newEntry.text().strip()
|
word = self.newEntry.text().strip()
|
||||||
@@ -134,6 +147,7 @@ class GuiWordList(QDialog):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _doDelete(self) -> None:
|
def _doDelete(self) -> None:
|
||||||
"""Delete the selected item."""
|
"""Delete the selected item."""
|
||||||
selItem = self.listBox.selectedItems()
|
selItem = self.listBox.selectedItems()
|
||||||
@@ -141,9 +155,9 @@ class GuiWordList(QDialog):
|
|||||||
self.listBox.takeItem(self.listBox.row(selItem[0]))
|
self.listBox.takeItem(self.listBox.row(selItem[0]))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _doSave(self) -> None:
|
def _doSave(self) -> None:
|
||||||
"""Save the new word list and close."""
|
"""Save the new word list and close."""
|
||||||
self._saveGuiSettings()
|
|
||||||
userDict = UserDictionary(SHARED.project)
|
userDict = UserDictionary(SHARED.project)
|
||||||
for i in range(self.listBox.count()):
|
for i in range(self.listBox.count()):
|
||||||
item = self.listBox.item(i)
|
item = self.listBox.item(i)
|
||||||
@@ -152,13 +166,7 @@ class GuiWordList(QDialog):
|
|||||||
if word:
|
if word:
|
||||||
userDict.add(word)
|
userDict.add(word)
|
||||||
userDict.save()
|
userDict.save()
|
||||||
self.accept()
|
self.close()
|
||||||
return
|
|
||||||
|
|
||||||
def _doClose(self) -> None:
|
|
||||||
"""Close without saving the word list."""
|
|
||||||
self._saveGuiSettings()
|
|
||||||
self.reject()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
@@ -180,6 +188,7 @@ class GuiWordList(QDialog):
|
|||||||
winWidth = CONFIG.rpxInt(self.width())
|
winWidth = CONFIG.rpxInt(self.width())
|
||||||
winHeight = CONFIG.rpxInt(self.height())
|
winHeight = CONFIG.rpxInt(self.height())
|
||||||
|
|
||||||
|
logger.debug("Saving State: GuiWordList")
|
||||||
pOptions = SHARED.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiWordList", "winWidth", winWidth)
|
pOptions.setValue("GuiWordList", "winWidth", winWidth)
|
||||||
pOptions.setValue("GuiWordList", "winHeight", winHeight)
|
pOptions.setValue("GuiWordList", "winHeight", winHeight)
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ class GuiDocViewerPanel(QWidget):
|
|||||||
widths = {}
|
widths = {}
|
||||||
for key, tab in self.kwTabs.items():
|
for key, tab in self.kwTabs.items():
|
||||||
widths[key] = tab.getColumnWidths()
|
widths[key] = tab.getColumnWidths()
|
||||||
|
logger.debug("Saving State: GuiDocViewerPanel")
|
||||||
SHARED.project.options.setValue("GuiDocViewerPanel", "colWidths", widths)
|
SHARED.project.options.setValue("GuiDocViewerPanel", "colWidths", widths)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ class GuiNovelView(QWidget):
|
|||||||
"""Run closing project tasks."""
|
"""Run closing project tasks."""
|
||||||
lastColType = self.novelTree.lastColType
|
lastColType = self.novelTree.lastColType
|
||||||
lastColSize = self.novelTree.lastColSize
|
lastColSize = self.novelTree.lastColSize
|
||||||
|
logger.debug("Saving State: GuiNovelView")
|
||||||
pOptions = SHARED.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiNovelView", "lastCol", lastColType)
|
pOptions.setValue("GuiNovelView", "lastCol", lastColType)
|
||||||
pOptions.setValue("GuiNovelView", "lastColSize", lastColSize)
|
pOptions.setValue("GuiNovelView", "lastColSize", lastColSize)
|
||||||
|
|||||||
@@ -606,6 +606,7 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
logHidden, orgWidth if logHidden and logWidth == 0 else logWidth
|
logHidden, orgWidth if logHidden and logWidth == 0 else logWidth
|
||||||
]
|
]
|
||||||
|
|
||||||
|
logger.debug("Saving State: GuiOutline")
|
||||||
pOptions = SHARED.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiOutline", "columnState", colState)
|
pOptions.setValue("GuiOutline", "columnState", colState)
|
||||||
pOptions.saveSettings()
|
pOptions.saveSettings()
|
||||||
|
|||||||
@@ -344,8 +344,6 @@ class GuiManuscriptBuild(QDialog):
|
|||||||
|
|
||||||
def _saveSettings(self):
|
def _saveSettings(self):
|
||||||
"""Save the user GUI settings."""
|
"""Save the user GUI settings."""
|
||||||
logger.debug("Saving GuiManuscriptBuild settings")
|
|
||||||
|
|
||||||
winWidth = CONFIG.rpxInt(self.width())
|
winWidth = CONFIG.rpxInt(self.width())
|
||||||
winHeight = CONFIG.rpxInt(self.height())
|
winHeight = CONFIG.rpxInt(self.height())
|
||||||
|
|
||||||
@@ -353,6 +351,7 @@ class GuiManuscriptBuild(QDialog):
|
|||||||
fmtWidth = CONFIG.rpxInt(mainSplit[0])
|
fmtWidth = CONFIG.rpxInt(mainSplit[0])
|
||||||
sumWidth = CONFIG.rpxInt(mainSplit[1])
|
sumWidth = CONFIG.rpxInt(mainSplit[1])
|
||||||
|
|
||||||
|
logger.debug("Saving State: GuiManuscriptBuild")
|
||||||
pOptions = SHARED.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiManuscriptBuild", "winWidth", winWidth)
|
pOptions.setValue("GuiManuscriptBuild", "winWidth", winWidth)
|
||||||
pOptions.setValue("GuiManuscriptBuild", "winHeight", winHeight)
|
pOptions.setValue("GuiManuscriptBuild", "winHeight", winHeight)
|
||||||
|
|||||||
@@ -417,8 +417,6 @@ class GuiManuscript(QDialog):
|
|||||||
|
|
||||||
def _saveSettings(self):
|
def _saveSettings(self):
|
||||||
"""Save the user GUI settings."""
|
"""Save the user GUI settings."""
|
||||||
logger.debug("Saving GuiManuscript settings")
|
|
||||||
|
|
||||||
buildOrder = []
|
buildOrder = []
|
||||||
for i in range(self.buildList.count()):
|
for i in range(self.buildList.count()):
|
||||||
if item := self.buildList.item(i):
|
if item := self.buildList.item(i):
|
||||||
@@ -442,6 +440,7 @@ class GuiManuscript(QDialog):
|
|||||||
detailsWidth = CONFIG.rpxInt(self.buildDetails.getColumnWidth())
|
detailsWidth = CONFIG.rpxInt(self.buildDetails.getColumnWidth())
|
||||||
detailsExpanded = self.buildDetails.getExpandedState()
|
detailsExpanded = self.buildDetails.getExpandedState()
|
||||||
|
|
||||||
|
logger.debug("Saving State: GuiManuscript")
|
||||||
pOptions = SHARED.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiManuscript", "winWidth", winWidth)
|
pOptions.setValue("GuiManuscript", "winWidth", winWidth)
|
||||||
pOptions.setValue("GuiManuscript", "winHeight", winHeight)
|
pOptions.setValue("GuiManuscript", "winHeight", winHeight)
|
||||||
|
|||||||
@@ -253,13 +253,11 @@ class GuiBuildSettings(QDialog):
|
|||||||
|
|
||||||
def _saveSettings(self) -> None:
|
def _saveSettings(self) -> None:
|
||||||
"""Save the various user settings."""
|
"""Save the various user settings."""
|
||||||
logger.debug("Saving GuiBuildSettings settings")
|
|
||||||
|
|
||||||
winWidth = CONFIG.rpxInt(self.width())
|
winWidth = CONFIG.rpxInt(self.width())
|
||||||
winHeight = CONFIG.rpxInt(self.height())
|
winHeight = CONFIG.rpxInt(self.height())
|
||||||
|
|
||||||
treeWidth, filterWidth = self.optTabSelect.mainSplitSizes()
|
treeWidth, filterWidth = self.optTabSelect.mainSplitSizes()
|
||||||
|
|
||||||
|
logger.debug("Saving State: GuiBuildSettings")
|
||||||
pOptions = SHARED.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiBuildSettings", "winWidth", winWidth)
|
pOptions.setValue("GuiBuildSettings", "winWidth", winWidth)
|
||||||
pOptions.setValue("GuiBuildSettings", "winHeight", winHeight)
|
pOptions.setValue("GuiBuildSettings", "winHeight", winHeight)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import logging
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from PyQt5.QtGui import QPixmap, QCursor
|
from PyQt5.QtGui import QCloseEvent, QPixmap, QCursor
|
||||||
from PyQt5.QtCore import Qt, pyqtSlot
|
from PyQt5.QtCore import Qt, pyqtSlot
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
qApp, QDialog, QTreeWidget, QTreeWidgetItem, QDialogButtonBox, QGridLayout,
|
qApp, QDialog, QTreeWidget, QTreeWidgetItem, QDialogButtonBox, QGridLayout,
|
||||||
@@ -307,9 +307,20 @@ class GuiWritingStats(QDialog):
|
|||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Slots
|
# Events
|
||||||
##
|
##
|
||||||
|
|
||||||
|
def closeEvent(self, event: QCloseEvent) -> None:
|
||||||
|
"""Capture the user closing the window."""
|
||||||
|
event.accept()
|
||||||
|
self.deleteLater()
|
||||||
|
return
|
||||||
|
|
||||||
|
##
|
||||||
|
# Private Slots
|
||||||
|
##
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _doClose(self) -> None:
|
def _doClose(self) -> None:
|
||||||
"""Save the state of the window, clear cache, end close."""
|
"""Save the state of the window, clear cache, end close."""
|
||||||
self.logData = []
|
self.logData = []
|
||||||
@@ -330,6 +341,7 @@ class GuiWritingStats(QDialog):
|
|||||||
showIdleTime = self.showIdleTime.isChecked()
|
showIdleTime = self.showIdleTime.isChecked()
|
||||||
histMax = self.histMax.value()
|
histMax = self.histMax.value()
|
||||||
|
|
||||||
|
logger.debug("Saving State: GuiWritingStats")
|
||||||
pOptions = SHARED.project.options
|
pOptions = SHARED.project.options
|
||||||
pOptions.setValue("GuiWritingStats", "winWidth", winWidth)
|
pOptions.setValue("GuiWritingStats", "winWidth", winWidth)
|
||||||
pOptions.setValue("GuiWritingStats", "winHeight", winHeight)
|
pOptions.setValue("GuiWritingStats", "winHeight", winHeight)
|
||||||
@@ -347,6 +359,7 @@ class GuiWritingStats(QDialog):
|
|||||||
pOptions.setValue("GuiWritingStats", "showIdleTime", showIdleTime)
|
pOptions.setValue("GuiWritingStats", "showIdleTime", showIdleTime)
|
||||||
pOptions.setValue("GuiWritingStats", "histMax", histMax)
|
pOptions.setValue("GuiWritingStats", "histMax", histMax)
|
||||||
pOptions.saveSettings()
|
pOptions.saveSettings()
|
||||||
|
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -56,14 +56,7 @@ def testDlgAbout_NWDialog(qtbot, monkeypatch, nwGUI):
|
|||||||
|
|
||||||
msgAbout.showReleaseNotes()
|
msgAbout.showReleaseNotes()
|
||||||
assert msgAbout.tabBox.currentWidget() == msgAbout.pageNotes
|
assert msgAbout.tabBox.currentWidget() == msgAbout.pageNotes
|
||||||
msgAbout._doClose()
|
msgAbout.close()
|
||||||
|
|
||||||
# Open Again from Menu
|
|
||||||
nwGUI.mainMenu.aAboutNW.activate(QAction.Trigger)
|
|
||||||
qtbot.waitUntil(lambda: getGuiItem("GuiAbout") is not None, timeout=1000)
|
|
||||||
msgAbout = getGuiItem("GuiAbout")
|
|
||||||
assert msgAbout is not None
|
|
||||||
msgAbout._doClose()
|
|
||||||
|
|
||||||
# END Test testDlgAbout_NWDialog
|
# END Test testDlgAbout_NWDialog
|
||||||
|
|
||||||
|
|||||||
@@ -45,12 +45,11 @@ def testDlgOther_QuoteSelect(qtbot, nwGUI):
|
|||||||
lastItem = anItem.text()[2]
|
lastItem = anItem.text()[2]
|
||||||
assert nwQuot.previewLabel.text() == lastItem
|
assert nwQuot.previewLabel.text() == lastItem
|
||||||
|
|
||||||
nwQuot._doAccept()
|
nwQuot.accept()
|
||||||
assert nwQuot.result() == QDialog.Accepted
|
assert nwQuot.result() == QDialog.Accepted
|
||||||
assert nwQuot.selectedQuote == lastItem
|
assert nwQuot.selectedQuote == lastItem
|
||||||
|
|
||||||
# qtbot.stop()
|
# qtbot.stop()
|
||||||
nwQuot._doReject()
|
|
||||||
nwQuot.close()
|
nwQuot.close()
|
||||||
|
|
||||||
# END Test testDlgOther_QuoteSelect
|
# END Test testDlgOther_QuoteSelect
|
||||||
@@ -89,7 +88,7 @@ def testDlgOther_Updates(qtbot, monkeypatch, nwGUI):
|
|||||||
nwGUI.mainMenu.aUpdates.activate(QAction.Trigger)
|
nwGUI.mainMenu.aUpdates.activate(QAction.Trigger)
|
||||||
|
|
||||||
# qtbot.stop()
|
# qtbot.stop()
|
||||||
nwUpdate._doClose()
|
nwUpdate.close()
|
||||||
|
|
||||||
# END Test testDlgOther_Updates
|
# END Test testDlgOther_Updates
|
||||||
|
|
||||||
@@ -101,13 +100,13 @@ def testDlgOther_EditLabel(qtbot, monkeypatch):
|
|||||||
|
|
||||||
with monkeypatch.context() as mp:
|
with monkeypatch.context() as mp:
|
||||||
mp.setattr(GuiEditLabel, "result", lambda *a: QDialog.Accepted)
|
mp.setattr(GuiEditLabel, "result", lambda *a: QDialog.Accepted)
|
||||||
newLabel, dlgOk = GuiEditLabel.getLabel(None, text="Hello World")
|
newLabel, dlgOk = GuiEditLabel.getLabel(None, text="Hello World") # type: ignore
|
||||||
assert dlgOk is True
|
assert dlgOk is True
|
||||||
assert newLabel == "Hello World"
|
assert newLabel == "Hello World"
|
||||||
|
|
||||||
with monkeypatch.context() as mp:
|
with monkeypatch.context() as mp:
|
||||||
mp.setattr(GuiEditLabel, "result", lambda *a: QDialog.Rejected)
|
mp.setattr(GuiEditLabel, "result", lambda *a: QDialog.Rejected)
|
||||||
newLabel, dlgOk = GuiEditLabel.getLabel(None, text="Hello World")
|
newLabel, dlgOk = GuiEditLabel.getLabel(None, text="Hello World") # type: ignore
|
||||||
assert dlgOk is False
|
assert dlgOk is False
|
||||||
assert newLabel == "Hello World"
|
assert newLabel == "Hello World"
|
||||||
|
|
||||||
|
|||||||
@@ -68,11 +68,11 @@ def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, projPath):
|
|||||||
wList._loadWordList()
|
wList._loadWordList()
|
||||||
|
|
||||||
# Check that the content was loaded
|
# Check that the content was loaded
|
||||||
assert wList.listBox.item(0).text() == "word_a"
|
assert wList.listBox.item(0).text() == "word_a" # type: ignore
|
||||||
assert wList.listBox.item(1).text() == "word_b"
|
assert wList.listBox.item(1).text() == "word_b" # type: ignore
|
||||||
assert wList.listBox.item(2).text() == "word_c"
|
assert wList.listBox.item(2).text() == "word_c" # type: ignore
|
||||||
assert wList.listBox.item(3).text() == "word_f"
|
assert wList.listBox.item(3).text() == "word_f" # type: ignore
|
||||||
assert wList.listBox.item(4).text() == "word_g"
|
assert wList.listBox.item(4).text() == "word_g" # type: ignore
|
||||||
assert wList.listBox.count() == 5
|
assert wList.listBox.count() == 5
|
||||||
|
|
||||||
# Add a blank word, which is ignored
|
# Add a blank word, which is ignored
|
||||||
@@ -91,24 +91,24 @@ def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, projPath):
|
|||||||
assert wList.listBox.count() == 6
|
assert wList.listBox.count() == 6
|
||||||
|
|
||||||
# Check that the content now
|
# Check that the content now
|
||||||
assert wList.listBox.item(0).text() == "word_a"
|
assert wList.listBox.item(0).text() == "word_a" # type: ignore
|
||||||
assert wList.listBox.item(1).text() == "word_b"
|
assert wList.listBox.item(1).text() == "word_b" # type: ignore
|
||||||
assert wList.listBox.item(2).text() == "word_c"
|
assert wList.listBox.item(2).text() == "word_c" # type: ignore
|
||||||
assert wList.listBox.item(3).text() == "word_d"
|
assert wList.listBox.item(3).text() == "word_d" # type: ignore
|
||||||
assert wList.listBox.item(4).text() == "word_f"
|
assert wList.listBox.item(4).text() == "word_f" # type: ignore
|
||||||
assert wList.listBox.item(5).text() == "word_g"
|
assert wList.listBox.item(5).text() == "word_g" # type: ignore
|
||||||
|
|
||||||
# Delete a word
|
# Delete a word
|
||||||
wList.newEntry.setText("delete_me")
|
wList.newEntry.setText("delete_me")
|
||||||
wList._doAdd()
|
wList._doAdd()
|
||||||
assert wList.listBox.item(0).text() == "delete_me"
|
assert wList.listBox.item(0).text() == "delete_me" # type: ignore
|
||||||
|
|
||||||
delItem = wList.listBox.findItems("delete_me", Qt.MatchExactly)[0]
|
delItem = wList.listBox.findItems("delete_me", Qt.MatchExactly)[0]
|
||||||
assert delItem.text() == "delete_me"
|
assert delItem.text() == "delete_me"
|
||||||
delItem.setSelected(True)
|
delItem.setSelected(True)
|
||||||
wList._doDelete()
|
wList._doDelete()
|
||||||
assert wList.listBox.findItems("delete_me", Qt.MatchExactly) == []
|
assert wList.listBox.findItems("delete_me", Qt.MatchExactly) == []
|
||||||
assert wList.listBox.item(0).text() == "word_a"
|
assert wList.listBox.item(0).text() == "word_a" # type: ignore
|
||||||
|
|
||||||
# Save files
|
# Save files
|
||||||
wList._doSave()
|
wList._doSave()
|
||||||
@@ -122,6 +122,6 @@ def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, projPath):
|
|||||||
assert "word_g" in userDict
|
assert "word_g" in userDict
|
||||||
|
|
||||||
# qtbot.stop()
|
# qtbot.stop()
|
||||||
wList._doClose()
|
wList.close()
|
||||||
|
|
||||||
# END Test testDlgWordList_Dialog
|
# END Test testDlgWordList_Dialog
|
||||||
|
|||||||
Reference in New Issue
Block a user