Author: jghali
Date: Tue Dec  8 11:50:14 2020
New Revision: 24311

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

Modified:
    trunk/Scribus/scribus/ui/arcwidget.cpp
    trunk/Scribus/scribus/ui/polygonwidget.cpp
    trunk/Scribus/scribus/ui/spiralwidget.cpp

Modified: trunk/Scribus/scribus/ui/arcwidget.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=24311&path=/trunk/Scribus/scribus/ui/arcwidget.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/arcwidget.cpp      (original)
+++ trunk/Scribus/scribus/ui/arcwidget.cpp      Tue Dec  8 11:50:14 2020
@@ -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: trunk/Scribus/scribus/ui/polygonwidget.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=24311&path=/trunk/Scribus/scribus/ui/polygonwidget.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/polygonwidget.cpp  (original)
+++ trunk/Scribus/scribus/ui/polygonwidget.cpp  Tue Dec  8 11:50:14 2020
@@ -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: trunk/Scribus/scribus/ui/spiralwidget.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=24311&path=/trunk/Scribus/scribus/ui/spiralwidget.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/spiralwidget.cpp   (original)
+++ trunk/Scribus/scribus/ui/spiralwidget.cpp   Tue Dec  8 11:50:14 2020
@@ -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);
+}


_______________________________________________
scribus-commit mailing list
[email protected]
http://lists.scribus.net/mailman/listinfo/scribus-commit

Reply via email to