Commit 729c2337 authored by Laurent Montel's avatar Laurent Montel 😁

When we disable emoticon, disable it in header too

parent 79949843
......@@ -90,7 +90,7 @@ QString GrantleeHeaderFormatter::toHtml(
return format(
settings.theme.absolutePath(), headerTemplate,
settings.theme.displayExtraVariables(), settings.isPrinting, settings.style, settings.message,
settings.showMailAction);
settings.showMailAction, settings.showEmoticons);
}
QString GrantleeHeaderFormatter::toHtml(const QStringList &displayExtraHeaders,
......@@ -110,7 +110,7 @@ QString GrantleeHeaderFormatter::format(const QString &absolutePath,
const Grantlee::Template &headerTemplate,
const QStringList &displayExtraHeaders, bool isPrinting,
const MessageViewer::HeaderStyle *style,
KMime::Message *message, bool showMailAction) const
KMime::Message *message, bool showMailAction, bool showEmoticons) const
{
QVariantHash headerObject;
......@@ -129,7 +129,10 @@ QString GrantleeHeaderFormatter::format(const QString &absolutePath,
d->headerStyleUtil.subjectDirectionString(message));
headerObject.insert(QStringLiteral("subjecti18n"), i18n("Subject:"));
const KTextToHTML::Options flags = KTextToHTML::PreserveSpaces | KTextToHTML::ReplaceSmileys;
KTextToHTML::Options flags = KTextToHTML::PreserveSpaces;
if (showEmoticons) {
flags |= KTextToHTML::ReplaceSmileys;
}
headerObject.insert(QStringLiteral("subject"),
d->headerStyleUtil.subjectString(message, flags));
......
......@@ -39,6 +39,7 @@ public:
, style(nullptr)
, message(nullptr)
, showMailAction(true)
, showEmoticons(true)
{
}
......@@ -47,6 +48,7 @@ public:
mutable const MessageViewer::HeaderStyle *style;
KMime::Message *message;
bool showMailAction;
bool showEmoticons;
};
explicit GrantleeHeaderFormatter();
......@@ -61,7 +63,7 @@ private:
QString format(const QString &absolutePath, const Grantlee::Template &headerTemplate,
const QStringList &displayExtraHeaders, bool isPrinting,
const MessageViewer::HeaderStyle *style, KMime::Message *message,
bool showMailAction = true) const;
bool showMailAction = true, bool showEmoticons = true) const;
class Private;
Private *const d;
};
......
......@@ -72,6 +72,7 @@ QString GrantleeHeaderStyle::format(KMime::Message *message) const
settings.style = this;
settings.message = message;
settings.showMailAction = d->mShowMailAction;
settings.showEmoticons = showEmoticons();
return d->mGrantleeFormatter->toHtml(settings);
}
......
......@@ -50,6 +50,7 @@ public:
, mTopLevel(true)
, mAllowAsync(false)
, mReadOnlyMessage(false)
, mShowEmoticons(true)
{
}
......@@ -65,6 +66,7 @@ public:
bool mTopLevel;
bool mAllowAsync;
bool mReadOnlyMessage;
bool mShowEmoticons;
};
HeaderStyle::HeaderStyle()
......@@ -201,3 +203,13 @@ void HeaderStyle::setReadOnlyMessage(bool readOnlyMessage)
{
d->mReadOnlyMessage = readOnlyMessage;
}
bool HeaderStyle::showEmoticons() const
{
return d->mShowEmoticons;
}
void HeaderStyle::setShowEmoticons(bool b)
{
d->mShowEmoticons = b;
}
......@@ -119,6 +119,9 @@ public:
bool readOnlyMessage() const;
void setReadOnlyMessage(bool readOnlyMessage);
bool showEmoticons() const;
void setShowEmoticons(bool b);
private:
HeaderStylePrivate *const d;
};
......
......@@ -24,11 +24,13 @@ class MessageViewer::HeaderStylePluginPrivate
{
public:
HeaderStylePluginPrivate()
: mIsEnabled(false)
: mIsEnabled(false),
mShowEmoticons(true)
{
}
bool mIsEnabled;
bool mShowEmoticons;
};
HeaderStylePlugin::HeaderStylePlugin(QObject *parent)
......@@ -77,3 +79,4 @@ void HeaderStylePlugin::showConfigureDialog(QWidget *parent)
Q_UNUSED(parent);
//Reimplement
}
......@@ -53,6 +53,7 @@ public:
virtual bool hasConfigureDialog() const;
virtual void showConfigureDialog(QWidget *parent);
private:
HeaderStylePluginPrivate *const d;
};
......
......@@ -110,8 +110,10 @@ QString PlainHeaderStyle::format(KMime::Message *message) const
//case HdrLong:
if (strategy->showHeader(QStringLiteral("subject"))) {
const KTextToHTML::Options flags = KTextToHTML::PreserveSpaces
| KTextToHTML::ReplaceSmileys;
KTextToHTML::Options flags = KTextToHTML::PreserveSpaces;
if (showEmoticons()) {
flags |= KTextToHTML::ReplaceSmileys;
}
headerStr += QStringLiteral("<div dir=\"%1\"><b style=\"font-size:130%\">").arg(subjectDir)
+d->mHeaderStyleUtil.subjectString(message, flags) + QLatin1String(
......
......@@ -3335,5 +3335,6 @@ void ViewerPrivate::setPrintElementBackground(bool printElementBackground)
void ViewerPrivate::slotToggleEmoticons()
{
mForceEmoticons = !mForceEmoticons;
headerStylePlugin()->headerStyle()->setShowEmoticons(mForceEmoticons);
update(MimeTreeParser::Force);
}
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