Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Set ModernWindow to set the event state equal to the child state #24

Merged
merged 2 commits into from
Nov 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions qtmodern/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ def __init__(self, w, parent=None):
self.setWindowTitle(w.windowTitle())
self.setGeometry(w.geometry())

self.installEventFilter(self)

# Adding attribute to clean up the parent window when the child is closed
self._w.setAttribute(Qt.WA_DeleteOnClose, True)
self._w.destroyed.connect(self.__child_was_closed)
Expand Down Expand Up @@ -146,13 +144,12 @@ def __child_was_closed(self):
self._w = None # The child was deleted, remove the reference to it and close the parent window
self.close()

def eventFilter(self, source, event):
if event.type() == QEvent.Close:
if not self._w:
return True
return self._w.close()

return QWidget.eventFilter(self, source, event)
def closeEvent(self, event):
if not self._w:
event.accept()
else:
self._w.close()
event.setAccepted(self._w.isHidden())
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isHidden seems to be the most reliable way to figure out if a window is closed or not


def setWindowTitle(self, title):
""" Set window title.
Expand Down