From a6c53ff651485a3903a6f4e2999fb1fd8bf7e32a Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Thu, 10 Sep 2020 13:53:12 +0200 Subject: [PATCH] fix result table display in dark mode --- src/Makefile.am | 7 ++++-- src/qtgui/restable.cpp | 43 +++++++++++++--------------------- src/sampleconf/recoll-dark.css | 14 +++++++++++ src/sampleconf/recoll-dark.qss | 21 ++++------------- 4 files changed, 39 insertions(+), 46 deletions(-) create mode 100644 src/sampleconf/recoll-dark.css diff --git a/src/Makefile.am b/src/Makefile.am index 9e0ffc6b..16cfbf65 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -556,7 +556,8 @@ python/samples/recollqsd.py \ \ sampleconf/fields sampleconf/fragbuts.xml sampleconf/mimeconf \ sampleconf/mimemap sampleconf/mimeview sampleconf/mimeview.mac \ -sampleconf/recoll.conf sampleconf/recoll.qss sampleconf/recoll-dark.qss \ +sampleconf/recoll.conf sampleconf/recoll.qss \ +sampleconf/recoll-dark.qss sampleconf/recoll-dark.css \ \ testmains/Makefile.am \ \ @@ -645,6 +646,8 @@ sampleconf/fields \ sampleconf/recoll.conf \ sampleconf/mimeconf \ sampleconf/recoll.qss \ +sampleconf/recoll-dark.qss \ +sampleconf/recoll-dark.css \ sampleconf/mimemap \ sampleconf/mimeview @@ -754,7 +757,7 @@ dist_man5_MANS = doc/man/recoll.conf.5 dist-hook: (cd $(top_srcdir); find . \ \( -name '*.pyc' -o -name '#*' -o -name '*~' \) -delete) - if test -z "$(NOTAG)";then \ + if test -z "$(NOTAG)";then \ test -z "`git status -s|grep -v recoll-$(VERSION)`"||exit 1; \ vers=`echo $(VERSION) | sed -e 's/~/_/g'`;\ git tag -a RECOLL-$$vers -m "Release $$vers tagged"; \ diff --git a/src/qtgui/restable.cpp b/src/qtgui/restable.cpp index 289b81c7..7e460599 100644 --- a/src/qtgui/restable.cpp +++ b/src/qtgui/restable.cpp @@ -483,8 +483,7 @@ public: // difficult. Anyway, the display seems fast enough as is. void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { - QStyleOptionViewItem opt = option; - initStyleOption(&opt, index); + QVariant value = index.data(Qt::DisplayRole); QString text; if (value.isValid() && !value.isNull()) { @@ -495,39 +494,29 @@ public: return; } + QStyleOptionViewItem opt = option; + initStyleOption(&opt, index); + painter->save(); QTextDocument document; + QString color = opt.palette.color(QPalette::Text).name(); + QString selcolor = opt.palette.color(QPalette::BrightText).name(); QString fstyle; if (prefs.reslistfontsize > 0) { int fs = prefs.reslistfontsize <= fsadjusttable ? - prefs.reslistfontsize : - prefs.reslistfontsize - fsadjusttable; + prefs.reslistfontsize : prefs.reslistfontsize - fsadjusttable; fstyle = QString("font-size: %1pt").arg(fs); } - if (opt.state & QStyle::State_Selected) { - painter->fillRect(opt.rect, opt.palette.highlight()); - // Set the foreground color. Tried with pen - // approach did not seem to work, probably it's - // reset by the textdocument. Couldn't use - // setdefaultstylesheet() either. the div thing is - // an ugly hack. Works for now - QString ntxt("
"; - ntxt += text + QString::fromUtf8("
"); - text.swap(ntxt); - } else { - if (!fstyle.isEmpty()) { - QString ntxt("
") + text + QString("
"); - text.swap(ntxt); - } - } - painter->setClipRect(option.rect); + QString ntxt("
") + text + QString("
"); + text.swap(ntxt); + + painter->setClipRect(opt.rect); QPoint where = option.rect.topLeft(); where.ry() += TEXTINCELLVTRANS; painter->translate(where); diff --git a/src/sampleconf/recoll-dark.css b/src/sampleconf/recoll-dark.css new file mode 100644 index 00000000..520cfb6e --- /dev/null +++ b/src/sampleconf/recoll-dark.css @@ -0,0 +1,14 @@ + +/* Result list HTML Header insert */ + + diff --git a/src/sampleconf/recoll-dark.qss b/src/sampleconf/recoll-dark.qss index 2604ade5..5ee4fd6e 100644 --- a/src/sampleconf/recoll-dark.qss +++ b/src/sampleconf/recoll-dark.qss @@ -15,16 +15,7 @@ result list: Preferences->GUI configuration->Result list-> Edit result page html header insert - For example: - - - + See recoll-dark.css in src/sampleconf of share/examples */ /* Light on dark text everywhere*/ @@ -57,13 +48,9 @@ QTabWidget QTabBar::tab:selected { color: #ffffff; } -/* - * Slightly *darker* background for text entry areas, and brighter - * (lighter) foreground. - * QTableView excluded until we fix the font color... - */ -QComboBox[editable="true"], QTextEdit, QLineEdit, -QTextBrowser, QWebView, QPlainTextEdit { +/* Slightly *darker* background for text entry areas. */ +QComboBox[editable="true"], QTextEdit[editable="true"], QLineEdit, +QPlainTextEdit { background-color: #101010; color: #ffffff; }