Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
fix!: fixed videoeditor close event problem
Browse files Browse the repository at this point in the history
  • Loading branch information
MemerGamer committed Mar 10, 2024
1 parent 85c8dae commit 20295bd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
24 changes: 21 additions & 3 deletions src/core/videoeditor.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()

0 comments on commit 20295bd

Please sign in to comment.