1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QTGRADIENTWIDGET_H |
5 | #define QTGRADIENTWIDGET_H |
6 | |
7 | #include <QtWidgets/QWidget> |
8 | |
9 | QT_BEGIN_NAMESPACE |
10 | |
11 | class QtGradientWidget : public QWidget |
12 | { |
13 | Q_OBJECT |
14 | Q_PROPERTY(bool backgroundCheckered READ isBackgroundCheckered WRITE setBackgroundCheckered) |
15 | public: |
16 | QtGradientWidget(QWidget *parent = 0); |
17 | ~QtGradientWidget(); |
18 | |
19 | QSize minimumSizeHint() const override; |
20 | QSize sizeHint() const override; |
21 | int heightForWidth(int w) const override; |
22 | |
23 | bool isBackgroundCheckered() const; |
24 | void setBackgroundCheckered(bool checkered); |
25 | |
26 | QGradientStops gradientStops() const; |
27 | |
28 | void setGradientType(QGradient::Type type); |
29 | QGradient::Type gradientType() const; |
30 | |
31 | void setGradientSpread(QGradient::Spread spread); |
32 | QGradient::Spread gradientSpread() const; |
33 | |
34 | void setStartLinear(const QPointF &point); |
35 | QPointF startLinear() const; |
36 | |
37 | void setEndLinear(const QPointF &point); |
38 | QPointF endLinear() const; |
39 | |
40 | void setCentralRadial(const QPointF &point); |
41 | QPointF centralRadial() const; |
42 | |
43 | void setFocalRadial(const QPointF &point); |
44 | QPointF focalRadial() const; |
45 | |
46 | void setRadiusRadial(qreal radius); |
47 | qreal radiusRadial() const; |
48 | |
49 | void setCentralConical(const QPointF &point); |
50 | QPointF centralConical() const; |
51 | |
52 | void setAngleConical(qreal angle); |
53 | qreal angleConical() const; |
54 | |
55 | public slots: |
56 | void setGradientStops(const QGradientStops &stops); |
57 | |
58 | signals: |
59 | |
60 | void startLinearChanged(const QPointF &point); |
61 | void endLinearChanged(const QPointF &point); |
62 | void centralRadialChanged(const QPointF &point); |
63 | void focalRadialChanged(const QPointF &point); |
64 | void radiusRadialChanged(qreal radius); |
65 | void centralConicalChanged(const QPointF &point); |
66 | void angleConicalChanged(qreal angle); |
67 | |
68 | protected: |
69 | void paintEvent(QPaintEvent *e) override; |
70 | void mousePressEvent(QMouseEvent *e) override; |
71 | void mouseReleaseEvent(QMouseEvent *e) override; |
72 | void mouseMoveEvent(QMouseEvent *e) override; |
73 | void mouseDoubleClickEvent(QMouseEvent *e) override; |
74 | |
75 | private: |
76 | QScopedPointer<class QtGradientWidgetPrivate> d_ptr; |
77 | Q_DECLARE_PRIVATE(QtGradientWidget) |
78 | Q_DISABLE_COPY_MOVE(QtGradientWidget) |
79 | }; |
80 | |
81 | QT_END_NAMESPACE |
82 | |
83 | #endif |
84 |