Make sure build settings are closed before deletion
This commit is contained in:
@@ -30,9 +30,9 @@ from datetime import datetime
|
|||||||
from time import time
|
from time import time
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from PyQt5.QtCore import QTimer, QUrl, Qt, pyqtSignal, pyqtSlot
|
from PyQt5.QtCore import Qt, QTimer, QUrl, pyqtSignal, pyqtSlot
|
||||||
from PyQt5.QtGui import QCloseEvent, QColor, QCursor, QFont, QPalette, QResizeEvent
|
from PyQt5.QtGui import QCloseEvent, QColor, QCursor, QFont, QPalette, QResizeEvent
|
||||||
from PyQt5.QtPrintSupport import QPrintPreviewDialog, QPrinter
|
from PyQt5.QtPrintSupport import QPrinter, QPrintPreviewDialog
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QAbstractItemView, QApplication, QDialog, QFormLayout, QGridLayout,
|
QAbstractItemView, QApplication, QDialog, QFormLayout, QGridLayout,
|
||||||
QHBoxLayout, QLabel, QListWidget, QListWidgetItem, QPushButton,
|
QHBoxLayout, QLabel, QListWidget, QListWidgetItem, QPushButton,
|
||||||
@@ -319,6 +319,8 @@ class GuiManuscript(QDialog):
|
|||||||
"""Delete the currently selected build settings entry."""
|
"""Delete the currently selected build settings entry."""
|
||||||
if build := self._getSelectedBuild():
|
if build := self._getSelectedBuild():
|
||||||
if SHARED.question(self.tr("Delete build '{0}'?".format(build.name))):
|
if SHARED.question(self.tr("Delete build '{0}'?".format(build.name))):
|
||||||
|
if dialog := self._findSettingsDialog(build.buildID):
|
||||||
|
dialog.close()
|
||||||
self._builds.removeBuild(build.buildID)
|
self._builds.removeBuild(build.buildID)
|
||||||
self._updateBuildsList()
|
self._updateBuildsList()
|
||||||
return
|
return
|
||||||
@@ -467,14 +469,10 @@ class GuiManuscript(QDialog):
|
|||||||
|
|
||||||
def _openSettingsDialog(self, build: BuildSettings) -> None:
|
def _openSettingsDialog(self, build: BuildSettings) -> None:
|
||||||
"""Open the build settings dialog."""
|
"""Open the build settings dialog."""
|
||||||
for obj in self.mainGui.children():
|
if dialog := self._findSettingsDialog(build.buildID):
|
||||||
# Don't open a second dialog if one exists
|
dialog.show()
|
||||||
if isinstance(obj, GuiBuildSettings):
|
dialog.raise_()
|
||||||
if obj.buildID == build.buildID:
|
return
|
||||||
logger.debug("Found instance of GuiBuildSettings")
|
|
||||||
obj.show()
|
|
||||||
obj.raise_()
|
|
||||||
return
|
|
||||||
|
|
||||||
dlgSettings = GuiBuildSettings(self.mainGui, build)
|
dlgSettings = GuiBuildSettings(self.mainGui, build)
|
||||||
dlgSettings.setModal(False)
|
dlgSettings.setModal(False)
|
||||||
@@ -507,6 +505,15 @@ class GuiManuscript(QDialog):
|
|||||||
self._updateBuildsList()
|
self._updateBuildsList()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def _findSettingsDialog(self, buildID: str) -> GuiBuildSettings | None:
|
||||||
|
"""Return an open build settings dialog for a given build, if
|
||||||
|
one exists.
|
||||||
|
"""
|
||||||
|
for obj in SHARED.mainGui.children():
|
||||||
|
if isinstance(obj, GuiBuildSettings) and obj.buildID == buildID:
|
||||||
|
return obj
|
||||||
|
return None
|
||||||
|
|
||||||
# END Class GuiManuscript
|
# END Class GuiManuscript
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user