[PATCH] usermanual.cpp: use default QWidget theme colors for text selections

Lubomir I. Ivanov neolit123 at gmail.com
Tue Oct 13 08:06:51 PDT 2015


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

The default selection text/background colors (also when seaching)
are black/light-grey in QWebView, for some reason.

To solve the issue we pass a stylesheet that makes use of the
default palette's highlight() and highlightedText() from QWidget.

Fixes #797

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
 qt-ui/usermanual.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/qt-ui/usermanual.cpp b/qt-ui/usermanual.cpp
index 6bbfb79..6b676f1 100644
--- a/qt-ui/usermanual.cpp
+++ b/qt-ui/usermanual.cpp
@@ -54,8 +54,11 @@ UserManual::UserManual(QWidget *parent) : QWidget(parent)
 	setWindowTitle(tr("User manual"));
 	setWindowIcon(QIcon(":/subsurface-icon"));
 
-
 	userManual = new QWebView(this);
+	QString colorBack = palette().highlight().color().name(QColor::HexRgb);
+	QString colorText = palette().highlightedText().color().name(QColor::HexRgb);
+	userManual->setStyleSheet(QString("QWebView { selection-background-color: %1; selection-color: %2; }")
+		.arg(colorBack).arg(colorText));
 	userManual->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
 	QString searchPath = getSubsurfaceDataPath("Documentation");
 	if (searchPath.size()) {
-- 
1.7.11.msysgit.0



More information about the subsurface mailing list