Retrieve font color from qt defaults and use it to set color in webkit-based elements (reslist and snippets window). User still needs to use the prefs to fix the font size. Closes issue #251

This commit is contained in:
Jean-Francois Dockes 2015-06-07 14:12:09 +02:00
parent 05a5d0c3b7
commit f00fa77d45
4 changed files with 24 additions and 10 deletions

View file

@ -27,6 +27,7 @@
#include "base64.h"
#include "advshist.h"
#include <QApplication>
#include <QSettings>
#include <QStringList>
#include <QFileDialog>
@ -146,6 +147,8 @@ void rwSettings(bool writing)
SETTING_RW(prefs.reslistfontsize, "/Recoll/prefs/reslist/fontSize", Int,
10);
prefs.fontcolor = QApplication::palette().text().color().name();
QString rlfDflt = QString::fromUtf8(prefs.dfltResListFormat);
if (writing) {
if (prefs.reslistformat.compare(rlfDflt)) {

View file

@ -50,6 +50,10 @@ class PrefsPack {
int respagesize;
int maxhltextmbs;
QString reslistfontfamily;
// Not saved in prefs for now. Computed from qt defaults and used to
// set main character color for webkit/textbrowser reslist and
// snippets window.
QString fontcolor;
QString qtermcolor; // Color for query terms in reslist and preview
int reslistfontsize;
// Result list format string

View file

@ -183,15 +183,17 @@ string QtGuiResListPager::prevUrl()
string QtGuiResListPager::headerContent()
{
string out;
#ifdef SETFONT_WITH_HEADSTYLE
out = "<style type=\"text/css\">\nbody,table,select,input {\n";
#ifdef SETFONT_WITH_HEADSTYLE
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 += string("color: ") + qs2utf8s(prefs.fontcolor) + ";\n";
out += string("}\n</style>\n");
out += qs2utf8s(prefs.reslistheadertext);
return out;
}

View file

@ -144,14 +144,19 @@ void SnippetsW::init()
ostringstream oss;
oss <<
"<html><head>"
"<meta http-equiv=\"content-type\" "
"content=\"text/html; charset=utf-8\">"
"<link type=\"text/css\" rel=\"stylesheet\" href=\"/tmp/style.css\">"
"</head>"
"<body>"
"<table>"
;
"<html><head>"
"<meta http-equiv=\"content-type\" "
"content=\"text/html; charset=utf-8\">";
oss << "<style type=\"text/css\">\nbody,table,select,input {\n";
oss << "color: " + qs2utf8s(prefs.fontcolor) + ";\n";
oss << "}\n</style>\n";
oss <<
"</head>"
"<body>"
"<table>"
;
g_hiliter.set_inputhtml(false);
bool nomatch = true;