GUI: allow setting full CSS style for term highlighting, not only color value

This commit is contained in:
Jean-Francois Dockes 2016-08-12 19:13:29 +02:00
parent e0aa229c28
commit 4f51c69806
8 changed files with 31 additions and 17 deletions

View File

@ -130,9 +130,24 @@ void rwSettings(bool writing)
SETTING_RW(prefs.previewPlainPre, SETTING_RW(prefs.previewPlainPre,
"/Recoll/prefs/preview/plainPre", Int, PrefsPack::PP_PREWRAP); "/Recoll/prefs/preview/plainPre", Int, PrefsPack::PP_PREWRAP);
SETTING_RW(prefs.qtermcolor, "/Recoll/prefs/qtermcolor", String, "blue");
if (!writing && prefs.qtermcolor == "") // History: used to be able to only set a bare color name. Can now
prefs.qtermcolor = "blue"; // set any CSS style. Hack on ':' presence to keep compat with old
// values
SETTING_RW(prefs.qtermstyle, "/Recoll/prefs/qtermcolor", String,
"color: blue");
if (!writing && prefs.qtermstyle == "")
prefs.qtermstyle = "color: blue";
{ // histo compatibility hack
int colon = prefs.qtermstyle.indexOf(":");
int semi = prefs.qtermstyle.indexOf(";");
// The 2nd part of the test is to keep compat with the
// injection hack of the 1st user who suggested this (had
// #ff5000;font-size:110%;... in 'qtermcolor')
if (colon == -1 || (colon != -1 && semi != -1 && semi < colon)) {
prefs.qtermstyle = QString::fromUtf8("color: ") + prefs.qtermstyle;
}
}
// Abstract snippet separator // Abstract snippet separator
SETTING_RW(prefs.abssep, "/Recoll/prefs/reslist/abssep", String,"&hellip;"); SETTING_RW(prefs.abssep, "/Recoll/prefs/reslist/abssep", String,"&hellip;");

View File

@ -54,7 +54,7 @@ class PrefsPack {
// set main character color for webkit/textbrowser reslist and // set main character color for webkit/textbrowser reslist and
// snippets window. // snippets window.
QString fontcolor; QString fontcolor;
QString qtermcolor; // Color for query terms in reslist and preview QString qtermstyle; // CSS style for query terms in reslist and other places
int reslistfontsize; int reslistfontsize;
// Result list format string // Result list format string
QString reslistformat; QString reslistformat;

View File

@ -76,9 +76,8 @@ string PlainToRichQtPreview::startMatch(unsigned int grpidx)
LOGDEB2("startMatch, ugrpidx " << (grpidx) << "\n" ); LOGDEB2("startMatch, ugrpidx " << (grpidx) << "\n" );
m_groupanchors[grpidx].push_back(++m_lastanchor); m_groupanchors[grpidx].push_back(++m_lastanchor);
m_groupcuranchors[grpidx] = 0; m_groupcuranchors[grpidx] = 0;
return string("<span style='color: "). return string("<span style='").
append((const char *)(prefs.qtermcolor.toUtf8())). append(qs2utf8s(prefs.qtermstyle)).
append(";font-weight: bold;").
append("'>"). append("'>").
append("<a name=\""). append("<a name=\"").
append(termAnchorName(m_lastanchor)). append(termAnchorName(m_lastanchor)).

View File

@ -286,8 +286,8 @@ public:
LOGDEB("Reslist startmatch: group " << (s1) << " user group " << (s2) << "\n" ); LOGDEB("Reslist startmatch: group " << (s1) << " user group " << (s2) << "\n" );
} }
return string("<span class='rclmatch' style='color: ") return string("<span class='rclmatch' style='")
+ qs2utf8s(prefs.qtermcolor) + string("'>"); + qs2utf8s(prefs.qtermstyle) + string("'>");
} }
virtual string endMatch() virtual string endMatch()
{ {

View File

@ -67,8 +67,8 @@ public:
virtual ~PlainToRichQtReslist() {} virtual ~PlainToRichQtReslist() {}
virtual string startMatch(unsigned int) virtual string startMatch(unsigned int)
{ {
return string("<span style='color: ") return string("<span style='")
+ qs2utf8s(prefs.qtermcolor) + string("'>"); + qs2utf8s(prefs.qtermstyle) + string("'>");
} }
virtual string endMatch() {return string("</span>");} virtual string endMatch() {return string("</span>");}
}; };

View File

@ -52,8 +52,8 @@ class PlainToRichQtSnippets : public PlainToRich {
public: public:
virtual string startMatch(unsigned int) virtual string startMatch(unsigned int)
{ {
return string("<span class='rclmatch' style='color: ") return string("<span class='rclmatch' style='")
+ qs2utf8s(prefs.qtermcolor) + string("'>"); + qs2utf8s(prefs.qtermstyle) + string("'>");
} }
virtual string endMatch() virtual string endMatch()
{ {

View File

@ -36,7 +36,7 @@
<item> <item>
<widget class="QLabel" name="textLabelqtc"> <widget class="QLabel" name="textLabelqtc">
<property name="text"> <property name="text">
<string>Highlight color for query terms</string> <string>Highlight CSS style for query terms</string>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>false</bool> <bool>false</bool>
@ -44,7 +44,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="qtermColorLE"> <widget class="QLineEdit" name="qtermStyleLE">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>50</width> <width>50</width>

View File

@ -154,7 +154,7 @@ void UIPrefsDialog::setFromPrefs()
break; break;
} }
// Query terms color // Query terms color
qtermColorLE->setText(prefs.qtermcolor); qtermStyleLE->setText(prefs.qtermstyle);
// Abstract snippet separator string // Abstract snippet separator string
abssepLE->setText(prefs.abssep); abssepLE->setText(prefs.abssep);
dateformatLE->setText(prefs.reslistdateformat); dateformatLE->setText(prefs.reslistdateformat);
@ -286,7 +286,7 @@ void UIPrefsDialog::accept()
prefs.collapseDuplicates = collapseDupsCB->isChecked(); prefs.collapseDuplicates = collapseDupsCB->isChecked();
prefs.maxhltextmbs = maxHLTSB->value(); prefs.maxhltextmbs = maxHLTSB->value();
prefs.qtermcolor = qtermColorLE->text(); prefs.qtermstyle = qtermStyleLE->text();
prefs.abssep = abssepLE->text(); prefs.abssep = abssepLE->text();
prefs.reslistdateformat = dateformatLE->text(); prefs.reslistdateformat = dateformatLE->text();
prefs.creslistdateformat = (const char*)prefs.reslistdateformat.toUtf8(); prefs.creslistdateformat = (const char*)prefs.reslistdateformat.toUtf8();