diff options
Diffstat (limited to 'examples/widgets/painting/gradients')
-rw-r--r-- | examples/widgets/painting/gradients/gradients.cpp | 22 | ||||
-rw-r--r-- | examples/widgets/painting/gradients/gradients.h | 10 | ||||
-rw-r--r-- | examples/widgets/painting/gradients/main.cpp | 2 |
3 files changed, 12 insertions, 22 deletions
diff --git a/examples/widgets/painting/gradients/gradients.cpp b/examples/widgets/painting/gradients/gradients.cpp index 1474c4ffaf..09985df8fa 100644 --- a/examples/widgets/painting/gradients/gradients.cpp +++ b/examples/widgets/painting/gradients/gradients.cpp @@ -62,7 +62,6 @@ ShadeWidget::ShadeWidget(ShadeType type, QWidget *parent) } else { setAttribute(Qt::WA_NoBackground); - } QPolygonF points; @@ -81,13 +80,11 @@ ShadeWidget::ShadeWidget(ShadeType type, QWidget *parent) connect(m_hoverPoints, SIGNAL(pointsChanged(QPolygonF)), this, SIGNAL(colorsChanged())); } - QPolygonF ShadeWidget::points() const { return m_hoverPoints->points(); } - uint ShadeWidget::colorAt(int x) { generateShade(); @@ -104,7 +101,6 @@ uint ShadeWidget::colorAt(int x) return 0; } - void ShadeWidget::setGradientStops(const QGradientStops &stops) { if (m_shade_type == ARGBShade) { @@ -121,7 +117,6 @@ void ShadeWidget::setGradientStops(const QGradientStops &stops) } } - void ShadeWidget::paintEvent(QPaintEvent *) { generateShade(); @@ -133,7 +128,6 @@ void ShadeWidget::paintEvent(QPaintEvent *) p.drawRect(0, 0, width() - 1, height() - 1); } - void ShadeWidget::generateShade() { if (m_shade.isNull() || m_shade.size() != size()) { @@ -167,11 +161,8 @@ void ShadeWidget::generateShade() p.fillRect(rect(), shade); } } - - } - GradientEditor::GradientEditor(QWidget *parent) : QWidget(parent) { @@ -195,13 +186,11 @@ GradientEditor::GradientEditor(QWidget *parent) connect(m_alpha_shade, SIGNAL(colorsChanged()), this, SLOT(pointsUpdated())); } - inline static bool x_less_than(const QPointF &p1, const QPointF &p2) { return p1.x() < p2.x(); } - void GradientEditor::pointsUpdated() { qreal w = m_alpha_shade->width(); @@ -217,9 +206,9 @@ void GradientEditor::pointsUpdated() qSort(points.begin(), points.end(), x_less_than); - for (int i=0; i<points.size(); ++i) { + for (int i = 0; i < points.size(); ++i) { qreal x = int(points.at(i).x()); - if (i+1 < points.size() && x == points.at(i+1).x()) + if (i + 1 < points.size() && x == points.at(i + 1).x()) continue; QColor color((0x00ff0000 & m_red_shade->colorAt(int(x))) >> 16, (0x0000ff00 & m_green_shade->colorAt(int(x))) >> 8, @@ -237,7 +226,6 @@ void GradientEditor::pointsUpdated() emit gradientStopsChanged(stops); } - static void set_shade_points(const QPolygonF &points, ShadeWidget *shade) { shade->hoverPoints()->setPoints(points); @@ -255,7 +243,7 @@ void GradientEditor::setGradientStops(const QGradientStops &stops) qreal h_blue = m_blue_shade->height(); qreal h_alpha = m_alpha_shade->height(); - for (int i=0; i<stops.size(); ++i) { + for (int i = 0; i < stops.size(); ++i) { qreal pos = stops.at(i).first; QRgb color = stops.at(i).second.rgba(); pts_red << QPointF(pos * m_red_shade->width(), h_red - qRed(color) * h_red / 255); @@ -454,7 +442,6 @@ void GradientWidget::setDefault(int config) m_renderer->setGradientStops(stops); } - GradientRenderer::GradientRenderer(QWidget *parent) : ArthurFrame(parent) { @@ -477,7 +464,6 @@ void GradientRenderer::setGradientStops(const QGradientStops &stops) update(); } - void GradientRenderer::mousePressEvent(QMouseEvent *) { setDescriptionEnabled(false); @@ -503,7 +489,7 @@ void GradientRenderer::paint(QPainter *p) g = QConicalGradient(pts.at(0), angle); } - for (int i=0; i<m_stops.size(); ++i) + for (int i = 0; i < m_stops.size(); ++i) g.setColorAt(m_stops.at(i).first, m_stops.at(i).second); g.setSpread(m_spread); diff --git a/examples/widgets/painting/gradients/gradients.h b/examples/widgets/painting/gradients/gradients.h index 0881d864f3..c816bddd0b 100644 --- a/examples/widgets/painting/gradients/gradients.h +++ b/examples/widgets/painting/gradients/gradients.h @@ -44,7 +44,9 @@ #include "arthurwidgets.h" -#include <QtWidgets> +QT_BEGIN_NAMESPACE +class QRadioButton; +QT_END_NAMESPACE class HoverPoints; @@ -52,6 +54,7 @@ class HoverPoints; class ShadeWidget : public QWidget { Q_OBJECT + public: enum ShadeType { RedShade, @@ -88,6 +91,7 @@ private: class GradientEditor : public QWidget { Q_OBJECT + public: GradientEditor(QWidget *parent); @@ -106,10 +110,10 @@ private: ShadeWidget *m_alpha_shade; }; - class GradientRenderer : public ArthurFrame { Q_OBJECT + public: GradientRenderer(QWidget *parent); void paint(QPainter *p); @@ -139,10 +143,10 @@ private: Qt::BrushStyle m_gradientType; }; - class GradientWidget : public QWidget { Q_OBJECT + public: GradientWidget(QWidget *parent); diff --git a/examples/widgets/painting/gradients/main.cpp b/examples/widgets/painting/gradients/main.cpp index ce179a7312..6ffba86acc 100644 --- a/examples/widgets/painting/gradients/main.cpp +++ b/examples/widgets/painting/gradients/main.cpp @@ -43,7 +43,7 @@ #include <QApplication> -int main(int argc, char **argv) +int main(int argc, char *argv[]) { Q_INIT_RESOURCE(gradients); |