@@ -29,6 +30,8 @@ EmailPreviewer::EmailPreviewer(GmailServiceRoot* account, QWidget* parent)
m_webView->setNavigationBarVisible(false);
connect(menu_attachments, &QMenu::triggered, this, &EmailPreviewer::downloadAttachment);
+ connect(m_ui.m_btnReply, &QToolButton::clicked, this, &EmailPreviewer::replyToEmail);
+ connect(m_ui.m_btnForward, &QToolButton::clicked, this, &EmailPreviewer::forwardEmail);
}
EmailPreviewer::~EmailPreviewer() {
@@ -60,6 +63,14 @@ void EmailPreviewer::loadMessage(const Message& msg, RootItem* selected_item) {
m_ui.m_btnAttachments->setDisabled(m_ui.m_btnAttachments->menu()->isEmpty());
}
+void EmailPreviewer::replyToEmail() {
+ FormAddEditEmail(m_account, window()).execForReply(&m_message);
+}
+
+void EmailPreviewer::forwardEmail() {
+ FormAddEditEmail(m_account, window()).execForForward(&m_message);
+}
+
void EmailPreviewer::downloadAttachment(QAction* act) {
const QString attachment_id = act->data().toStringList().at(1);
const QString file_name = act->data().toStringList().at(0);
diff --git a/src/librssguard/services/gmail/gui/emailpreviewer.h b/src/librssguard/services/gmail/gui/emailpreviewer.h
index b63a5075a..5ccfa1d36 100644
--- a/src/librssguard/services/gmail/gui/emailpreviewer.h
+++ b/src/librssguard/services/gmail/gui/emailpreviewer.h
@@ -22,6 +22,8 @@ class EmailPreviewer : public CustomMessagePreviewer {
virtual void loadMessage(const Message& msg, RootItem* selected_item);
private slots:
+ void replyToEmail();
+ void forwardEmail();
void downloadAttachment(QAction* act);
private:
diff --git a/src/librssguard/services/gmail/gui/formaddeditemail.cpp b/src/librssguard/services/gmail/gui/formaddeditemail.cpp
index 0af21ff43..054a2b00d 100644
--- a/src/librssguard/services/gmail/gui/formaddeditemail.cpp
+++ b/src/librssguard/services/gmail/gui/formaddeditemail.cpp
@@ -54,10 +54,36 @@ void FormAddEditEmail::execForAdd() {
void FormAddEditEmail::execForReply(Message* original_message) {
m_originalMessage = original_message;
- addRecipientRow(m_originalMessage->m_author);
m_ui.m_txtSubject->setText(QSL("Re: %1").arg(m_originalMessage->m_title));
m_ui.m_txtSubject->setEnabled(false);
m_ui.m_txtMessage->setFocus();
+
+ addRecipientRow(m_originalMessage->m_author);
+ exec();
+}
+
+void FormAddEditEmail::execForForward(Message* original_message) {
+ m_originalMessage = original_message;
+
+ m_ui.m_txtSubject->setText(QSL("Fwd: %1").arg(m_originalMessage->m_title));
+ m_ui.m_txtSubject->setEnabled(false);
+ m_ui.m_txtMessage->setFocus();
+
+ // TODO: Obtain "To" header from Gmail API and fill it in too.
+ const QString forward_header = QSL(""
+ "---------- Forwarded message ---------
"
+ "From: %1
"
+ "Date: %2
"
+ "Subject: %3
"
+ "To: -"
+ "
").arg(m_originalMessage->m_author,
+ m_originalMessage->m_created.toString(),
+ m_originalMessage->m_title);
+
+ m_ui.m_txtMessage->setHtml(forward_header + m_originalMessage->m_contents);
+ m_ui.m_txtMessage->moveCursor(QTextCursor::MoveOperation::Start);
+
+ addRecipientRow()->setFocus();
exec();
}
diff --git a/src/librssguard/services/gmail/gui/formaddeditemail.h b/src/librssguard/services/gmail/gui/formaddeditemail.h
index 7c45dfb1b..1eed7e412 100644
--- a/src/librssguard/services/gmail/gui/formaddeditemail.h
+++ b/src/librssguard/services/gmail/gui/formaddeditemail.h
@@ -24,6 +24,7 @@ class FormAddEditEmail : public QDialog {
public slots:
void execForAdd();
void execForReply(Message* original_message);
+ void execForForward(Message* original_message);
private slots:
void removeRecipientRow();