Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 935b2118 authored by Laurent Montel's avatar Laurent Montel 😁

Allow to show html source even if we have build as release

(cherry picked from commit aca3146c)
parent eca2e4c2
......@@ -53,24 +53,27 @@ MailSourceWebEngineViewer::MailSourceWebEngineViewer(QWidget *parent)
setAttribute(Qt::WA_DeleteOnClose);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mRawBrowser = new MailSourceViewTextBrowserWidget(QStringLiteral("Email"), this);
#ifndef NDEBUG
mTabWidget = new QTabWidget(this);
mainLayout->addWidget(mTabWidget);
mTabWidget->addTab(mRawBrowser, i18nc("Unchanged mail message", "Raw Source"));
mTabWidget->setTabToolTip(0,
i18n(
"Raw, unmodified mail as it is stored on the filesystem or on the server"));
mHtmlBrowser = new MailSourceViewTextBrowserWidget(QStringLiteral("HTML"), this);
mTabWidget->addTab(mHtmlBrowser, i18nc("Mail message as shown, in HTML format", "HTML Source"));
mTabWidget->setTabToolTip(1, i18n("HTML code for displaying the message to the user"));
mTabWidget->setCurrentIndex(0);
#else
mainLayout->addWidget(mRawBrowser);
mShowHtmlSource = true;
#endif
mShowHtmlSource = mShowHtmlSource || !qEnvironmentVariableIsEmpty("MESSAGEVIEWER_HTML_SOURCE_DEBUG");
if (mShowHtmlSource) {
mTabWidget = new QTabWidget(this);
mainLayout->addWidget(mTabWidget);
mTabWidget->addTab(mRawBrowser, i18nc("Unchanged mail message", "Raw Source"));
mTabWidget->setTabToolTip(0,
i18n(
"Raw, unmodified mail as it is stored on the filesystem or on the server"));
mHtmlBrowser = new MailSourceViewTextBrowserWidget(QStringLiteral("HTML"), this);
mTabWidget->addTab(mHtmlBrowser, i18nc("Mail message as shown, in HTML format", "HTML Source"));
mTabWidget->setTabToolTip(1, i18n("HTML code for displaying the message to the user"));
mTabWidget->setCurrentIndex(0);
} else {
mainLayout->addWidget(mRawBrowser);
}
// combining the shortcuts in one qkeysequence() did not work...
QShortcut *shortcut = new QShortcut(this);
......@@ -106,22 +109,20 @@ void MailSourceWebEngineViewer::setRawSource(const QString &source)
void MailSourceWebEngineViewer::setDisplayedSource(QWebEnginePage *page)
{
#ifndef NDEBUG
if (page) {
MailSourceViewTextBrowserWidget *browser = mHtmlBrowser;
page->toHtml([browser](const QString &result) {
browser->setPlainText(result);
});
if (mShowHtmlSource) {
if (page) {
MailSourceViewTextBrowserWidget *browser = mHtmlBrowser;
page->toHtml([browser](const QString &result) {
browser->setPlainText(result);
});
}
}
#else
Q_UNUSED(page);
#endif
}
void MailSourceWebEngineViewer::setFixedFont()
{
mRawBrowser->setFixedFont();
#ifndef NDEBUG
mHtmlBrowser->setFixedFont();
#endif
if (mShowHtmlSource) {
mHtmlBrowser->setFixedFont();
}
}
......@@ -39,12 +39,11 @@ public:
void setDisplayedSource(QWebEnginePage *page);
void setFixedFont();
private:
MailSourceViewTextBrowserWidget *mRawBrowser;
FindBarSourceView *mFindBar;
#ifndef NDEBUG
QTabWidget *mTabWidget;
MailSourceViewTextBrowserWidget *mHtmlBrowser;
#endif
MailSourceViewTextBrowserWidget *mRawBrowser = nullptr;
FindBarSourceView *mFindBar = nullptr;
QTabWidget *mTabWidget = nullptr;
MailSourceViewTextBrowserWidget *mHtmlBrowser = nullptr;
bool mShowHtmlSource = false;
};
}
#endif // MAILSOURCEWEBENGINEVIEWER_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment