Skip to content

Commit

Permalink
🎉 Remove exit prompt when all is saved
Browse files Browse the repository at this point in the history
  • Loading branch information
FabienRoger committed Feb 16, 2022
1 parent a981f77 commit 2532e7f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pyflow/graphics/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,13 +453,24 @@ def onEditRun(self):
if len(selected_blocks) == 1:
selected_blocks[0].run_left()

def allWidgetsAreSaved(self):
"""Return true if all widgets are saved."""

for widget in self.mdiArea.subWindowList():
if isinstance(widget.widget(), Widget):
if widget.widget().isModified():
return False

return True

def closeEvent(self, event: QCloseEvent):
"""Handle the event when the window is about to be closed."""

if self.never_show_exit_prompt:
if self.allWidgetsAreSaved() or self.never_show_exit_prompt:
self.closeWindow(event)
return

# Show the exit without saving prompt
quit_msg = "Exit without saving?"
msgbox = QMessageBox(self)
msgbox.setText(quit_msg)
Expand All @@ -472,6 +483,7 @@ def closeEvent(self, event: QCloseEvent):

if msgbox.checkBox().checkState() == Qt.CheckState.Checked:
self.never_show_exit_prompt = True
self.writeSettings()

if msgbox.result() == int(str(QMessageBox.No)):
event.ignore()
Expand Down

0 comments on commit 2532e7f

Please sign in to comment.