compensate for off-by-3 error when setting webkit font size with QWebSettings. Experiment (ifndefed) with using css instead
This commit is contained in:
parent
7714de2cac
commit
c28b1f91cc
@ -70,6 +70,13 @@ static const QKeySequence closeKeySeq("Ctrl+w");
|
||||
#include <QWebSettings>
|
||||
#endif
|
||||
|
||||
// Decide if we set font family and style with a css section in the
|
||||
// html <head> or with qwebsettings setfont... calls. We currently do
|
||||
// it with websettings because this gives an instant redisplay, and
|
||||
// the css has a tendancy to not find some system fonts. Otoh,
|
||||
// SetFontSize() needs a strange offset of 3, not needed with css.
|
||||
#undef SETFONT_WITH_HEADSTYLE
|
||||
|
||||
class QtGuiResListPager : public ResListPager {
|
||||
public:
|
||||
QtGuiResListPager(ResList *p, int ps)
|
||||
@ -175,7 +182,18 @@ string QtGuiResListPager::prevUrl()
|
||||
|
||||
string QtGuiResListPager::headerContent()
|
||||
{
|
||||
return (const char *)prefs.reslistheadertext.toUtf8();
|
||||
string out;
|
||||
#ifdef SETFONT_WITH_HEADSTYLE
|
||||
out = "<style type=\"text/css\">\nbody,table,select,input {\n";
|
||||
char ftsz[30];
|
||||
sprintf(ftsz, "%d", prefs.reslistfontsize);
|
||||
out += string("font-family: \"") + qs2utf8s(prefs.reslistfontfamily)
|
||||
+ "\";\n";
|
||||
out += string("font-size: ") + ftsz + "pt;\n";
|
||||
out += string("}\n</style>\n");
|
||||
#endif
|
||||
out += qs2utf8s(prefs.reslistheadertext);
|
||||
return out;
|
||||
}
|
||||
|
||||
void QtGuiResListPager::suggest(const vector<string>uterms,
|
||||
@ -378,10 +396,13 @@ void ResList::setFont()
|
||||
QTextBrowser::setFont(QFont());
|
||||
}
|
||||
#else
|
||||
#ifndef SETFONT_WITH_HEADSTYLE
|
||||
QWebSettings *websettings = settings();
|
||||
if (prefs.reslistfontfamily.length()) {
|
||||
// For some reason there is (12-2014) an offset of 3 between what
|
||||
// we request from webkit and what we get.
|
||||
websettings->setFontSize(QWebSettings::DefaultFontSize,
|
||||
prefs.reslistfontsize);
|
||||
prefs.reslistfontsize + 3);
|
||||
websettings->setFontFamily(QWebSettings::StandardFont,
|
||||
prefs.reslistfontfamily);
|
||||
} else {
|
||||
@ -389,6 +410,7 @@ void ResList::setFont()
|
||||
websettings->resetFontFamily(QWebSettings::StandardFont);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
int ResList::newListId()
|
||||
|
||||
@ -377,10 +377,14 @@ void UIPrefsDialog::showFontDialog()
|
||||
|
||||
font = QFontDialog::getFont(&ok, font, this);
|
||||
if (ok) {
|
||||
// Check if the default font was set, in which case we
|
||||
// erase the preference
|
||||
// We used to check if the default font was set, in which case
|
||||
// we erased the preference, but this would result in letting
|
||||
// webkit make a choice of default font which it usually seems
|
||||
// to do wrong. So now always set the font. There is still a
|
||||
// way for the user to let webkit choose the default though:
|
||||
// click reset, then the font name and size will be empty.
|
||||
QString s;
|
||||
if (font.family().compare(this->font().family()) ||
|
||||
if (1 || font.family().compare(this->font().family()) ||
|
||||
font.pointSize() != this->font().pointSize()) {
|
||||
reslistFontFamily = font.family();
|
||||
reslistFontSize = font.pointSize();
|
||||
|
||||
@ -38,8 +38,8 @@ using std::list;
|
||||
#include "mimehandler.h"
|
||||
|
||||
// Default highlighter. No need for locking, this is query-only.
|
||||
static const string cstr_hlfontcolor("<font color=\"blue\">");
|
||||
static const string cstr_hlendfont("</font>");
|
||||
static const string cstr_hlfontcolor("<span style='color: blue;'>");
|
||||
static const string cstr_hlendfont("</span>");
|
||||
class PlainToRichHtReslist : public PlainToRich {
|
||||
public:
|
||||
virtual string startMatch(unsigned int)
|
||||
@ -361,9 +361,9 @@ void ResListPager::displayPage(RclConfig *config)
|
||||
<< headerContent()
|
||||
<< "</head><body>" << endl
|
||||
<< pageTop()
|
||||
<< "<p><font size=+1><b>"
|
||||
<< "<p><span style=\"font-size:110%;\"><b>"
|
||||
<< m_docSource->title()
|
||||
<< "</b></font> ";
|
||||
<< "</b></span> ";
|
||||
|
||||
if (pageEmpty()) {
|
||||
chunk << trans("<p><b>No results found</b><br>");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user