0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the QtGui module of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
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 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
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 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
#ifndef QDYNAMICTOOLBAR_H
|
|
43 |
#define QDYNAMICTOOLBAR_H
|
|
44 |
|
|
45 |
#include <QtGui/qwidget.h>
|
|
46 |
|
|
47 |
QT_BEGIN_HEADER
|
|
48 |
|
|
49 |
QT_BEGIN_NAMESPACE
|
|
50 |
|
|
51 |
QT_MODULE(Gui)
|
|
52 |
|
|
53 |
#ifndef QT_NO_TOOLBAR
|
|
54 |
|
|
55 |
class QToolBarPrivate;
|
|
56 |
|
|
57 |
class QAction;
|
|
58 |
class QIcon;
|
|
59 |
class QMainWindow;
|
|
60 |
class QStyleOptionToolBar;
|
|
61 |
|
|
62 |
class Q_GUI_EXPORT QToolBar : public QWidget
|
|
63 |
{
|
|
64 |
Q_OBJECT
|
|
65 |
|
|
66 |
Q_PROPERTY(bool movable READ isMovable WRITE setMovable
|
|
67 |
DESIGNABLE (qobject_cast<QMainWindow *>(parentWidget()) != 0)
|
|
68 |
NOTIFY movableChanged)
|
|
69 |
Q_PROPERTY(Qt::ToolBarAreas allowedAreas READ allowedAreas WRITE setAllowedAreas
|
|
70 |
DESIGNABLE (qobject_cast<QMainWindow *>(parentWidget()) != 0)
|
|
71 |
NOTIFY allowedAreasChanged)
|
|
72 |
Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation
|
|
73 |
DESIGNABLE (qobject_cast<QMainWindow *>(parentWidget()) == 0)
|
|
74 |
NOTIFY orientationChanged)
|
|
75 |
Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged)
|
|
76 |
Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle
|
|
77 |
NOTIFY toolButtonStyleChanged)
|
|
78 |
Q_PROPERTY(bool floating READ isFloating)
|
|
79 |
Q_PROPERTY(bool floatable READ isFloatable WRITE setFloatable)
|
|
80 |
|
|
81 |
public:
|
|
82 |
explicit QToolBar(const QString &title, QWidget *parent = 0);
|
|
83 |
explicit QToolBar(QWidget *parent = 0);
|
|
84 |
~QToolBar();
|
|
85 |
|
|
86 |
void setMovable(bool movable);
|
|
87 |
bool isMovable() const;
|
|
88 |
|
|
89 |
void setAllowedAreas(Qt::ToolBarAreas areas);
|
|
90 |
Qt::ToolBarAreas allowedAreas() const;
|
|
91 |
|
|
92 |
inline bool isAreaAllowed(Qt::ToolBarArea area) const
|
|
93 |
{ return (allowedAreas() & area) == area; }
|
|
94 |
|
|
95 |
void setOrientation(Qt::Orientation orientation);
|
|
96 |
Qt::Orientation orientation() const;
|
|
97 |
|
|
98 |
void clear();
|
|
99 |
|
|
100 |
#ifdef Q_NO_USING_KEYWORD
|
|
101 |
inline void addAction(QAction *action)
|
|
102 |
{ QWidget::addAction(action); }
|
|
103 |
#else
|
|
104 |
using QWidget::addAction;
|
|
105 |
#endif
|
|
106 |
|
|
107 |
QAction *addAction(const QString &text);
|
|
108 |
QAction *addAction(const QIcon &icon, const QString &text);
|
|
109 |
QAction *addAction(const QString &text, const QObject *receiver, const char* member);
|
|
110 |
QAction *addAction(const QIcon &icon, const QString &text,
|
|
111 |
const QObject *receiver, const char* member);
|
|
112 |
|
|
113 |
QAction *addSeparator();
|
|
114 |
QAction *insertSeparator(QAction *before);
|
|
115 |
|
|
116 |
QAction *addWidget(QWidget *widget);
|
|
117 |
QAction *insertWidget(QAction *before, QWidget *widget);
|
|
118 |
|
|
119 |
QRect actionGeometry(QAction *action) const;
|
|
120 |
QAction *actionAt(const QPoint &p) const;
|
|
121 |
inline QAction *actionAt(int x, int y) const;
|
|
122 |
|
|
123 |
QAction *toggleViewAction() const;
|
|
124 |
|
|
125 |
QSize iconSize() const;
|
|
126 |
Qt::ToolButtonStyle toolButtonStyle() const;
|
|
127 |
|
|
128 |
QWidget *widgetForAction(QAction *action) const;
|
|
129 |
|
|
130 |
bool isFloatable() const;
|
|
131 |
void setFloatable(bool floatable);
|
|
132 |
bool isFloating() const;
|
|
133 |
|
|
134 |
public Q_SLOTS:
|
|
135 |
void setIconSize(const QSize &iconSize);
|
|
136 |
void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle);
|
|
137 |
|
|
138 |
Q_SIGNALS:
|
|
139 |
void actionTriggered(QAction *action);
|
|
140 |
void movableChanged(bool movable);
|
|
141 |
void allowedAreasChanged(Qt::ToolBarAreas allowedAreas);
|
|
142 |
void orientationChanged(Qt::Orientation orientation);
|
|
143 |
void iconSizeChanged(const QSize &iconSize);
|
|
144 |
void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle);
|
|
145 |
|
|
146 |
protected:
|
|
147 |
void actionEvent(QActionEvent *event);
|
|
148 |
void changeEvent(QEvent *event);
|
|
149 |
void childEvent(QChildEvent *event);
|
|
150 |
void paintEvent(QPaintEvent *event);
|
|
151 |
void resizeEvent(QResizeEvent *event);
|
|
152 |
bool event(QEvent *event);
|
|
153 |
void initStyleOption(QStyleOptionToolBar *option) const;
|
|
154 |
|
|
155 |
#ifdef QT3_SUPPORT
|
|
156 |
public:
|
|
157 |
QT3_SUPPORT_CONSTRUCTOR QToolBar(QWidget *parent, const char *name);
|
|
158 |
inline QT3_SUPPORT void setLabel(const QString &label)
|
|
159 |
{ setWindowTitle(label); }
|
|
160 |
inline QT3_SUPPORT QString label() const
|
|
161 |
{ return windowTitle(); }
|
|
162 |
#endif
|
|
163 |
|
|
164 |
private:
|
|
165 |
Q_DECLARE_PRIVATE(QToolBar)
|
|
166 |
Q_DISABLE_COPY(QToolBar)
|
|
167 |
Q_PRIVATE_SLOT(d_func(), void _q_toggleView(bool))
|
|
168 |
Q_PRIVATE_SLOT(d_func(), void _q_updateIconSize(const QSize &))
|
|
169 |
Q_PRIVATE_SLOT(d_func(), void _q_updateToolButtonStyle(Qt::ToolButtonStyle))
|
|
170 |
|
|
171 |
friend class QMainWindow;
|
|
172 |
friend class QMainWindowLayout;
|
|
173 |
friend class QToolBarLayout;
|
|
174 |
friend class QToolBarAreaLayout;
|
|
175 |
};
|
|
176 |
|
|
177 |
inline QAction *QToolBar::actionAt(int ax, int ay) const
|
|
178 |
{ return actionAt(QPoint(ax, ay)); }
|
|
179 |
|
|
180 |
#endif // QT_NO_TOOLBAR
|
|
181 |
|
|
182 |
QT_END_NAMESPACE
|
|
183 |
|
|
184 |
QT_END_HEADER
|
|
185 |
|
|
186 |
#endif // QDYNAMICTOOLBAR_H
|