summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-06-23 15:01:59 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-06-23 15:01:59 +0200
commit0ff830ff10df95c0f4507925c07114354c70ae6f (patch)
treecc4e3428609d3b70569b3a0d61356d690353a7d5
parent6ffde9d47bef4d37aa6f778ac893956fe879a86a (diff)
downloadkube-0ff830ff10df95c0f4507925c07114354c70ae6f.tar.gz
kube-0ff830ff10df95c0f4507925c07114354c70ae6f.zip
Add a basic css to html mails to suppress scrollbars.
https://stackoverflow.com/questions/32612478/remove-scrollbars-from-qwebengineview-or-qwebenginepage
-rw-r--r--framework/src/domain/mime/partmodel.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/framework/src/domain/mime/partmodel.cpp b/framework/src/domain/mime/partmodel.cpp
index eeeb391d..0f4afcd8 100644
--- a/framework/src/domain/mime/partmodel.cpp
+++ b/framework/src/domain/mime/partmodel.cpp
@@ -114,6 +114,20 @@ QModelIndex PartModel::index(int row, int column, const QModelIndex &parent) con
114 return QModelIndex(); 114 return QModelIndex();
115} 115}
116 116
117static QString addCss(const QString &s)
118{
119 //overflow:hidden ensures no scrollbars are ever shown.
120 const auto css = "<style>\n"
121 "body {\n"
122 "overflow:hidden;\n"
123 "}\n"
124 "</style>";
125 const auto header = QLatin1String("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n"
126 "<html><head><title></title>")
127 + css + QLatin1String("</head>\n<body>\n");
128 return header + s + QStringLiteral("</body></html>");
129}
130
117QVariant PartModel::data(const QModelIndex &index, int role) const 131QVariant PartModel::data(const QModelIndex &index, int role) const
118{ 132{
119 if (!index.isValid()) { 133 if (!index.isValid()) {
@@ -177,7 +191,7 @@ QVariant PartModel::data(const QModelIndex &index, int role) const
177 case ContentRole: { 191 case ContentRole: {
178 const auto text = messagePart->isHtml() ? messagePart->htmlContent() : messagePart->text(); 192 const auto text = messagePart->isHtml() ? messagePart->htmlContent() : messagePart->text();
179 if (messagePart->isHtml()) { 193 if (messagePart->isHtml()) {
180 return d->mParser->resolveCidLinks(text); 194 return addCss(d->mParser->resolveCidLinks(text));
181 } else { //We assume plain 195 } else { //We assume plain
182 //We alwas do richtext (so we get highlighted links and stuff). 196 //We alwas do richtext (so we get highlighted links and stuff).
183 return HtmlUtils::linkify(Qt::convertFromPlainText(text)); 197 return HtmlUtils::linkify(Qt::convertFromPlainText(text));
@@ -198,6 +212,8 @@ QVariant PartModel::data(const QModelIndex &index, int role) const
198 return tr("Wrong passphrase."); 212 return tr("Wrong passphrase.");
199 case MimeTreeParser::MessagePart::UnknownError: 213 case MimeTreeParser::MessagePart::UnknownError:
200 break; 214 break;
215 default:
216 break;
201 } 217 }
202 return messagePart->errorString(); 218 return messagePart->errorString();
203 } 219 }