51 |
51 |
52 def __init__(self, mode="bug", parent=None): |
52 def __init__(self, mode="bug", parent=None): |
53 """ |
53 """ |
54 Constructor |
54 Constructor |
55 |
55 |
56 @param mode mode of this dialog (string, "bug" or "feature") |
56 @param mode mode of this dialog ("bug" or "feature") |
57 @param parent parent widget of this dialog (QWidget) |
57 @type str |
|
58 @param parent parent widget of this dialog |
|
59 @type QWidget |
58 """ |
60 """ |
59 super().__init__(parent) |
61 super().__init__(parent) |
60 self.setupUi(self) |
62 self.setupUi(self) |
61 self.setWindowFlags(Qt.WindowType.Window) |
63 self.setWindowFlags(Qt.WindowType.Window) |
62 |
64 |
115 |
117 |
116 def keyPressEvent(self, ev): |
118 def keyPressEvent(self, ev): |
117 """ |
119 """ |
118 Protected method to handle the user pressing the escape key. |
120 Protected method to handle the user pressing the escape key. |
119 |
121 |
120 @param ev key event (QKeyEvent) |
122 @param ev key event |
|
123 @type QKeyEvent |
121 """ |
124 """ |
122 if ev.key() == Qt.Key.Key_Escape: |
125 if ev.key() == Qt.Key.Key_Escape: |
123 res = EricMessageBox.yesNo( |
126 res = EricMessageBox.yesNo( |
124 self, |
127 self, |
125 self.tr("Close dialog"), |
128 self.tr("Close dialog"), |
130 |
133 |
131 def on_buttonBox_clicked(self, button): |
134 def on_buttonBox_clicked(self, button): |
132 """ |
135 """ |
133 Private slot called by a button of the button box clicked. |
136 Private slot called by a button of the button box clicked. |
134 |
137 |
135 @param button button that was clicked (QAbstractButton) |
138 @param button button that was clicked |
|
139 @type QAbstractButton |
136 """ |
140 """ |
137 if button == self.sendButton: |
141 if button == self.sendButton: |
138 self.on_sendButton_clicked() |
142 self.on_sendButton_clicked() |
139 elif button == self.googleHelpButton: |
143 elif button == self.googleHelpButton: |
140 self.on_googleHelpButton_clicked() |
144 self.on_googleHelpButton_clicked() |
204 |
208 |
205 def __encodedText(self, txt): |
209 def __encodedText(self, txt): |
206 """ |
210 """ |
207 Private method to create a MIMEText message with correct encoding. |
211 Private method to create a MIMEText message with correct encoding. |
208 |
212 |
209 @param txt text to be put into the MIMEText object (string) |
213 @param txt text to be put into the MIMEText object |
|
214 @type str |
210 @return MIMEText object |
215 @return MIMEText object |
|
216 @rtype email.mime.text.MIMEText |
211 """ |
217 """ |
212 try: |
218 try: |
213 txt.encode("us-ascii") |
219 txt.encode("us-ascii") |
214 return MIMEText(txt) |
220 return MIMEText(txt) |
215 except UnicodeEncodeError: |
221 except UnicodeEncodeError: |
218 |
224 |
219 def __encodedHeader(self, txt): |
225 def __encodedHeader(self, txt): |
220 """ |
226 """ |
221 Private method to create a correctly encoded mail header. |
227 Private method to create a correctly encoded mail header. |
222 |
228 |
223 @param txt header text to encode (string) |
229 @param txt header text to encode |
224 @return encoded header (email.header.Header) |
230 @type str |
|
231 @return encoded header |
|
232 @rtype email.header.Header |
225 """ |
233 """ |
226 try: |
234 try: |
227 txt.encode("us-ascii") |
235 txt.encode("us-ascii") |
228 return Header(txt) |
236 return Header(txt) |
229 except UnicodeEncodeError: |
237 except UnicodeEncodeError: |
318 |
326 |
319 def __sendmail(self, msg): |
327 def __sendmail(self, msg): |
320 """ |
328 """ |
321 Private method to actually send the message. |
329 Private method to actually send the message. |
322 |
330 |
323 @param msg the message to be sent (string) |
331 @param msg the message to be sent |
324 @return flag indicating success (boolean) |
332 @type str |
|
333 @return flag indicating success |
|
334 @rtype bool |
325 """ |
335 """ |
326 try: |
336 try: |
327 encryption = Preferences.getUser("MailServerEncryption") |
337 encryption = Preferences.getUser("MailServerEncryption") |
328 if encryption == "SSL": |
338 if encryption == "SSL": |
329 server = smtplib.SMTP_SSL( |
339 server = smtplib.SMTP_SSL( |
462 |
472 |
463 def attachFile(self, fname, deleteFile): |
473 def attachFile(self, fname, deleteFile): |
464 """ |
474 """ |
465 Public method to add an attachment. |
475 Public method to add an attachment. |
466 |
476 |
467 @param fname name of the file to be attached (string) |
477 @param fname name of the file to be attached |
|
478 @type str |
468 @param deleteFile flag indicating to delete the file after it has |
479 @param deleteFile flag indicating to delete the file after it has |
469 been sent (boolean) |
480 been sent |
|
481 @type bool |
470 """ |
482 """ |
471 mimeType = mimetypes.guess_type(fname)[0] |
483 mimeType = mimetypes.guess_type(fname)[0] |
472 if not mimeType: |
484 if not mimeType: |
473 mimeType = "application/octet-stream" |
485 mimeType = "application/octet-stream" |
474 QTreeWidgetItem(self.attachments, [fname, mimeType]) |
486 QTreeWidgetItem(self.attachments, [fname, mimeType]) |
495 @pyqtSlot(str) |
507 @pyqtSlot(str) |
496 def on_subject_textChanged(self, txt): |
508 def on_subject_textChanged(self, txt): |
497 """ |
509 """ |
498 Private slot to handle the textChanged signal of the subject edit. |
510 Private slot to handle the textChanged signal of the subject edit. |
499 |
511 |
500 @param txt changed text (string) |
512 @param txt changed text |
|
513 @type str |
501 """ |
514 """ |
502 self.sendButton.setEnabled( |
515 self.sendButton.setEnabled( |
503 self.subject.text() != "" and self.message.toPlainText() != "" |
516 self.subject.text() != "" and self.message.toPlainText() != "" |
504 ) |
517 ) |
505 |
518 |