Modified the EricMessageBox okToClearData() function for more flexibility. eric7

Mon, 13 Feb 2023 17:51:03 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 13 Feb 2023 17:51:03 +0100
branch
eric7
changeset 9757
ab6e87f6f1c4
parent 9756
9854647c8c5c
child 9758
6d24ab9c0404

Modified the EricMessageBox okToClearData() function for more flexibility.

src/eric7/Documentation/Source/eric7.EricWidgets.EricMessageBox.html file | annotate | diff | comparison | revisions
src/eric7/EricWidgets/EricMessageBox.py file | annotate | diff | comparison | revisions
--- a/src/eric7/Documentation/Source/eric7.EricWidgets.EricMessageBox.html	Mon Feb 13 17:49:52 2023 +0100
+++ b/src/eric7/Documentation/Source/eric7.EricWidgets.EricMessageBox.html	Mon Feb 13 17:51:03 2023 +0100
@@ -43,7 +43,7 @@
 </tr>
 <tr>
 <td><a href="#okToClearData">okToClearData</a></td>
-<td>Function to show a model message box to ask for clearing the data.</td>
+<td>Function to show a modal message box to ask for clearing the data.</td>
 </tr>
 <tr>
 <td><a href="#question">question</a></td>
@@ -270,7 +270,7 @@
 <b>okToClearData</b>(<i>parent, title, text, saveFunc, textFormat=Qt.TextFormat.AutoText</i>)
 
 <p>
-    Function to show a model message box to ask for clearing the data.
+    Function to show a modal message box to ask for clearing the data.
 </p>
 <dl>
 
--- a/src/eric7/EricWidgets/EricMessageBox.py	Mon Feb 13 17:49:52 2023 +0100
+++ b/src/eric7/EricWidgets/EricMessageBox.py	Mon Feb 13 17:51:03 2023 +0100
@@ -325,7 +325,7 @@
 
 def okToClearData(parent, title, text, saveFunc, textFormat=Qt.TextFormat.AutoText):
     """
-    Function to show a model message box to ask for clearing the data.
+    Function to show a modal message box to ask for clearing the data.
 
     @param parent parent widget of the message box (QWidget)
     @param title caption of the message box (string)
@@ -335,16 +335,15 @@
     @param textFormat format of the text (Qt.TextFormat)
     @return flag indicating that it is ok to clear the data (boolean)
     """
+    buttons = QMessageBox.StandardButton.Abort | QMessageBox.StandardButton.Discard
+    if saveFunc:
+        buttons |= QMessageBox.StandardButton.Save
     res = __messageBox(
         parent,
         title,
         text,
         QMessageBox.Icon.Warning,
-        (
-            QMessageBox.StandardButton.Abort
-            | QMessageBox.StandardButton.Discard
-            | QMessageBox.StandardButton.Save
-        ),
+        buttons,
         QMessageBox.StandardButton.Save,
         textFormat,
     )

eric ide

mercurial