def unsaved_files_dialog(<EOL>self, all_files=False, with_cancel=True, with_discard=True):
for image in self.images:<EOL><INDENT>if image.metadata.changed() and (all_files or image.selected):<EOL><INDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return True<EOL><DEDENT>dialog = QtWidgets.QMessageBox()<EOL>dialog.setWindowTitle(self.tr('<STR_LIT>'))<EOL>dialog.setText(self.tr('<STR_LIT>'))<EOL>dialog.setInformativeText(self.tr('<STR_LIT>'))<EOL>dialog.setIcon(QtWidgets.QMessageBox.Warning)<EOL>buttons = QtWidgets.QMessageBox.Save<EOL>if with_cancel:<EOL><INDENT>buttons |= QtWidgets.QMessageBox.Cancel<EOL><DEDENT>if with_discard:<EOL><INDENT>buttons |= QtWidgets.QMessageBox.Discard<EOL><DEDENT>dialog.setStandardButtons(buttons)<EOL>dialog.setDefaultButton(QtWidgets.QMessageBox.Save)<EOL>result = dialog.exec_()<EOL>if result == QtWidgets.QMessageBox.Save:<EOL><INDENT>self._save_files()<EOL>return True<EOL><DEDENT>return result == QtWidgets.QMessageBox.Discard<EOL>
Return true if OK to continue with close or quit or whatever