OSDN Git Service

It's 2011 now.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qmldesigner / components / propertyeditor / layoutwidget.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
35 #ifndef LAYOUTWIDGET_H
36 #define LAYOUTWIDGET_H
37
38 #include <QtGui/QFrame>
39 #include <QLabel>
40 #include <QPushButton>
41 #include <QUrl>
42
43 QT_BEGIN_NAMESPACE
44
45 class LayoutWidget : public QFrame
46 {
47     Q_OBJECT
48
49    Q_PROPERTY(bool leftAnchor READ leftAnchor WRITE setLeftAnchor NOTIFY leftAnchorChanged)
50    Q_PROPERTY(bool rightAnchor READ rightAnchor WRITE setRightAnchor NOTIFY rightAnchorChanged)
51    Q_PROPERTY(bool bottomAnchor READ bottomAnchor WRITE setBottomAnchor NOTIFY bottomAnchorChanged)
52    Q_PROPERTY(bool topAnchor READ topAnchor WRITE setTopAnchor NOTIFY topAnchorChanged)
53
54    Q_PROPERTY(QUrl leftButtonIcon READ icon WRITE setLeftButtonIcon)
55    Q_PROPERTY(QUrl rightButtonIcon READ icon WRITE setRightButtonIcon)
56    Q_PROPERTY(QUrl topButtonIcon READ icon WRITE setTopButtonIcon)
57    Q_PROPERTY(QUrl bottomButtonIcon READ icon WRITE setBottomButtonIcon)
58
59 public:
60
61     void setLeftButtonIcon(const QUrl &url)
62     { setIcon(m_leftButton, url); }
63
64     void setRightButtonIcon(const QUrl &url)
65     { setIcon(m_rightButton, url); }
66
67     void setTopButtonIcon(const QUrl &url)
68     { setIcon(m_topButton, url); }
69
70     void setBottomButtonIcon(const QUrl &url)
71     { setIcon(m_bottomButton, url); }
72
73     QUrl icon() const {return QUrl(); }
74
75     LayoutWidget(QWidget *parent = 0);
76     ~LayoutWidget();
77
78     bool leftAnchor() const { return m_leftAnchor; }
79     bool rightAnchor() const { return m_rightAnchor; }
80     bool topAnchor() const { return m_topAnchor; }
81     bool bottomAnchor() const { return m_bottomAnchor; }
82
83 public slots:
84     void setLeftAnchor(bool anchor)
85     {
86         if (anchor == m_leftAnchor)
87             return;
88         m_leftAnchor = anchor;
89         m_leftButton->setChecked(anchor);
90         emit leftAnchorChanged();
91     }
92
93     void setRightAnchor(bool anchor)
94     {
95         if (anchor == m_rightAnchor)
96             return;
97         m_rightAnchor = anchor;
98         m_rightButton->setChecked(anchor);
99         emit rightAnchorChanged();
100     }
101
102     void setTopAnchor(bool anchor)
103     {
104         if (anchor == m_topAnchor)
105             return;
106         m_topAnchor = anchor;
107         m_topButton->setChecked(anchor);
108         emit topAnchorChanged();
109     }
110
111     void setBottomAnchor(bool anchor)
112     {
113         if (anchor == m_bottomAnchor)
114             return;
115         m_bottomAnchor = anchor;
116         m_bottomButton->setChecked(anchor);
117         emit bottomAnchorChanged();
118     }
119
120 signals:
121     //void colorChanged(const QColor &color);
122     void fill();
123     void topAnchorChanged();
124     void bottomAnchorChanged();
125     void leftAnchorChanged();
126     void rightAnchorChanged();
127
128 private:
129     void setIcon(QPushButton *button, QUrl url);
130     bool m_leftAnchor, m_rightAnchor, m_topAnchor, m_bottomAnchor;
131     QPushButton *m_leftButton;
132     QPushButton *m_rightButton;
133     QPushButton *m_topButton;
134     QPushButton *m_bottomButton;
135     QPushButton *m_middleButton;
136 };
137
138 QT_END_NAMESPACE
139
140 #endif
141