r24397 by jghali - Backport r24311: Improve rendering of arc, polygon and spiral widgets in dark mode

scribus-commit scribus-commit at lists.scribus.net
Tue Jan 12 13:11:50 UTC 2021


Author: jghali
Date: Tue Jan 12 13:11:49 2021
New Revision: 24397

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24397
Log:
Backport r24311: Improve rendering of arc, polygon and spiral widgets in dark mode

Modified:
    branches/Version156/Scribus/scribus/ui/arcwidget.cpp
    branches/Version156/Scribus/scribus/ui/polygonwidget.cpp
    branches/Version156/Scribus/scribus/ui/spiralwidget.cpp

Modified: branches/Version156/Scribus/scribus/ui/arcwidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24397&path=/branches/Version156/Scribus/scribus/ui/arcwidget.cpp
==============================================================================
--- branches/Version156/Scribus/scribus/ui/arcwidget.cpp	(original)
+++ branches/Version156/Scribus/scribus/ui/arcwidget.cpp	Tue Jan 12 13:11:49 2021
@@ -68,15 +68,19 @@
 	int pixWidth = Preview->width() - 5;
 	int pixHeight = Preview->height() - 5;
 
+	const QPalette& palette = this->palette();
+	const QColor& textColor = palette.color(QPalette::Text);
+	const QColor& windowColor = palette.color(QPalette::Base);
+
 	QPixmap pm = QPixmap(pixWidth * devicePixelRatioF(), pixHeight * devicePixelRatioF());
 	pm.setDevicePixelRatio(devicePixelRatioF());
-	pm.fill(Qt::white);
+	pm.fill(windowColor);
 
 	QPainter p;
 	p.begin(&pm);
 	p.setRenderHint(QPainter::Antialiasing, true);
 	p.setBrush(Qt::NoBrush);
-	p.setPen(Qt::black);
+	p.setPen(textColor);
 	QPainterPath path;
 	path.moveTo(pixWidth / 2.0, pixHeight / 2.0);
 	double nSweep = endAngle->value() - startAngle->value();

Modified: branches/Version156/Scribus/scribus/ui/polygonwidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24397&path=/branches/Version156/Scribus/scribus/ui/polygonwidget.cpp
==============================================================================
--- branches/Version156/Scribus/scribus/ui/polygonwidget.cpp	(original)
+++ branches/Version156/Scribus/scribus/ui/polygonwidget.cpp	Tue Jan 12 13:11:49 2021
@@ -215,15 +215,19 @@
 	int pixWidth = (Preview->width() - 5) * devicePixelRatioF();
 	int pixHeight = (Preview->height() - 5) * devicePixelRatioF();
 
+	const QPalette& palette = this->palette();
+	const QColor& textColor = palette.color(QPalette::Text);
+	const QColor& windowColor = palette.color(QPalette::Base);
+
 	QPixmap pm(pixWidth, pixHeight);
 	pm.setDevicePixelRatio(devicePixelRatioF());
-	pm.fill(Qt::white);
+	pm.fill(windowColor);
 
 	QPainter p;
 	p.begin(&pm);
 	p.setRenderHint(QPainter::Antialiasing, true);
 	p.setBrush(Qt::NoBrush);
-	p.setPen(Qt::black);
+	p.setPen(textColor);
 	QPainterPath pp = regularPolygonPath(polyWidth, polyHeight, cornersSpinBox->value(), applyConvexGroupBox->isChecked(), GetFactor(), rotationSlider->value(), roundness, innerRotationSpinBox->value(), innerround);
 	QRectF br = pp.boundingRect();
 	if (br.x() < 0)

