eric7/UI/EmailDialog.py

branch
eric7
changeset 8356
68ec9c3d4de5
parent 8354
12ebd3934fef
child 8358
144a6b854f70
equal deleted inserted replaced
8355:8a7677a63c8d 8356:68ec9c3d4de5
17 from PyQt6.QtWidgets import ( 17 from PyQt6.QtWidgets import (
18 QHeaderView, QLineEdit, QDialog, QInputDialog, QDialogButtonBox, 18 QHeaderView, QLineEdit, QDialog, QInputDialog, QDialogButtonBox,
19 QTreeWidgetItem 19 QTreeWidgetItem
20 ) 20 )
21 21
22 from E5Gui import E5MessageBox, E5FileDialog 22 from E5Gui import EricMessageBox, EricFileDialog
23 from E5Gui.E5OverrideCursor import E5OverrideCursor 23 from E5Gui.EricOverrideCursor import EricOverrideCursor
24 24
25 from .Ui_EmailDialog import Ui_EmailDialog 25 from .Ui_EmailDialog import Ui_EmailDialog
26 26
27 from .Info import BugAddress, FeatureAddress 27 from .Info import BugAddress, FeatureAddress
28 import Preferences 28 import Preferences
108 Protected method to handle the user pressing the escape key. 108 Protected method to handle the user pressing the escape key.
109 109
110 @param ev key event (QKeyEvent) 110 @param ev key event (QKeyEvent)
111 """ 111 """
112 if ev.key() == Qt.Key.Key_Escape: 112 if ev.key() == Qt.Key.Key_Escape:
113 res = E5MessageBox.yesNo( 113 res = EricMessageBox.yesNo(
114 self, 114 self,
115 self.tr("Close dialog"), 115 self.tr("Close dialog"),
116 self.tr("""Do you really want to close the dialog?""")) 116 self.tr("""Do you really want to close the dialog?"""))
117 if res: 117 if res:
118 self.reject() 118 self.reject()
130 130
131 def on_buttonBox_rejected(self): 131 def on_buttonBox_rejected(self):
132 """ 132 """
133 Private slot to handle the rejected signal of the button box. 133 Private slot to handle the rejected signal of the button box.
134 """ 134 """
135 res = E5MessageBox.yesNo( 135 res = EricMessageBox.yesNo(
136 self, 136 self,
137 self.tr("Close dialog"), 137 self.tr("Close dialog"),
138 self.tr("""Do you really want to close the dialog?""")) 138 self.tr("""Do you really want to close the dialog?"""))
139 if res: 139 if res:
140 self.reject() 140 self.reject()
153 helpStr = self.tr( 153 helpStr = self.tr(
154 "<p>The Google Mail Client API is not installed." 154 "<p>The Google Mail Client API is not installed."
155 " Use <code>{0}</code> to install it.</p>" 155 " Use <code>{0}</code> to install it.</p>"
156 ).format(getInstallCommand()) 156 ).format(getInstallCommand())
157 157
158 from E5Gui.E5SimpleHelpDialog import E5SimpleHelpDialog 158 from E5Gui.EricSimpleHelpDialog import EricSimpleHelpDialog
159 self.__helpDialog = E5SimpleHelpDialog( 159 self.__helpDialog = EricSimpleHelpDialog(
160 title=self.tr("Gmail API Help"), 160 title=self.tr("Gmail API Help"),
161 helpStr=helpStr, parent=self) 161 helpStr=helpStr, parent=self)
162 162
163 self.__helpDialog.show() 163 self.__helpDialog.show()
164 164
340 errorStr = e.strerror 340 errorStr = e.strerror
341 elif isinstance(e, OSError): 341 elif isinstance(e, OSError):
342 errorStr = e[1] 342 errorStr = e[1]
343 else: 343 else:
344 errorStr = str(e) 344 errorStr = str(e)
345 res = E5MessageBox.retryAbort( 345 res = EricMessageBox.retryAbort(
346 self, 346 self,
347 self.tr("Send Message"), 347 self.tr("Send Message"),
348 self.tr( 348 self.tr(
349 """<p>Authentication failed.<br>Reason: {0}</p>""") 349 """<p>Authentication failed.<br>Reason: {0}</p>""")
350 .format(errorStr), 350 .format(errorStr),
351 E5MessageBox.Critical) 351 EricMessageBox.Critical)
352 if res: 352 if res:
353 return self.__sendmail(msg) 353 return self.__sendmail(msg)
354 else: 354 else:
355 return False 355 return False
356 356
357 with E5OverrideCursor(): 357 with EricOverrideCursor():
358 server.sendmail(Preferences.getUser("Email"), self.__toAddress, 358 server.sendmail(Preferences.getUser("Email"), self.__toAddress,
359 msg) 359 msg)
360 server.quit() 360 server.quit()
361 except (smtplib.SMTPException, OSError) as e: 361 except (smtplib.SMTPException, OSError) as e:
362 if isinstance(e, smtplib.SMTPResponseException): 362 if isinstance(e, smtplib.SMTPResponseException):
365 errorStr = str(e) 365 errorStr = str(e)
366 elif isinstance(e, OSError): 366 elif isinstance(e, OSError):
367 errorStr = e.strerror 367 errorStr = e.strerror
368 else: 368 else:
369 errorStr = str(e) 369 errorStr = str(e)
370 res = E5MessageBox.retryAbort( 370 res = EricMessageBox.retryAbort(
371 self, 371 self,
372 self.tr("Send Message"), 372 self.tr("Send Message"),
373 self.tr( 373 self.tr(
374 """<p>Message could not be sent.<br>Reason: {0}</p>""") 374 """<p>Message could not be sent.<br>Reason: {0}</p>""")
375 .format(errorStr), 375 .format(errorStr),
376 E5MessageBox.Critical) 376 EricMessageBox.Critical)
377 if res: 377 if res:
378 return self.__sendmail(msg) 378 return self.__sendmail(msg)
379 else: 379 else:
380 return False 380 return False
381 return True 381 return True
409 if ok: 409 if ok:
410 self.__deleteAttachedFiles() 410 self.__deleteAttachedFiles()
411 self.accept() 411 self.accept()
412 else: 412 else:
413 # we got an error 413 # we got an error
414 E5MessageBox.critical( 414 EricMessageBox.critical(
415 self, 415 self,
416 self.tr("Send Message via Gmail"), 416 self.tr("Send Message via Gmail"),
417 self.tr( 417 self.tr(
418 """<p>Message could not be sent.<br>Reason: {0}</p>""") 418 """<p>Message could not be sent.<br>Reason: {0}</p>""")
419 .format(message) 419 .format(message)
422 @pyqtSlot() 422 @pyqtSlot()
423 def on_addButton_clicked(self): 423 def on_addButton_clicked(self):
424 """ 424 """
425 Private slot to handle the Add... button. 425 Private slot to handle the Add... button.
426 """ 426 """
427 fname = E5FileDialog.getOpenFileName( 427 fname = EricFileDialog.getOpenFileName(
428 self, 428 self,
429 self.tr("Attach file")) 429 self.tr("Attach file"))
430 if fname: 430 if fname:
431 self.attachFile(fname, False) 431 self.attachFile(fname, False)
432 432

eric ide

mercurial