71 |
71 |
72 @param msgType type of the message (integer, QtMsgType) |
72 @param msgType type of the message (integer, QtMsgType) |
73 @param message message to be shown (bytes) |
73 @param message message to be shown (bytes) |
74 """ |
74 """ |
75 if __msgHandlerDialog: |
75 if __msgHandlerDialog: |
76 if msgType == QtDebugMsg: |
76 try: |
77 messageType = QCoreApplication.translate("E5ErrorMessage", "Debug Message:") |
77 if msgType == QtDebugMsg: |
78 elif msgType == QtWarningMsg: |
78 messageType = QCoreApplication.translate("E5ErrorMessage", "Debug Message:") |
79 messageType = QCoreApplication.translate("E5ErrorMessage", "Warning:") |
79 elif msgType == QtWarningMsg: |
80 elif msgType == QtCriticalMsg: |
80 messageType = QCoreApplication.translate("E5ErrorMessage", "Warning:") |
81 messageType = QCoreApplication.translate("E5ErrorMessage", "Critical:") |
81 elif msgType == QtCriticalMsg: |
82 elif msgType == QtFatalMsg: |
82 messageType = QCoreApplication.translate("E5ErrorMessage", "Critical:") |
83 messageType = QCoreApplication.translate("E5ErrorMessage", "Fatal Error:") |
83 elif msgType == QtFatalMsg: |
84 msg = "<p><b>{0}</b></p><p>{1}</p>".format( |
84 messageType = QCoreApplication.translate("E5ErrorMessage", "Fatal Error:") |
85 messageType, Utilities.html_uencode(message.decode())) |
85 msg = "<p><b>{0}</b></p><p>{1}</p>".format( |
86 if QThread.currentThread() == qApp.thread(): |
86 messageType, Utilities.html_uencode(message.decode())) |
87 __msgHandlerDialog.showMessage(msg) |
87 if QThread.currentThread() == qApp.thread(): |
88 else: |
88 __msgHandlerDialog.showMessage(msg) |
89 QMetaObject.invokeMethod( |
89 else: |
90 __msgHandlerDialog, |
90 QMetaObject.invokeMethod( |
91 "showMessage", |
91 __msgHandlerDialog, |
92 Qt.QueuedConnection, |
92 "showMessage", |
93 Q_ARG(str, msg)) |
93 Qt.QueuedConnection, |
|
94 Q_ARG(str, msg)) |
|
95 return |
|
96 except RuntimeError: |
|
97 pass |
94 elif __origMsgHandler: |
98 elif __origMsgHandler: |
95 __origMsgHandler(msgType, message) |
99 __origMsgHandler(msgType, message) |
96 else: |
100 return |
97 if msgType == QtDebugMsg: |
101 |
98 messageType = QCoreApplication.translate("E5ErrorMessage", "Debug Message") |
102 if msgType == QtDebugMsg: |
99 elif msgType == QtWarningMsg: |
103 messageType = QCoreApplication.translate("E5ErrorMessage", "Debug Message") |
100 messageType = QCoreApplication.translate("E5ErrorMessage", "Warning") |
104 elif msgType == QtWarningMsg: |
101 elif msgType == QtCriticalMsg: |
105 messageType = QCoreApplication.translate("E5ErrorMessage", "Warning") |
102 messageType = QCoreApplication.translate("E5ErrorMessage", "Critical") |
106 elif msgType == QtCriticalMsg: |
103 elif msgType == QtFatalMsg: |
107 messageType = QCoreApplication.translate("E5ErrorMessage", "Critical") |
104 messageType = QCoreApplication.translate("E5ErrorMessage", "Fatal Error") |
108 elif msgType == QtFatalMsg: |
105 print("{0}: {1}".format(messageType, message.decode())) |
109 messageType = QCoreApplication.translate("E5ErrorMessage", "Fatal Error") |
|
110 print("{0}: {1}".format(messageType, message.decode())) |
106 |
111 |
107 |
112 |
108 def qtHandler(): |
113 def qtHandler(): |
109 """ |
114 """ |
110 Module function to install an E5ErrorMessage dialog as the global |
115 Module function to install an E5ErrorMessage dialog as the global |