[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 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 | **
|
---|
[561] | 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.
|
---|
[2] | 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at qt-info@nokia.com.
|
---|
[2] | 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);
|
---|
[561] | 145 | void topLevelChanged(bool topLevel);
|
---|
[846] | 146 | void visibilityChanged(bool visible);
|
---|
[2] | 147 |
|
---|
| 148 | protected:
|
---|
| 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
|
---|
| 158 | public:
|
---|
| 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 |
|
---|
| 166 | private:
|
---|
| 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 |
|
---|
| 179 | inline QAction *QToolBar::actionAt(int ax, int ay) const
|
---|
| 180 | { return actionAt(QPoint(ax, ay)); }
|
---|
| 181 |
|
---|
| 182 | #endif // QT_NO_TOOLBAR
|
---|
| 183 |
|
---|
| 184 | QT_END_NAMESPACE
|
---|
| 185 |
|
---|
| 186 | QT_END_HEADER
|
---|
| 187 |
|
---|
| 188 | #endif // QDYNAMICTOOLBAR_H
|
---|