Continued replacing QMessageBox.

Fri, 03 Sep 2010 13:48:52 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 03 Sep 2010 13:48:52 +0200
changeset 550
22b951013193
parent 549
fe99d46d56c8
child 551
e1074b63ff08

Continued replacing QMessageBox.

E5Gui/E5MessageBox.py file | annotate | diff | comparison | revisions
UI/EmailDialog.py file | annotate | diff | comparison | revisions
--- a/E5Gui/E5MessageBox.py	Fri Sep 03 13:39:08 2010 +0200
+++ b/E5Gui/E5MessageBox.py	Fri Sep 03 13:48:52 2010 +0200
@@ -151,6 +151,32 @@
                        yesDefault and QMessageBox.Yes or QMessageBox.No)
     return res == QMessageBox.Yes
 
+def retryAbort(parent, title, text, type_ = Question):
+    """
+    Function to show a model abort/retry message box.
+    
+    @param parent parent widget of the message box (QWidget)
+    @param title caption of the message box (string)
+    @param text text to be shown by the message box (string)
+    @keyparam type_ type of the dialog (Critical, Information, Question or Warning)
+    @return flag indicating the selection of the Retry button (boolean)
+    """
+    assert type_ in [Critical, Information, Question, Warning]
+    
+    if type_ == Question:
+        icon = QMessageBox.Question
+    elif type_ == Warning:
+        icon = QMessageBox.Warning
+    elif type_ == Critical:        
+        icon = QMessageBox.Critical
+    elif type_ == Information:
+        icon = QMessageBox.Information
+    
+    res = __messageBox(parent, title, text, icon, 
+                    QMessageBox.StandardButtons(QMessageBox.Retry | QMessageBox.Abort), 
+                    QMessageBox.Retry)
+    return res == QMessageBox.Retry
+
 def okToClearData(parent, title, text, saveFunc):
     """
     Function to show a model message box to ask for clearing the data.
--- a/UI/EmailDialog.py	Fri Sep 03 13:39:08 2010 +0200
+++ b/UI/EmailDialog.py	Fri Sep 03 13:48:52 2010 +0200
@@ -282,15 +282,12 @@
                     server.login(Preferences.getUser("MailServerUser"),
                                  password)
                 except (smtplib.SMTPException, socket.error) as e:
-                    res = E5MessageBox.critical(self,
+                    res = E5MessageBox.retryAbort(self,
                         self.trUtf8("Send bug report"),
                         self.trUtf8("""<p>Authentication failed.<br>Reason: {0}</p>""")
                             .format(str(e)),
-                        QMessageBox.StandardButtons(\
-                            QMessageBox.Abort | \
-                            QMessageBox.Retry),
-                        QMessageBox.Retry)
-                    if res == QMessageBox.Retry:
+                        E5MessageBox.Critical)
+                    if res:
                         return self.__sendmail(msg)
                     else:
                         return False
@@ -306,11 +303,8 @@
                 self.trUtf8("Send bug report"),
                 self.trUtf8("""<p>Message could not be sent.<br>Reason: {0}</p>""")
                     .format(str(e)),
-                QMessageBox.StandardButtons(\
-                    QMessageBox.Abort | \
-                    QMessageBox.Retry),
-                QMessageBox.Retry)
-            if res == QMessageBox.Retry:
+                E5MessageBox.Critical)
+            if res:
                 return self.__sendmail(msg)
             else:
                 return False

eric ide

mercurial