summaryrefslogtreecommitdiff
path: root/src/shared/qtgradienteditor
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/qtgradienteditor')
-rw-r--r--src/shared/qtgradienteditor/qtcolorline.h2
-rw-r--r--src/shared/qtgradienteditor/qtgradienteditor.cpp2
-rw-r--r--src/shared/qtgradienteditor/qtgradientview.cpp3
-rw-r--r--src/shared/qtgradienteditor/qtgradientwidget.cpp53
4 files changed, 30 insertions, 30 deletions
diff --git a/src/shared/qtgradienteditor/qtcolorline.h b/src/shared/qtgradienteditor/qtcolorline.h
index 606d0fa84..6d19ed4d9 100644
--- a/src/shared/qtgradienteditor/qtcolorline.h
+++ b/src/shared/qtgradienteditor/qtcolorline.h
@@ -54,7 +54,6 @@ class QtColorLine : public QWidget
Q_PROPERTY(bool backgroundCheckered READ isBackgroundCheckered WRITE setBackgroundCheckered)
Q_PROPERTY(ColorComponent colorComponent READ colorComponent WRITE setColorComponent)
Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
- Q_ENUMS(ColorComponent)
public:
enum ColorComponent {
@@ -66,6 +65,7 @@ public:
Value,
Alpha
};
+ Q_ENUM(ColorComponent)
QSize minimumSizeHint() const;
QSize sizeHint() const;
diff --git a/src/shared/qtgradienteditor/qtgradienteditor.cpp b/src/shared/qtgradienteditor/qtgradienteditor.cpp
index 25e9fdb2a..57d35b83a 100644
--- a/src/shared/qtgradienteditor/qtgradienteditor.cpp
+++ b/src/shared/qtgradienteditor/qtgradienteditor.cpp
@@ -41,6 +41,8 @@
#include "qtgradientstopscontroller.h"
#include "ui_qtgradienteditor.h"
+#include <QtWidgets/QButtonGroup>
+
QT_BEGIN_NAMESPACE
class QtGradientEditorPrivate
diff --git a/src/shared/qtgradienteditor/qtgradientview.cpp b/src/shared/qtgradienteditor/qtgradientview.cpp
index a0d4790e6..29c33574e 100644
--- a/src/shared/qtgradienteditor/qtgradientview.cpp
+++ b/src/shared/qtgradienteditor/qtgradientview.cpp
@@ -41,9 +41,10 @@
#include "qtgradientmanager.h"
#include "qtgradientdialog.h"
#include "qtgradientutils.h"
+#include <QtGui/QClipboard>
#include <QtGui/QPainter>
+#include <QtWidgets/QAction>
#include <QtWidgets/QMessageBox>
-#include <QtGui/QClipboard>
QT_BEGIN_NAMESPACE
diff --git a/src/shared/qtgradienteditor/qtgradientwidget.cpp b/src/shared/qtgradienteditor/qtgradientwidget.cpp
index 73c448578..24226384a 100644
--- a/src/shared/qtgradienteditor/qtgradientwidget.cpp
+++ b/src/shared/qtgradienteditor/qtgradientwidget.cpp
@@ -49,12 +49,7 @@
#define _USE_MATH_DEFINES
#endif
-
-#include "math.h"
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
+#include "qmath.h"
QT_BEGIN_NAMESPACE
@@ -343,7 +338,7 @@ void QtGradientWidget::mousePressEvent(QMouseEvent *e)
if (r1.contains(pF) || r2.contains(pF) || r3.contains(pF)) {
x = pF.x() / size().width() - d_ptr->m_centralRadial.x();
y = pF.y() / size().height() - d_ptr->m_centralRadial.y();
- double clickRadius = sqrt(x * x + y * y);
+ const double clickRadius = hypot(x, y);
//d_ptr->m_radiusOffset = d_ptr->m_radiusRadial - clickRadius;
d_ptr->m_radiusFactor = d_ptr->m_radiusRadial / clickRadius;
if (d_ptr->m_radiusFactor == 0)
@@ -382,7 +377,7 @@ void QtGradientWidget::mousePressEvent(QMouseEvent *e)
y = current.y() - central.y();
x /= size().width() / 2;
y /= size().height() / 2;
- double angle = atan2(-y, x) * 180 / M_PI;
+ const double angle = qRadiansToDegrees(atan2(-y, x));
d_ptr->m_angleOffset = d_ptr->m_angleConical - angle;
d_ptr->m_dragAngle = d_ptr->m_angleConical;
@@ -442,7 +437,7 @@ void QtGradientWidget::mouseMoveEvent(QMouseEvent *e)
} else {
x = pF.x() / size().width() - d_ptr->m_centralRadial.x();
y = pF.y() / size().height() - d_ptr->m_centralRadial.y();
- double moveRadius = sqrt(x * x + y * y);
+ const double moveRadius = hypot(x, y);
//double newRadius = moveRadius + d_ptr->m_radiusOffset;
double newRadius = moveRadius * d_ptr->m_radiusFactor;
if (newRadius > 2)
@@ -472,7 +467,7 @@ void QtGradientWidget::mouseMoveEvent(QMouseEvent *e)
x /= size().width() / 2;
y /= size().height() / 2;
- double angle = atan2(-y, x) * 180 / M_PI + d_ptr->m_angleOffset;
+ const double angle = qRadiansToDegrees(atan2(-y, x)) + d_ptr->m_angleOffset;
d_ptr->setAngleConical(angle);
}
}
@@ -619,28 +614,30 @@ void QtGradientWidget::paintEvent(QPaintEvent *e)
p.setBrush(Qt::NoBrush);
int pointCount = 2;
for (int i = 0; i < pointCount; i++) {
- QPointF ang(cos(M_PI * (i * 180.0 / pointCount + d_ptr->m_angleConical) / 180) * size().width() / 2,
- -sin(M_PI * (i * 180.0 / pointCount + d_ptr->m_angleConical) / 180) * size().height() / 2);
- double mod = sqrt(ang.x() * ang.x() + ang.y() * ang.y());
- p.drawLine(QPointF(central.x() + ang.x() * (radius - corr) / mod,
- central.y() + ang.y() * (radius - corr) / mod),
- QPointF(central.x() + ang.x() * (radius + corr) / mod,
- central.y() + ang.y() * (radius + corr) / mod));
- p.drawLine(QPointF(central.x() - ang.x() * (radius - corr) / mod,
- central.y() - ang.y() * (radius - corr) / mod),
- QPointF(central.x() - ang.x() * (radius + corr) / mod,
- central.y() - ang.y() * (radius + corr) / mod));
+ const qreal angle = qDegreesToRadians(i * 180.0 / pointCount + d_ptr->m_angleConical);
+ const QPointF ray(cos(angle) * size().width() / 2,
+ -sin(angle) * size().height() / 2);
+ const double mod = hypot(ray.x(), ray.y());
+ p.drawLine(QPointF(central.x() + ray.x() * (radius - corr) / mod,
+ central.y() + ray.y() * (radius - corr) / mod),
+ QPointF(central.x() + ray.x() * (radius + corr) / mod,
+ central.y() + ray.y() * (radius + corr) / mod));
+ p.drawLine(QPointF(central.x() - ray.x() * (radius - corr) / mod,
+ central.y() - ray.y() * (radius - corr) / mod),
+ QPointF(central.x() - ray.x() * (radius + corr) / mod,
+ central.y() - ray.y() * (radius + corr) / mod));
}
if (d_ptr->m_dragHandle == QtGradientWidgetPrivate::AngleConicalHandle) {
p.save();
p.setPen(dragPen);
- QPointF ang(cos(M_PI * (d_ptr->m_angleConical - d_ptr->m_angleOffset) / 180) * size().width() / 2,
- -sin(M_PI * (d_ptr->m_angleConical - d_ptr->m_angleOffset) / 180) * size().height() / 2);
- double mod = sqrt(ang.x() * ang.x() + ang.y() * ang.y());
- p.drawLine(QPointF(central.x() + ang.x() * (radius - corr) / mod,
- central.y() + ang.y() * (radius - corr) / mod),
- QPointF(central.x() + ang.x() * (radius + corr) / mod,
- central.y() + ang.y() * (radius + corr) / mod));
+ const qreal angle = qDegreesToRadians(d_ptr->m_angleConical - d_ptr->m_angleOffset);
+ const QPointF ray(cos(angle) * size().width() / 2,
+ -sin(angle) * size().height() / 2);
+ const double mod = hypot(ray.x(), ray.y());
+ p.drawLine(QPointF(central.x() + ray.x() * (radius - corr) / mod,
+ central.y() + ray.y() * (radius - corr) / mod),
+ QPointF(central.x() + ray.x() * (radius + corr) / mod,
+ central.y() + ray.y() * (radius + corr) / mod));
p.restore();
}