Fix Bézier spline broken on locales with numerical separator != .

Fix Bézier colors with dark themes
CCBUG: 357659
parent b0211b4c
......@@ -162,7 +162,7 @@ void BezierSplineEditor::paintEvent(QPaintEvent* event)
}
p.setPen(QPen(Qt::gray, 1, Qt::SolidLine));
p.setPen(QPen(palette().mid().color(), 1, Qt::SolidLine));
/*
* Borders
......@@ -210,7 +210,7 @@ void BezierSplineEditor::paintEvent(QPaintEvent* event)
next = m_spline.getPoint(i + 1, wWidth, wHeight, true);
splinePath.cubicTo(point.h2, next.h1, next.p);
}
p.setPen(QPen(Qt::black, 1, Qt::SolidLine));
p.setPen(QPen(palette().text().color(), 1, Qt::SolidLine));
p.drawPath(splinePath);
......
......@@ -48,7 +48,7 @@ CubicBezierSpline& CubicBezierSpline::operator=(const CubicBezierSpline& spline)
void CubicBezierSpline::fromString(const QString& spline)
{
m_points.clear();
QLocale locale;
const QStringList bpoints = spline.split(QLatin1Char('|'));
foreach(const QString &bpoint, bpoints) {
const QStringList points = bpoint.split(QLatin1Char('#'));
......@@ -56,7 +56,7 @@ void CubicBezierSpline::fromString(const QString& spline)
foreach(const QString &point, points) {
QStringList xy = point.split(QLatin1Char(';'));
if (xy.count() == 2)
values.append(QPointF(xy.at(0).toDouble(), xy.at(1).toDouble()));
values.append(QPointF(locale.toDouble(xy.at(0)), locale.toDouble(xy.at(1))));
}
if (values.count() == 3) {
m_points.append(BPoint(values.at(0), values.at(1), values.at(2)));
......
/*
* Copyright (c) 2005 Casper Boemann <cbr@boemann.dk>
* Copyright (c) 2005 C. Boemann <cbo@boemann.dk>
* Copyright (c) 2009 Dmitry Kazakov <dimula73@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
......@@ -42,10 +42,6 @@
#include <QSpinBox>
// KDE includes.
#include <kcursor.h>
#define bounds(x,a,b) (x<a ? a : (x>b ? b :x))
#define MOUSE_AWAY_THRES 15
#define POINT_AREA 1E-4
......@@ -86,8 +82,7 @@ KisCurveWidget::KisCurveWidget(QWidget *parent, Qt::WindowFlags f)
KisCurveWidget::~KisCurveWidget()
{
if (d->m_pixmapCache)
delete d->m_pixmapCache;
delete d->m_pixmapCache;
delete d;
}
......@@ -223,18 +218,18 @@ void KisCurveWidget::paintEvent(QPaintEvent *)
int wHeight = height() - 1;
QPainter p(this);
// Antialiasing is not a good idea here, because
// the grid will drift one pixel to any side due to rounding of int
// FIXME: let's user tell the last word (in config)
//p.setRenderHint(QPainter::Antialiasing);
// fill with color to show widget bounds
p.fillRect(rect(), palette().base());
// draw background
if (!d->m_pix.isNull()) {
if (d->m_pixmapDirty || !d->m_pixmapCache) {
if (d->m_pixmapCache)
delete d->m_pixmapCache;
delete d->m_pixmapCache;
d->m_pixmapCache = new QPixmap(width(), height());
QPainter cachePainter(d->m_pixmapCache);
......@@ -243,43 +238,29 @@ void KisCurveWidget::paintEvent(QPaintEvent *)
d->m_pixmapDirty = false;
}
p.drawPixmap(0, 0, *d->m_pixmapCache);
} else
p.fillRect(rect(), palette().background());
}
d->drawGrid(p, wWidth, wHeight);
/*KisConfig cfg;
if (cfg.antialiasCurves())
p.setRenderHint(QPainter::Antialiasing);*/
p.setRenderHint(QPainter::Antialiasing);
// Draw default line
p.setPen(QPen(Qt::gray, 1, Qt::SolidLine));
p.setPen(QPen(palette().mid().color(), 1, Qt::SolidLine));
p.drawLine(QLineF(0, wHeight, wWidth, 0));
// Draw curve.
double prevY = wHeight - d->m_curve.value(0.) * wHeight;
double prevX = 0.;
int x;
QPolygonF poly;
p.setPen(QPen(Qt::black, 1, Qt::SolidLine));
p.setPen(QPen(palette().text().color(), 1, Qt::SolidLine));
for (x = 0 ; x < wWidth ; ++x) {
double normalizedX = double(x) / wWidth;
double curY = wHeight - d->m_curve.value(normalizedX) * wHeight;
/**
* Keep in mind that QLineF rounds doubles
* to ints mathematically, not just rounds down
* like in C
*/
p.drawLine(QLineF(prevX, prevY,
x, curY));
prevX = x;
prevY = curY;
poly.append(QPointF(x, curY));
}
p.drawLine(QLineF(prevX, prevY ,
x, wHeight - d->m_curve.value(1.0) * wHeight));
poly.append(QPointF(x, wHeight - d->m_curve.value(1.0) * wHeight));
p.drawPolyline(poly);
// Drawing curve handles.
if (!d->m_readOnlyMode) {
......
......@@ -36,7 +36,6 @@ class KisCurveWidget::Private
public:
explicit Private(KisCurveWidget *parent);
virtual ~Private();
/* Dragging variables */
int m_grab_point_index;
......@@ -150,11 +149,6 @@ KisCurveWidget::Private::Private(KisCurveWidget *parent)
m_maxPoints = 0;
}
KisCurveWidget::Private::~Private()
{
}
double KisCurveWidget::Private::io2sp(int x)
{
int rangeLen = m_inOutMax - m_inOutMin;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment