Add closeEvents to dialogs and set the deleteLater command
This commit is contained in:
@@ -344,8 +344,6 @@ class GuiManuscriptBuild(QDialog):
|
||||
|
||||
def _saveSettings(self):
|
||||
"""Save the user GUI settings."""
|
||||
logger.debug("Saving GuiManuscriptBuild settings")
|
||||
|
||||
winWidth = CONFIG.rpxInt(self.width())
|
||||
winHeight = CONFIG.rpxInt(self.height())
|
||||
|
||||
@@ -353,6 +351,7 @@ class GuiManuscriptBuild(QDialog):
|
||||
fmtWidth = CONFIG.rpxInt(mainSplit[0])
|
||||
sumWidth = CONFIG.rpxInt(mainSplit[1])
|
||||
|
||||
logger.debug("Saving State: GuiManuscriptBuild")
|
||||
pOptions = SHARED.project.options
|
||||
pOptions.setValue("GuiManuscriptBuild", "winWidth", winWidth)
|
||||
pOptions.setValue("GuiManuscriptBuild", "winHeight", winHeight)
|
||||
|
||||
@@ -417,8 +417,6 @@ class GuiManuscript(QDialog):
|
||||
|
||||
def _saveSettings(self):
|
||||
"""Save the user GUI settings."""
|
||||
logger.debug("Saving GuiManuscript settings")
|
||||
|
||||
buildOrder = []
|
||||
for i in range(self.buildList.count()):
|
||||
if item := self.buildList.item(i):
|
||||
@@ -442,6 +440,7 @@ class GuiManuscript(QDialog):
|
||||
detailsWidth = CONFIG.rpxInt(self.buildDetails.getColumnWidth())
|
||||
detailsExpanded = self.buildDetails.getExpandedState()
|
||||
|
||||
logger.debug("Saving State: GuiManuscript")
|
||||
pOptions = SHARED.project.options
|
||||
pOptions.setValue("GuiManuscript", "winWidth", winWidth)
|
||||
pOptions.setValue("GuiManuscript", "winHeight", winHeight)
|
||||
|
||||
@@ -253,13 +253,11 @@ class GuiBuildSettings(QDialog):
|
||||
|
||||
def _saveSettings(self) -> None:
|
||||
"""Save the various user settings."""
|
||||
logger.debug("Saving GuiBuildSettings settings")
|
||||
|
||||
winWidth = CONFIG.rpxInt(self.width())
|
||||
winHeight = CONFIG.rpxInt(self.height())
|
||||
|
||||
treeWidth, filterWidth = self.optTabSelect.mainSplitSizes()
|
||||
|
||||
logger.debug("Saving State: GuiBuildSettings")
|
||||
pOptions = SHARED.project.options
|
||||
pOptions.setValue("GuiBuildSettings", "winWidth", winWidth)
|
||||
pOptions.setValue("GuiBuildSettings", "winHeight", winHeight)
|
||||
|
||||
@@ -29,7 +29,7 @@ import logging
|
||||
from datetime import datetime
|
||||
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.QtWidgets import (
|
||||
qApp, QDialog, QTreeWidget, QTreeWidgetItem, QDialogButtonBox, QGridLayout,
|
||||
@@ -307,9 +307,20 @@ class GuiWritingStats(QDialog):
|
||||
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:
|
||||
"""Save the state of the window, clear cache, end close."""
|
||||
self.logData = []
|
||||
@@ -330,6 +341,7 @@ class GuiWritingStats(QDialog):
|
||||
showIdleTime = self.showIdleTime.isChecked()
|
||||
histMax = self.histMax.value()
|
||||
|
||||
logger.debug("Saving State: GuiWritingStats")
|
||||
pOptions = SHARED.project.options
|
||||
pOptions.setValue("GuiWritingStats", "winWidth", winWidth)
|
||||
pOptions.setValue("GuiWritingStats", "winHeight", winHeight)
|
||||
@@ -347,6 +359,7 @@ class GuiWritingStats(QDialog):
|
||||
pOptions.setValue("GuiWritingStats", "showIdleTime", showIdleTime)
|
||||
pOptions.setValue("GuiWritingStats", "histMax", histMax)
|
||||
pOptions.saveSettings()
|
||||
|
||||
self.close()
|
||||
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user