OSDN Git Service

Update license.
[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 (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33
34 #ifndef LAYOUTWIDGET_H
35 #define LAYOUTWIDGET_H
36
37 #include <QtGui/QFrame>
38 #include <QLabel>
39 #include <QPushButton>
40 #include <QUrl>
41
42 QT_BEGIN_NAMESPACE
43
44 class LayoutWidget : public QFrame
45 {
46     Q_OBJECT
47
48    Q_PROPERTY(bool leftAnchor READ leftAnchor WRITE setLeftAnchor NOTIFY leftAnchorChanged)
49    Q_PROPERTY(bool rightAnchor READ rightAnchor WRITE setRightAnchor NOTIFY rightAnchorChanged)
50    Q_PROPERTY(bool bottomAnchor READ bottomAnchor WRITE setBottomAnchor NOTIFY bottomAnchorChanged)
51    Q_PROPERTY(bool topAnchor READ topAnchor WRITE setTopAnchor NOTIFY topAnchorChanged)
52
53    Q_PROPERTY(QUrl leftButtonIcon READ icon WRITE setLeftButtonIcon)
54    Q_PROPERTY(QUrl rightButtonIcon READ icon WRITE setRightButtonIcon)
55    Q_PROPERTY(QUrl topButtonIcon READ icon WRITE setTopButtonIcon)
56    Q_PROPERTY(QUrl bottomButtonIcon READ icon WRITE setBottomButtonIcon)
57
58 public:
59
60     void setLeftButtonIcon(const QUrl &url)
61     { setIcon(m_leftButton, url); }
62
63     void setRightButtonIcon(const QUrl &url)
64     { setIcon(m_rightButton, url); }
65
66     void setTopButtonIcon(const QUrl &url)
67     { setIcon(m_topButton, url); }
68
69     void setBottomButtonIcon(const QUrl &url)
70     { setIcon(m_bottomButton, url); }
71
72     QUrl icon() const {return QUrl(); }
73
74     LayoutWidget(QWidget *parent = 0);
75     ~LayoutWidget();
76
77     bool leftAnchor() const { return m_leftAnchor; }
78     bool rightAnchor() const { return m_rightAnchor; }
79     bool topAnchor() const { return m_topAnchor; }
80     bool bottomAnchor() const { return m_bottomAnchor; }
81
82 public slots:
83     void setLeftAnchor(bool anchor)
84     {
85         if (anchor == m_leftAnchor)
86             return;
87         m_leftAnchor = anchor;
88         m_leftButton->setChecked(anchor);
89         emit leftAnchorChanged();
90     }
91
92     void setRightAnchor(bool anchor)
93     {
94         if (anchor == m_rightAnchor)
95             return;
96         m_rightAnchor = anchor;
97         m_rightButton->setChecked(anchor);
98         emit rightAnchorChanged();
99     }
100
101     void setTopAnchor(bool anchor)
102     {
103         if (anchor == m_topAnchor)
104             return;
105         m_topAnchor = anchor;
106         m_topButton->setChecked(anchor);
107         emit topAnchorChanged();
108     }
109
110     void setBottomAnchor(bool anchor)
111     {
112         if (anchor == m_bottomAnchor)
113             return;
114         m_bottomAnchor = anchor;
115         m_bottomButton->setChecked(anchor);
116         emit bottomAnchorChanged();
117     }
118
119 signals:
120     //void colorChanged(const QColor &color);
121     void fill();
122     void topAnchorChanged();
123     void bottomAnchorChanged();
124     void leftAnchorChanged();
125     void rightAnchorChanged();
126
127 private:
128     void setIcon(QPushButton *button, QUrl url);
129     bool m_leftAnchor, m_rightAnchor, m_topAnchor, m_bottomAnchor;
130     QPushButton *m_leftButton;
131     QPushButton *m_rightButton;
132     QPushButton *m_topButton;
133     QPushButton *m_bottomButton;
134     QPushButton *m_middleButton;
135 };
136
137 QT_END_NAMESPACE
138
139 #endif
140