1/****************************************************************************
2**
3** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Digia. For licensing terms and
14** conditions see http://qt.digia.com/licensing. For further information
15** use the contact form at http://qt.digia.com/contact-us.
16**
17** 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.
24**
25** In addition, as a special exception, Digia gives you certain additional
26** rights. These rights are described in the Digia Qt LGPL Exception
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28**
29** GNU General Public License Usage
30** Alternatively, this file may be used under the terms of the GNU
31** General Public License version 3.0 as published by the Free Software
32** Foundation and appearing in the file LICENSE.GPL included in the
33** packaging of this file. Please review the following information to
34** ensure the GNU General Public License version 3.0 requirements will be
35** met: http://www.gnu.org/copyleft/gpl.html.
36**
37**
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QDYNAMICTOOLBAR_H
43#define QDYNAMICTOOLBAR_H
44
45#include <QtGui/qwidget.h>
46
47QT_BEGIN_HEADER
48
49QT_BEGIN_NAMESPACE
50
51QT_MODULE(Gui)
52
53#ifndef QT_NO_TOOLBAR
54
55class QToolBarPrivate;
56
57class QAction;
58class QIcon;
59class QMainWindow;
60class QStyleOptionToolBar;
61
62class 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
81public:
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
134public Q_SLOTS:
135 void setIconSize(const QSize &iconSize);
136 void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle);
137
138Q_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 void topLevelChanged(bool topLevel);
146 void visibilityChanged(bool visible);
147
148protected:
149 void actionEvent(QActionEvent *event);
150 void changeEvent(QEvent *event);
151 void childEvent(QChildEvent *event);
152 void paintEvent(QPaintEvent *event);
153 void resizeEvent(QResizeEvent *event);
154 bool event(QEvent *event);
155 void initStyleOption(QStyleOptionToolBar *option) const;
156
157#ifdef QT3_SUPPORT
158public:
159 QT3_SUPPORT_CONSTRUCTOR QToolBar(QWidget *parent, const char *name);
160 inline QT3_SUPPORT void setLabel(const QString &label)
161 { setWindowTitle(label); }
162 inline QT3_SUPPORT QString label() const
163 { return windowTitle(); }
164#endif
165
166private:
167 Q_DECLARE_PRIVATE(QToolBar)
168 Q_DISABLE_COPY(QToolBar)
169 Q_PRIVATE_SLOT(d_func(), void _q_toggleView(bool))
170 Q_PRIVATE_SLOT(d_func(), void _q_updateIconSize(const QSize &))
171 Q_PRIVATE_SLOT(d_func(), void _q_updateToolButtonStyle(Qt::ToolButtonStyle))
172
173 friend class QMainWindow;
174 friend class QMainWindowLayout;
175 friend class QToolBarLayout;
176 friend class QToolBarAreaLayout;
177};
178
179inline QAction *QToolBar::actionAt(int ax, int ay) const
180{ return actionAt(QPoint(ax, ay)); }
181
182#endif // QT_NO_TOOLBAR
183
184QT_END_NAMESPACE
185
186QT_END_HEADER
187
188#endif // QDYNAMICTOOLBAR_H
189