diff --git a/src/core/settings.py b/src/core/settings.py index 761b536..958f198 100644 --- a/src/core/settings.py +++ b/src/core/settings.py @@ -262,9 +262,15 @@ def open_settings_dialog(main_window, settings, themes, current_theme) -> None: # Change window title settingsDialog.setWindowTitle("Settings") + settingsDialog.setModal(True) + + # Ensure that the dialog is deleted when it is closed + settingsDialog.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose) # Inherit the theme from the main window settingsDialog.setStyleSheet(main_window.customStyleSheet) + + # Connect the styleSheetUpdated signal to the settingsDialog's setStyleSheet method main_window.styleSheetUpdated.connect(settingsDialog.setStyleSheet) # Load settings and themes to the dialog @@ -288,7 +294,8 @@ def open_settings_dialog(main_window, settings, themes, current_theme) -> None: main_window, uiSettings, settings, themes, current_theme ) ) - settingsDialog.exec() + settingsDialog.exec_() + logger.info("Settings dialog closed.") @logger.catch diff --git a/src/core/videoeditor.py b/src/core/videoeditor.py index 0a01d02..de72d37 100644 --- a/src/core/videoeditor.py +++ b/src/core/videoeditor.py @@ -1,4 +1,4 @@ -from PySide6.QtWidgets import QMainWindow, QWidget, QSizePolicy +from PySide6.QtWidgets import QMainWindow, QWidget, QSizePolicy, QApplication from PySide6.QtGui import QAction from PySide6.QtCore import Signal, Qt @@ -28,7 +28,7 @@ class VideoEditorWindow(QMainWindow): def __init__(self, parent=None): """Initializer""" super().__init__(parent) - + self.isSettingsDialogOpen = False self.central_widget = QWidget(self) self.ui = Ui_VideoEditor() self.ui.setupUi(self.central_widget) @@ -80,5 +80,23 @@ def create_menubar(self): @logger.catch def open_settings(self): """Open the settings dialog.""" - + self.isSettingsDialogOpen = True + logger.info("Opening settings dialog.") open_settings_dialog(self, self.settings, self.themes, self.current_theme) + logger.info("Settings dialog closed.") + QApplication.processEvents() + self.isSettingsDialogOpen = False + + @logger.catch + def closeEvent(self, event): + logger.info( + f"Close event triggered with isSettingsDialogOpen={self.isSettingsDialogOpen}" + ) + if self.isSettingsDialogOpen: + logger.info("Ignoring close event due to settings dialog being open.") + event.ignore() + else: + logger.info("Proceeding with application quit.") + app_instance = QApplication.instance() + if app_instance: + app_instance.quit()