def closeEvent(self, event: QCloseEvent) -> None: """Called on closing window.""" if self.should_close_document(self.tr("Quit")): gp.dump_prefs(self.pref) event.accept() else: event.ignore()
def closeEvent(self, event: QCloseEvent) -> None: """Close event to avoid user close the window accidentally.""" if self.check_file_changed(): event.ignore() return if self.inputs_widget.inputs_play_shaft.isActive(): self.inputs_widget.inputs_play_shaft.stop() self.save_settings() XStream.back() logger.info("Exit") event.accept()
def closeEvent(self, event: QtGui.QCloseEvent): if chisurf.settings.gui['confirm_close_program']: reply = chisurf.widgets.widgets.MyMessageBox.question( self, 'Message', "Are you sure to quit?", QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No) if reply == QtWidgets.QMessageBox.Yes: event.accept() else: event.ignore() else: event.accept()
def about_to_close(self, event: QCloseEvent) -> None: self.log.debug("About to close requested") if not self.model.is_set: self.model.on_close() self.log.debug("No project set; closing") event.accept() return name = self.model.path.name if not self.model.is_stale: self.model.on_close() self.log.debug(f"Project {name} has no changes; closing") event.accept() return response = showSaveDialog( parent=self._window, title="About to close", text=f"You have unsaved changes pending for project {name}.\n" "Do you want to save your changes?", ) if response == QMessageBox.Save: self.model.save() self.model.on_close() self.log.debug(f"Project {name} saved; closing") event.accept() elif response == QMessageBox.Discard: self.model.on_close() self.log.debug(f"Project {name} not saved; closing") event.accept() elif response == QMessageBox.Cancel: self.log.debug(f"Project {name} not saved; not closing") event.ignore() else: raise RuntimeError(f"Unknown response {response}")
def closeEvent(self, event: QCloseEvent): if self.__cancel_check(): event.accept() else: event.ignore()