r23906 by jghali - Make rulers follow dark mode

scribus-commit scribus-commit at lists.scribus.net
Fri Jun 26 13:02:04 UTC 2020


Author: jghali
Date: Fri Jun 26 13:02:04 2020
New Revision: 23906

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23906
Log:
Make rulers follow dark mode

Modified:
    trunk/Scribus/scribus/ui/hruler.cpp
    trunk/Scribus/scribus/ui/vruler.cpp

Modified: trunk/Scribus/scribus/ui/hruler.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23906&path=/trunk/Scribus/scribus/ui/hruler.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/hruler.cpp	(original)
+++ trunk/Scribus/scribus/ui/hruler.cpp	Fri Jun 26 13:02:04 2020
@@ -44,7 +44,6 @@
 
 #include "iconmanager.h"
 
-
 #ifdef Q_OS_MAC
 #define topline 1
 #else
@@ -55,17 +54,12 @@
 #define midline (topline + rulerheight/2)
 #define tabline 7
 
-
-
 Hruler::Hruler(ScribusView *pa, ScribusDoc *doc) : QWidget(pa),
 	m_doc(doc),
 	m_view(pa)
 {
 	setBackgroundRole(QPalette::Window);
-	setAutoFillBackground(true);
-	QPalette palette;
-	palette.setBrush(QPalette::Window, QColor(240, 240, 240));
-	setPalette(palette);
+	//setAutoFillBackground(true);
 	setMouseTracking(true);
 	rulerGesture = new RulerGesture(m_view, RulerGesture::HORIZONTAL);
 	unitChange();
@@ -469,6 +463,8 @@
 	{
 		int rectX1 = textPosToLocal(m_distLeft);
 		int rectX2 = textPosToLocal(m_itemEndPos - m_itemPos - m_distRight);
+		const QPalette& palette = this->palette();
+		const QColor& textColor = palette.color(QPalette::Text);
 		p.eraseRect(QRect(QPoint(rectX1, 1), QPoint(rectX2, 15)));
 		p.drawLine(rectX1, 16, rectX2, 16);
 		p.save();
@@ -515,7 +511,7 @@
 
 			if (m_tabValues.count() != 0)
 			{
-				p.setPen(QPen(Qt::black, 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
+				p.setPen(QPen(textColor, 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
 				for (int yg = 0; yg < signed(m_tabValues.count()); yg++)
 				{
 					xPos = textPosToLocal(pos + m_tabValues[yg].tabPosition);
@@ -600,7 +596,8 @@
 	static const QColor BACKGROUND(255, 255, 255);
 	static QPixmap pix( 4*SCALE, 16*SCALE );
 	static bool initpix = true;
-	if (initpix) {
+	if (initpix)
+	{
 		initpix = false;
 		QPainter pp( &pix );
 		pp.setBrush( BACKGROUND );
@@ -614,14 +611,16 @@
 	// draw pixmap
 	p.save();
 	p.translate(-m_view->contentsX(), 0);
-	p.scale(1.0/SCALE, 1.0/(SCALE+1));
-	p.drawPixmap((where-2)*SCALE, 1, pix);
+	p.scale(1.0 / SCALE, 1.0 / (SCALE + 1));
+	p.drawPixmap((m_whereToDraw - 2) * SCALE, 1, pix);
 	p.restore();
 	// restore marks
-	p.setBrush(Qt::black);
-	p.setPen(Qt::black);
+	const QPalette& palette = this->palette();
+	const QColor& textColor = palette.color(QPalette::Text);
+	p.setBrush(textColor);
+	p.setPen(textColor);
 	p.setFont(font());
-	double sc = m_view->getScale();
+	double sc = m_view->scale();
 	double cc = width() / sc;
 	double firstMark = ceil(m_offset / m_iter) * m_iter - m_offset;
 	while (firstMark < cc)
@@ -643,9 +642,11 @@
 
 void Hruler::drawMarks(QPainter& p)
 {
-	p.setBrush(Qt::black);
-	p.setPen(Qt::black);
-	//p.drawLine(0, 16, width(), 16);
+	const QPalette& palette = this->palette();
+	const QColor& textColor = palette.color(QPalette::Text);
+	p.setBrush(textColor);
+	p.setPen(textColor);
+
 	double sc = m_scaling;
 	double cc = width() / sc;
 	double firstMark = ceil(m_offset / m_iter) * m_iter - m_offset;

Modified: trunk/Scribus/scribus/ui/vruler.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23906&path=/trunk/Scribus/scribus/ui/vruler.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/vruler.cpp	(original)
+++ trunk/Scribus/scribus/ui/vruler.cpp	Fri Jun 26 13:02:04 2020
@@ -46,10 +46,7 @@
 	m_view(pa)
 {
 	setBackgroundRole(QPalette::Window);
-	setAutoFillBackground(true);
-	QPalette palette;
-	palette.setBrush(QPalette::Window, QColor(240, 240, 240));
-	setPalette(palette);
+	//setAutoFillBackground(true);
 	setMouseTracking(true);
 	rulerGesture = new RulerGesture(m_view, RulerGesture::VERTICAL);
 	unitChange();
@@ -87,6 +84,10 @@
 		return;
 	QString tx;
 	double sc = m_view->scale();
+	
+	const QPalette& palette = this->palette();
+	const QColor& textColor = palette.color(QPalette::Text);
+	
 	QFont ff = font();
 	ff.setPointSize(6);
 	setFont(ff);
@@ -94,10 +95,10 @@
 	p.begin(this);
 	p.save();
 	p.setClipRect(e->rect());
-//	p.drawLine(16, 0, 16, height());
-	p.setBrush(Qt::black);
-	p.setPen(Qt::black);
+	p.setBrush(textColor);
+	p.setPen(textColor);
 	p.setFont(font());
+	
 	double cc = height() / sc;
 	double firstMark = ceil(m_offset / m_iter) * m_iter - m_offset;
 	while (firstMark < cc)
@@ -171,14 +172,14 @@
 		// draw pixmap
 		p.save();
 		p.translate(0, -m_view->contentsY());
-		p.scale(1.0/(SCALE+1), 1.0/SCALE);
-		p.drawPixmap(0, (where-2)*SCALE, pix);
+		p.scale(1.0 / (SCALE + 1), 1.0 / SCALE);
+		p.drawPixmap(0, (m_whereToDraw - 2) * SCALE, pix);
 		p.restore();
 		// repaint marks
-		p.setBrush(Qt::black);
-		p.setPen(Qt::black);
+		p.setBrush(textColor);
+		p.setPen(textColor);
 		p.setFont(font());
-		double sc = m_view->getScale();
+		double sc = m_view->scale();
 		double cc = height() / sc;
 		double firstMark = ceil(m_offset / m_iter) * m_iter - m_offset;
 		while (firstMark < cc)




More information about the scribus-commit mailing list