OSDN Git Service

b11d3dc422c138361ae752ce0326e9151662cd3e
[qt-creator-jp/qt-creator-jp.git] / src / libs / qmleditorwidgets / contextpanewidget.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 CONTEXTPANEWIDGET_H
35 #define CONTEXTPANEWIDGET_H
36
37 #include <qmleditorwidgets_global.h>
38 #include <QtGui/QFrame>
39 #include <QtCore/QWeakPointer>
40
41 QT_BEGIN_NAMESPACE
42 class QToolButton;
43 class QVariant;
44 class QGraphicsDropShadowEffect;
45 class QGraphicsOpacityEffect;
46 QT_END_NAMESPACE
47
48 namespace QmlJS {
49     class PropertyReader;
50 }
51
52 namespace QmlEditorWidgets {
53
54 class CustomColorDialog;
55 class ContextPaneTextWidget;
56 class EasingContextPane;
57 class ContextPaneWidgetRectangle;
58 class ContextPaneWidgetImage;
59
60 class QMLEDITORWIDGETS_EXPORT DragWidget : public QFrame
61 {
62     Q_OBJECT
63
64 public:
65     explicit DragWidget(QWidget *parent = 0);
66     void setSecondaryTarget(QWidget* w)
67     { m_secondaryTarget = w; }
68
69 protected:
70     QPoint m_pos;
71     void mousePressEvent(QMouseEvent * event);
72     void mouseReleaseEvent(QMouseEvent * event);
73     void mouseMoveEvent(QMouseEvent * event);
74     void virtual protectedMoved();
75     void leaveEvent(QEvent *);
76     void enterEvent(QEvent *);
77
78 private:
79     QGraphicsDropShadowEffect *m_dropShadowEffect;
80     QGraphicsOpacityEffect *m_opacityEffect;
81     QPoint m_startPos;
82     QWeakPointer<QWidget> m_secondaryTarget;
83 };
84
85 class QMLEDITORWIDGETS_EXPORT ContextPaneWidget : public DragWidget
86 {
87     Q_OBJECT
88
89 public:
90     explicit ContextPaneWidget(QWidget *parent = 0);
91     ~ContextPaneWidget();
92     void activate(const QPoint &pos, const QPoint &alternative, const QPoint &alternative2, bool pinned);
93     void rePosition(const QPoint &pos, const QPoint &alternative , const QPoint &alternative3, bool pinned);
94     void deactivate();
95     void setOptions(bool enabled, bool pinned);
96     CustomColorDialog *colorDialog();
97     void setProperties(QmlJS::PropertyReader *propertyReader);
98     void setPath(const QString &path);
99     bool setType(const QStringList &types);
100     bool acceptsType(const QStringList &types);
101     QWidget* currentWidget() const { return m_currentWidget; }
102     void setIsPropertyChanges(bool b)
103     { m_isPropertyChanges = b; }
104     bool isPropertyChanges() const
105     { return m_isPropertyChanges; }
106
107 public slots:
108     void onTogglePane();
109     void onShowColorDialog(bool, const QPoint &);
110
111 signals:
112     void propertyChanged(const QString &, const QVariant &);
113     void removeProperty(const QString &);
114     void removeAndChangeProperty(const QString &, const QString &, const QVariant &, bool);
115     void pinnedChanged(bool);
116     void enabledChanged(bool);
117     void closed();
118
119 private slots:
120     void onDisable(bool);
121     void onResetPosition(bool toggle);
122
123 protected:
124
125     void protectedMoved();
126
127     QToolButton *m_toolButton;
128     QWidget *createFontWidget();
129     QWidget *createEasingWidget();
130     QWidget *createImageWidget();
131     QWidget *createBorderImageWidget();
132     QWidget *createRectangleWidget();
133
134     void setPinButton();
135     void setLineButton();
136
137 private:
138     QWidget *m_currentWidget;
139     ContextPaneTextWidget *m_textWidget;
140     EasingContextPane *m_easingWidget;
141     ContextPaneWidgetImage *m_imageWidget;
142     ContextPaneWidgetImage *m_borderImageWidget;
143     ContextPaneWidgetRectangle *m_rectangleWidget;
144     QWeakPointer<CustomColorDialog> m_bauhausColorDialog;
145     QWeakPointer<QAction> m_resetAction;
146     QWeakPointer<QAction> m_disableAction;
147     QString m_colorName;
148     QPoint m_originalPos;
149     bool m_pinned;
150     bool m_isPropertyChanges;
151 };
152
153 } //QmlDesigner
154
155 #endif // CONTEXTPANEWIDGET_H