1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
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
16 ** GNU Lesser General Public License Usage
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.
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.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #ifndef GRADIENTLINE_H
35 #define GRADIENTLINE_H
37 #include <qmleditorwidgets_global.h>
38 #include <QtGui/QWidget>
39 #include <QtGui/QLinearGradient>
41 namespace QmlEditorWidgets {
43 class QMLEDITORWIDGETS_EXPORT GradientLine : public QWidget {
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)
51 GradientLine(QWidget *parent = 0);
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 &);
63 void activeColorChanged();
64 void itemNodeChanged();
65 void gradientNameChanged();
66 void gradientChanged();
67 void openColorDialog(const QPoint &pos);
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 *);
80 void updateGradient();
81 int currentColorIndex() const { return m_colorIndex; }
82 void setCurrentIndex(int i);
85 QString m_gradientName;
86 QList<QColor> m_colorList;
91 QLinearGradient m_gradient;
102 #endif //GRADIENTLINE_H