gmail previewer supports reply-to and forward

This commit is contained in:
Martin Rotter 2022-04-07 09:00:35 +02:00
parent 6b3e0179f2
commit f2094ce261
6 changed files with 49 additions and 11 deletions

View File

@ -10,16 +10,14 @@ RSS Guard
### [Discord server](https://discord.gg/7xbVMPPNqH) | [Downloads](https://github.com/martinrotter/rssguard/releases) | [Development builds](https://github.com/martinrotter/rssguard/releases/tag/devbuild) | [Documentation](https://github.com/martinrotter/rssguard/blob/master/resources/docs/Documentation.md)
RSS Guard is simple RSS/ATOM feed reader for Windows, Linux, BSD, OS/2 or macOS which can work with RSS/ATOM/JSON feeds and also supports many online feed services:
* [Tiny Tiny RSS](https://tt-rss.org),
* [Inoreader](https://www.inoreader.com) (via Google Reader API plugin),
* [Nextcloud News](https://apps.nextcloud.com/apps/news),
* [Feedly](https://feedly.com),
* [Gmail](https://developers.google.com/gmail/api),
* [FreshRSS](https://freshrss.org) (via Google Reader API plugin),
* [The Old Reader](https://theoldreader.com) (via Google Reader API plugin),
* [Bazqux](https://bazqux.com) (via Google Reader API plugin),
* [Reedah](http://reedah.com) (via Google Reader API plugin),
* [Feedly](https://feedly.com).
* Google Reader API ([Bazqux](https://bazqux.com), [FreshRSS](https://freshrss.org), [Inoreader](https://www.inoreader.com), [Reedah](http://reedah.com), [The Old Reader](https://theoldreader.com) and others),
* [Nextcloud News](https://apps.nextcloud.com/apps/news),
* [Tiny Tiny RSS](https://tt-rss.org).
![RSS Guard](resources/docs/videos/rssguard.gif)
Application icon was kindly contributed by Siddharth Yadav - @Siddharth_yd (Instagram), illustrationdesignsid@gmail.com (e-mail). Flag icons were provided by [IconDrawer](http://www.icondrawer.com).
Contributed graphics:
* RSS Guard logo - [Siddharth Yadav](mailto:illustrationdesignsid@gmail.com), [@Siddharth_yd](https://www.instagram.com/siddharth_yd/).
* Flag icons - [IconDrawer](http://www.icondrawer.com).

View File

@ -26,7 +26,7 @@
<url type="donation">https://github.com/sponsors/martinrotter</url>
<content_rating type="oars-1.1" />
<releases>
<release version="4.2.1" date="2022-04-06"/>
<release version="4.2.1" date="2022-04-07"/>
</releases>
<content_rating type="oars-1.0">
<content_attribute id="violence-cartoon">none</content_attribute>

View File

@ -10,6 +10,7 @@
#include "services/gmail/definitions.h"
#include "services/gmail/gmailnetworkfactory.h"
#include "services/gmail/gmailserviceroot.h"
#include "services/gmail/gui/formaddeditemail.h"
#include <QJsonObject>
@ -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);

View File

@ -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:

View File

@ -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("<pre>"
"---------- Forwarded message ---------<br/>"
"From: %1<br/>"
"Date: %2<br/>"
"Subject: %3<br/>"
"To: -"
"</pre><br/>").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();
}

View File

@ -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();