gmail now display value of To header + gmail now uses proper default/master CSS as per selected skin in nonwebengine variant
This commit is contained in:
parent
e6536a172b
commit
9b033ad717
5 changed files with 44 additions and 30 deletions
|
@ -34,6 +34,15 @@ TextBrowserViewer::TextBrowserViewer(QWidget* parent)
|
||||||
setResourcesEnabled(qApp->settings()->value(GROUP(Messages), SETTING(Messages::ShowResourcesInArticles)).toBool());
|
setResourcesEnabled(qApp->settings()->value(GROUP(Messages), SETTING(Messages::ShowResourcesInArticles)).toBool());
|
||||||
setDocument(m_document.data());
|
setDocument(m_document.data());
|
||||||
|
|
||||||
|
// Apply master CSS.
|
||||||
|
QColor a_color = qApp->skins()->currentSkin().colorForModel(SkinEnums::PaletteColors::FgInteresting).value<QColor>();
|
||||||
|
|
||||||
|
if (!a_color.isValid()) {
|
||||||
|
a_color = qApp->palette().color(QPalette::ColorRole::Highlight);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_document.data()->setDefaultStyleSheet(QSL("a { color: %1; }").arg(a_color.name()));
|
||||||
|
|
||||||
connect(this, &TextBrowserViewer::reloadDocument, this, [this]() {
|
connect(this, &TextBrowserViewer::reloadDocument, this, [this]() {
|
||||||
const auto scr = verticalScrollBarPosition();
|
const auto scr = verticalScrollBarPosition();
|
||||||
setHtmlPrivate(html(), m_currentUrl);
|
setHtmlPrivate(html(), m_currentUrl);
|
||||||
|
@ -116,12 +125,6 @@ PreparedHtml TextBrowserViewer::prepareHtmlForMessage(const QList<Message>& mess
|
||||||
|
|
||||||
html.m_html += QSL("</div>");
|
html.m_html += QSL("</div>");
|
||||||
|
|
||||||
QColor a_color = qApp->skins()->currentSkin().colorForModel(SkinEnums::PaletteColors::FgInteresting).value<QColor>();
|
|
||||||
|
|
||||||
if (!a_color.isValid()) {
|
|
||||||
a_color = qApp->palette().color(QPalette::ColorRole::Highlight);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString base_url;
|
QString base_url;
|
||||||
auto* feed = selected_item->getParentServiceRoot()
|
auto* feed = selected_item->getParentServiceRoot()
|
||||||
->getItemFromSubTree([messages](const RootItem* it) {
|
->getItemFromSubTree([messages](const RootItem* it) {
|
||||||
|
@ -137,14 +140,6 @@ PreparedHtml TextBrowserViewer::prepareHtmlForMessage(const QList<Message>& mess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Final html, with replaced link colors.
|
|
||||||
html.m_html = QSL("<html>"
|
|
||||||
"<head><style>"
|
|
||||||
"a { color: %2; }"
|
|
||||||
"</style></head>"
|
|
||||||
"<body>%1</body>"
|
|
||||||
"</html>")
|
|
||||||
.arg(html.m_html, a_color.name());
|
|
||||||
html.m_baseUrl = base_url;
|
html.m_baseUrl = base_url;
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
|
|
|
@ -20,7 +20,7 @@ class OAuth2Service;
|
||||||
class Downloader;
|
class Downloader;
|
||||||
|
|
||||||
class GmailNetworkFactory : public QObject {
|
class GmailNetworkFactory : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GmailNetworkFactory(QObject* parent = nullptr);
|
explicit GmailNetworkFactory(QObject* parent = nullptr);
|
||||||
|
@ -40,10 +40,15 @@ class GmailNetworkFactory : public QObject {
|
||||||
void setDownloadOnlyUnreadMessages(bool download_only_unread_messages);
|
void setDownloadOnlyUnreadMessages(bool download_only_unread_messages);
|
||||||
|
|
||||||
// API methods.
|
// API methods.
|
||||||
|
QMap<QString, QString> getMessageMetadata(const QString& msg_id,
|
||||||
|
const QStringList& metadata,
|
||||||
|
const QNetworkProxy& custom_proxy);
|
||||||
QNetworkRequest requestForAttachment(const QString& email_id, const QString& attachment_id);
|
QNetworkRequest requestForAttachment(const QString& email_id, const QString& attachment_id);
|
||||||
QString sendEmail(Mimesis::Message msg, const QNetworkProxy& custom_proxy, Message* reply_to_message = nullptr);
|
QString sendEmail(Mimesis::Message msg, const QNetworkProxy& custom_proxy, Message* reply_to_message = nullptr);
|
||||||
QList<Message> messages(const QString& stream_id, const QHash<ServiceRoot::BagOfMessages, QStringList>& stated_messages,
|
QList<Message> messages(const QString& stream_id,
|
||||||
Feed::Status& error, const QNetworkProxy& custom_proxy);
|
const QHash<ServiceRoot::BagOfMessages, QStringList>& stated_messages,
|
||||||
|
Feed::Status& error,
|
||||||
|
const QNetworkProxy& custom_proxy);
|
||||||
QNetworkReply::NetworkError markMessagesRead(RootItem::ReadStatus status,
|
QNetworkReply::NetworkError markMessagesRead(RootItem::ReadStatus status,
|
||||||
const QStringList& custom_ids,
|
const QStringList& custom_ids,
|
||||||
const QNetworkProxy& custom_proxy);
|
const QNetworkProxy& custom_proxy);
|
||||||
|
@ -64,9 +69,6 @@ class GmailNetworkFactory : public QObject {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool fillFullMessage(Message& msg, const QJsonObject& json, const QString& feed_id);
|
bool fillFullMessage(Message& msg, const QJsonObject& json, const QString& feed_id);
|
||||||
QMap<QString, QString> getMessageMetadata(const QString& msg_id,
|
|
||||||
const QStringList& metadata,
|
|
||||||
const QNetworkProxy& custom_proxy);
|
|
||||||
QList<Message> obtainAndDecodeFullMessages(const QStringList& message_ids,
|
QList<Message> obtainAndDecodeFullMessages(const QStringList& message_ids,
|
||||||
const QString& feed_id,
|
const QString& feed_id,
|
||||||
const QNetworkProxy& custom_proxy);
|
const QNetworkProxy& custom_proxy);
|
||||||
|
|
|
@ -18,6 +18,9 @@ EmailPreviewer::EmailPreviewer(GmailServiceRoot* account, QWidget* parent)
|
||||||
: CustomMessagePreviewer(parent), m_account(account), m_webView(new WebBrowser(nullptr, this)) {
|
: CustomMessagePreviewer(parent), m_account(account), m_webView(new WebBrowser(nullptr, this)) {
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
|
m_tmrLoadExtraMessageData.setInterval(200);
|
||||||
|
m_tmrLoadExtraMessageData.setSingleShot(true);
|
||||||
|
|
||||||
m_ui.m_mainLayout->addWidget(dynamic_cast<QWidget*>(m_webView.data()), 3, 0, 1, -1);
|
m_ui.m_mainLayout->addWidget(dynamic_cast<QWidget*>(m_webView.data()), 3, 0, 1, -1);
|
||||||
m_ui.m_btnAttachments->setIcon(qApp->icons()->fromTheme(QSL("mail-attachment")));
|
m_ui.m_btnAttachments->setIcon(qApp->icons()->fromTheme(QSL("mail-attachment")));
|
||||||
m_ui.m_btnForward->setIcon(qApp->icons()->fromTheme(QSL("mail-forward")));
|
m_ui.m_btnForward->setIcon(qApp->icons()->fromTheme(QSL("mail-forward")));
|
||||||
|
@ -32,6 +35,8 @@ EmailPreviewer::EmailPreviewer(GmailServiceRoot* account, QWidget* parent)
|
||||||
connect(menu_attachments, &QMenu::triggered, this, &EmailPreviewer::downloadAttachment);
|
connect(menu_attachments, &QMenu::triggered, this, &EmailPreviewer::downloadAttachment);
|
||||||
connect(m_ui.m_btnReply, &QToolButton::clicked, this, &EmailPreviewer::replyToEmail);
|
connect(m_ui.m_btnReply, &QToolButton::clicked, this, &EmailPreviewer::replyToEmail);
|
||||||
connect(m_ui.m_btnForward, &QToolButton::clicked, this, &EmailPreviewer::forwardEmail);
|
connect(m_ui.m_btnForward, &QToolButton::clicked, this, &EmailPreviewer::forwardEmail);
|
||||||
|
|
||||||
|
connect(&m_tmrLoadExtraMessageData, &QTimer::timeout, this, &EmailPreviewer::loadExtraMessageData);
|
||||||
}
|
}
|
||||||
|
|
||||||
EmailPreviewer::~EmailPreviewer() {
|
EmailPreviewer::~EmailPreviewer() {
|
||||||
|
@ -39,6 +44,7 @@ EmailPreviewer::~EmailPreviewer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmailPreviewer::clear() {
|
void EmailPreviewer::clear() {
|
||||||
|
m_tmrLoadExtraMessageData.stop();
|
||||||
m_webView->clear(false);
|
m_webView->clear(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +67,14 @@ void EmailPreviewer::loadMessage(const Message& msg, RootItem* selected_item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui.m_btnAttachments->setDisabled(m_ui.m_btnAttachments->menu()->isEmpty());
|
m_ui.m_btnAttachments->setDisabled(m_ui.m_btnAttachments->menu()->isEmpty());
|
||||||
|
|
||||||
|
m_tmrLoadExtraMessageData.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmailPreviewer::loadExtraMessageData() {
|
||||||
|
m_ui.m_tbTo->setText(m_account->network()->getMessageMetadata(m_message.m_customId,
|
||||||
|
{QSL("TO")},
|
||||||
|
m_account->networkProxy())["To"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmailPreviewer::replyToEmail() {
|
void EmailPreviewer::replyToEmail() {
|
||||||
|
@ -86,8 +100,7 @@ void EmailPreviewer::downloadAttachment(QAction* act) {
|
||||||
|
|
||||||
if (!data.isEmpty()) {
|
if (!data.isEmpty()) {
|
||||||
IOFactory::writeFile(it->output().fileName(),
|
IOFactory::writeFile(it->output().fileName(),
|
||||||
QByteArray::fromBase64(data.toLocal8Bit(),
|
QByteArray::fromBase64(data.toLocal8Bit(), QByteArray::Base64Option::Base64UrlEncoding));
|
||||||
QByteArray::Base64Option::Base64UrlEncoding));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,10 +9,12 @@
|
||||||
|
|
||||||
#include "ui_emailpreviewer.h"
|
#include "ui_emailpreviewer.h"
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
class GmailServiceRoot;
|
class GmailServiceRoot;
|
||||||
|
|
||||||
class EmailPreviewer : public CustomMessagePreviewer {
|
class EmailPreviewer : public CustomMessagePreviewer {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit EmailPreviewer(GmailServiceRoot* account, QWidget* parent = nullptr);
|
explicit EmailPreviewer(GmailServiceRoot* account, QWidget* parent = nullptr);
|
||||||
|
@ -22,6 +24,7 @@ class EmailPreviewer : public CustomMessagePreviewer {
|
||||||
virtual void loadMessage(const Message& msg, RootItem* selected_item);
|
virtual void loadMessage(const Message& msg, RootItem* selected_item);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void loadExtraMessageData();
|
||||||
void replyToEmail();
|
void replyToEmail();
|
||||||
void forwardEmail();
|
void forwardEmail();
|
||||||
void downloadAttachment(QAction* act);
|
void downloadAttachment(QAction* act);
|
||||||
|
@ -31,6 +34,7 @@ class EmailPreviewer : public CustomMessagePreviewer {
|
||||||
GmailServiceRoot* m_account;
|
GmailServiceRoot* m_account;
|
||||||
QScopedPointer<WebBrowser> m_webView;
|
QScopedPointer<WebBrowser> m_webView;
|
||||||
Message m_message;
|
Message m_message;
|
||||||
|
QTimer m_tmrLoadExtraMessageData;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EMAILPREVIEWER_H
|
#endif // EMAILPREVIEWER_H
|
||||||
|
|
|
@ -14,13 +14,6 @@
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="m_mainLayout">
|
<layout class="QGridLayout" name="m_mainLayout">
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QLineEdit" name="m_tbSubject">
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -115,6 +108,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="1" colspan="2">
|
||||||
|
<widget class="QLineEdit" name="m_tbSubject">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
|
|
Loading…
Add table
Reference in a new issue