Hello,
I ferquently forget to Bcc my self when I send and email with Trojitá and
thus I keep loosing sent emails. I don't want to use the "Save Outgoing
Mail" feature because I also use fetchmail to archive my emails. It's also
not always the case that I want to Bcc my self; I want to be able to
control that option on a per email basis.
So I added a tiny checkbox right next the from combobox in the composer
window that reads "Bcc".
It's really a tiny patch and there are some things missing, like:
- remembering the checkbox state
- make the test cases work again. There's a problem in
test_SenderIdentitiesModel.cpp (to start with). I'll have to find out how
to make it spit out more debug messages so that I can identify the problem.
A much, much cooler solution might be to add scripting capabilities in
Trojitá (or hooks, like in Mutt) but that would require many more changes
and, basically, I don't know how to do that :-)
But I thought I'd share it anyway, in case someone finds it usefull, or if
you guys are interested in incorporating it in Trojitá (after it's polished
enough).
Cheers,
George
diff --git a/src/Gui/ComposeWidget.cpp b/src/Gui/ComposeWidget.cpp
index 1fb02dc..3eb45fb 100644
--- a/src/Gui/ComposeWidget.cpp
+++ b/src/Gui/ComposeWidget.cpp
@@ -316,6 +316,14 @@ void ComposeWidget::closeEvent(QCloseEvent *ce)
bool ComposeWidget::buildMessageData()
{
+ // Set from address.
+ Imap::Message::MailAddress fromAddress;
+ if (!Imap::Message::MailAddress::fromPrettyString(fromAddress, ui->sender->currentText())) {
+ gotError(tr("The From: address does not look like a valid one"));
+ return false;
+ }
+
+ // Set recipients.
QList<QPair<Composer::RecipientKind,Imap::Message::MailAddress> > recipients;
QString errorMessage;
if (!parseRecipients(recipients, errorMessage)) {
@@ -326,13 +334,14 @@ bool ComposeWidget::buildMessageData()
gotError(tr("You haven't entered any recipients"));
return false;
}
- m_submission->composer()->setRecipients(recipients);
- Imap::Message::MailAddress fromAddress;
- if (!Imap::Message::MailAddress::fromPrettyString(fromAddress, ui->sender->currentText())) {
- gotError(tr("The From: address does not look like a valid one"));
- return false;
+ // Add self to recipient list, if bccSelf is checked.
+ if (ui->bccSelf->isChecked()) {
+ recipients << qMakePair(Composer::ADDRESS_BCC, fromAddress);
}
+
+ m_submission->composer()->setRecipients(recipients);
+
if (ui->subject->text().isEmpty()) {
gotError(tr("You haven't entered any subject. Cannot send such a mail, sorry."));
ui->subject->setFocus();
diff --git a/src/Gui/ComposeWidget.ui b/src/Gui/ComposeWidget.ui
index 559a849..9e04dba 100644
--- a/src/Gui/ComposeWidget.ui
+++ b/src/Gui/ComposeWidget.ui
@@ -56,20 +56,31 @@
</widget>
</item>
<item row="0" column="1">
- <widget class="QComboBox" name="sender">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="editable">
- <bool>true</bool>
- </property>
- <property name="insertPolicy">
- <enum>QComboBox::NoInsert</enum>
- </property>
- </widget>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QComboBox" name="sender">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <property name="insertPolicy">
+ <enum>QComboBox::NoInsert</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="bccSelf">
+ <property name="text">
+ <string>Bcc</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="subjectLabel">