OSDN Git Service

2154dce5ff8456673527ac92dfd4a68e564c19f7
[qt-creator-jp/qt-creator-jp.git] / src / libs / qmleditorwidgets / gradientline.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef GRADIENTLINE_H
35 #define GRADIENTLINE_H
36
37 #include <qmleditorwidgets_global.h>
38 #include <QtGui/QWidget>
39 #include <QtGui/QLinearGradient>
40
41 namespace QmlEditorWidgets {
42
43 class QMLEDITORWIDGETS_EXPORT GradientLine : public QWidget {
44     Q_OBJECT
45     Q_PROPERTY(QColor activeColor READ activeColor WRITE setActiveColor NOTIFY activeColorChanged)
46     Q_PROPERTY(QString gradientName READ gradientName WRITE setGradientName NOTIFY gradientNameChanged)
47     Q_PROPERTY(bool active READ active WRITE setActive)
48     Q_PROPERTY(QLinearGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged)
49
50 public:
51     GradientLine(QWidget *parent = 0);
52
53     QString gradientName() const { return m_gradientName; }
54     void setGradientName(const QString &newName);
55     QColor activeColor() const { return m_activeColor; }
56     void setActiveColor(const QColor &newColor);
57     bool active() const { return m_active; }
58     void setActive(bool a) { m_active = a; }
59     QLinearGradient gradient() const { return m_gradient; }
60     void setGradient(const QLinearGradient &);
61
62 signals:
63     void activeColorChanged();
64     void itemNodeChanged();
65     void gradientNameChanged();
66     void gradientChanged();
67     void openColorDialog(const QPoint &pos);
68 protected:
69     bool event(QEvent *event);
70     void keyPressEvent(QKeyEvent * event);
71     void paintEvent(QPaintEvent *event);
72     void mousePressEvent(QMouseEvent *event);
73     void mouseDoubleClickEvent(QMouseEvent *event);
74     void mouseReleaseEvent(QMouseEvent *);
75     void mouseMoveEvent(QMouseEvent *);
76
77 private:
78     void setup();
79     void readGradient();
80     void updateGradient();
81     int currentColorIndex() const { return m_colorIndex; }
82     void setCurrentIndex(int i);
83
84     QColor m_activeColor;
85     QString m_gradientName;
86     QList<QColor> m_colorList;
87     QList<qreal> m_stops;
88     int m_colorIndex;
89     bool m_dragActive;
90     QPoint m_dragStart;
91     QLinearGradient m_gradient;
92     int m_yOffset;
93     bool m_create;
94     bool m_active;
95     bool m_dragOff;
96     bool m_useGradient;
97
98 };
99
100 } //QmlEditorWidgets
101
102 #endif //GRADIENTLINE_H