Modified: branches/Version156/Scribus/scribus/ui/spiralwidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24397&path=/branches/Version156/Scribus/scribus/ui/spiralwidget.cpp
==============================================================================
--- branches/Version156/Scribus/scribus/ui/spiralwidget.cpp	(original)
+++ branches/Version156/Scribus/scribus/ui/spiralwidget.cpp	Tue Jan 12 13:11:49 2021
@@ -1,91 +1,95 @@
-/*
-For general Scribus (>=1.3.2) copyright and licensing information please refer
-to the COPYING file provided with the program. Following this notice may exist
-a copyright and/or license notice that predates the release of Scribus 1.3.2
-for which a new license (GPL+exception) is in place.
-*/
-#include "spiralwidget.h"
-#include "scconfig.h"
-#include <QPixmap>
-#include <QPainter>
-#include <QPainterPath>
-#include <QRectF>
-
-#if defined(_MSC_VER) && !defined(_USE_MATH_DEFINES)
-#define _USE_MATH_DEFINES
-#endif
-#include <cmath>
-
-#include "util_math.h"
-#include "prefsstructs.h"
-
-SpiralWidget::SpiralWidget(QWidget* parent) : QWidget( parent )
-{
-	setupUi(this);
-	startAngle->setNewUnit(6);
-	arcFactor->setDecimals(0);
-	startAngle->setValues(0, 36000, 1, 0);
-	endAngle->setNewUnit(6);
-	endAngle->setValues(0, 36000, 1, 0);
-}
-
-void SpiralWidget::connectSignals(bool conn)
-{
-	if (conn)
-	{
-		connect(startAngle, SIGNAL(valueChanged(double)), this, SLOT(updatePreview()));
-		connect(endAngle, SIGNAL(valueChanged(double)), this, SLOT(updatePreview()));
-		connect(arcFactor, SIGNAL(valueChanged(double)), this, SLOT(updatePreview()));
-	}
-	else
-	{
-		disconnect(startAngle, SIGNAL(valueChanged(double)), this, SLOT(updatePreview()));
-		disconnect(endAngle, SIGNAL(valueChanged(double)), this, SLOT(updatePreview()));
-		disconnect(arcFactor, SIGNAL(valueChanged(double)), this, SLOT(updatePreview()));
-	}
-}
-
-
-void SpiralWidget::restoreDefaults(struct ItemToolPrefs *prefsData)
-{
-	connectSignals(false);
-	startAngle->setValue(prefsData->spiralStartAngle);
-	endAngle->setValue(prefsData->spiralEndAngle);
-	arcFactor->setValue(qRound(prefsData->spiralFactor * 100) - 100);
-	updatePreview();
-	connectSignals(true);
-}
-
-void SpiralWidget::saveGuiToPrefs(struct ItemToolPrefs *prefsData)
-{
-	prefsData->spiralStartAngle = startAngle->value();
-	prefsData->spiralEndAngle = endAngle->value();
-	prefsData->spiralFactor = (static_cast<int>(arcFactor->value()) + 100) / 100.0;
-}
-
-void SpiralWidget::updatePreview()
-{
-	startAngle->setMaximum(endAngle->value() - 1);
-	endAngle->setMinimum(startAngle->value() + 1);
-	
-	int spiralWidth = Preview->width() - 11;
-	int spiralHeight = Preview->height() - 11;
-	int pixWidth = (Preview->width() - 5) * devicePixelRatioF();
-	int pixHeight = (Preview->height() - 5) * devicePixelRatioF();
-
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+#include "spiralwidget.h"
+#include "scconfig.h"
+#include <QPixmap>
+#include <QPainter>
+#include <QPainterPath>
+#include <QRectF>
+
+#if defined(_MSC_VER) && !defined(_USE_MATH_DEFINES)
+#define _USE_MATH_DEFINES
+#endif
+#include <cmath>
+
+#include "util_math.h"
+#include "prefsstructs.h"
+
+SpiralWidget::SpiralWidget(QWidget* parent) : QWidget( parent )
+{
+	setupUi(this);
+	startAngle->setNewUnit(6);
+	arcFactor->setDecimals(0);
+	startAngle->setValues(0, 36000, 1, 0);
+	endAngle->setNewUnit(6);
+	endAngle->setValues(0, 36000, 1, 0);
+}
+
+void SpiralWidget::connectSignals(bool conn)
+{
+	if (conn)
+	{
+		connect(startAngle, SIGNAL(valueChanged(double)), this, SLOT(updatePreview()));
+		connect(endAngle, SIGNAL(valueChanged(double)), this, SLOT(updatePreview()));
+		connect(arcFactor, SIGNAL(valueChanged(double)), this, SLOT(updatePreview()));
+	}
+	else
+	{
+		disconnect(startAngle, SIGNAL(valueChanged(double)), this, SLOT(updatePreview()));
+		disconnect(endAngle, SIGNAL(valueChanged(double)), this, SLOT(updatePreview()));
+		disconnect(arcFactor, SIGNAL(valueChanged(double)), this, SLOT(updatePreview()));
+	}
+}
+
+
+void SpiralWidget::restoreDefaults(struct ItemToolPrefs *prefsData)
+{
+	connectSignals(false);
+	startAngle->setValue(prefsData->spiralStartAngle);
+	endAngle->setValue(prefsData->spiralEndAngle);
+	arcFactor->setValue(qRound(prefsData->spiralFactor * 100) - 100);
+	updatePreview();
+	connectSignals(true);
+}
+
+void SpiralWidget::saveGuiToPrefs(struct ItemToolPrefs *prefsData)
+{
+	prefsData->spiralStartAngle = startAngle->value();
+	prefsData->spiralEndAngle = endAngle->value();
+	prefsData->spiralFactor = (static_cast<int>(arcFactor->value()) + 100) / 100.0;
+}
+
+void SpiralWidget::updatePreview()
+{
+	startAngle->setMaximum(endAngle->value() - 1);
+	endAngle->setMinimum(startAngle->value() + 1);
+	
+	int spiralWidth = Preview->width() - 11;
+	int spiralHeight = Preview->height() - 11;
+	int pixWidth = (Preview->width() - 5) * devicePixelRatioF();
+	int pixHeight = (Preview->height() - 5) * devicePixelRatioF();
+
+	const QPalette& palette = this->palette();
+	const QColor& textColor = palette.color(QPalette::Text);
+	const QColor& windowColor = palette.color(QPalette::Base);
+
 	QPixmap pm(pixWidth, pixHeight);
 	pm.setDevicePixelRatio(devicePixelRatioF());
-	pm.fill(Qt::white);
-
-	QPainter p;
-	p.begin(&pm);
-	p.setRenderHint(QPainter::Antialiasing, true);
-	p.setBrush(Qt::NoBrush);
-	p.setPen(Qt::black);
-	QPainterPath path = spiralPath(spiralWidth, spiralHeight, startAngle->value(), endAngle->value(), (static_cast<int>(arcFactor->value()) + 100) / 100.0);
-	path.translate(3, 3);
-	p.strokePath(path, p.pen());
-	p.end();
-
-	Preview->setPixmap(pm);
-}
+	pm.fill(windowColor);
+
+	QPainter p;
+	p.begin(&pm);
+	p.setRenderHint(QPainter::Antialiasing, true);
+	p.setBrush(Qt::NoBrush);
+	p.setPen(textColor);
+	QPainterPath path = spiralPath(spiralWidth, spiralHeight, startAngle->value(), endAngle->value(), (static_cast<int>(arcFactor->value()) + 100) / 100.0);
+	path.translate(3, 3);
+	p.strokePath(path, p.pen());
+	p.end();
+
+	Preview->setPixmap(pm);
+}




More information about the scribus-commit mailing list