1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QTOOLBARLAYOUT_P_H
5#define QTOOLBARLAYOUT_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
19#include <QtWidgets/qlayout.h>
20#include <private/qlayoutengine_p.h>
21#include <QList>
22
23QT_REQUIRE_CONFIG(toolbar);
24
25QT_BEGIN_NAMESPACE
26
27class QAction;
28class QToolBarExtension;
29class QMenu;
30
31class QToolBarItem : public QWidgetItem
32{
33public:
34 QToolBarItem(QWidget *widget);
35 bool isEmpty() const override;
36
37 QAction *action;
38 bool customWidget;
39};
40
41class QToolBarLayout : public QLayout
42{
43 Q_OBJECT
44
45public:
46 QToolBarLayout(QWidget *parent = nullptr);
47 ~QToolBarLayout();
48
49 void addItem(QLayoutItem *item) override;
50 QLayoutItem *itemAt(int index) const override;
51 QLayoutItem *takeAt(int index) override;
52 int count() const override;
53
54 bool isEmpty() const override;
55 void invalidate() override;
56 Qt::Orientations expandingDirections() const override;
57
58 void setGeometry(const QRect &r) override;
59 QSize minimumSize() const override;
60 QSize sizeHint() const override;
61
62 void insertAction(int index, QAction *action);
63 int indexOf(const QAction *action) const;
64 using QLayout::indexOf; // bring back the hidden members
65
66 bool layoutActions(const QSize &size);
67 QSize expandedSize(const QSize &size) const;
68 bool expanded, animating;
69
70 void setUsePopupMenu(bool set); // Yeah, there's no getter, but it's internal.
71 void checkUsePopupMenu();
72
73 bool movable() const;
74 void updateMarginAndSpacing();
75 bool hasExpandFlag() const;
76
77 void updateMacBorderMetrics();
78public Q_SLOTS:
79 void setExpanded(bool b);
80
81private:
82 QList<QToolBarItem*> items;
83 QSize hint, minSize;
84 bool dirty, expanding, empty, expandFlag;
85 QList<QLayoutStruct> geomArray;
86 QRect handRect;
87 QToolBarExtension *extension;
88
89 void updateGeomArray() const;
90 QToolBarItem *createItem(QAction *action);
91 QMenu *popupMenu;
92};
93
94QT_END_NAMESPACE
95
96#endif // QTOOLBARLAYOUT_P_H
97

source code of qtbase/src/widgets/widgets/qtoolbarlayout_p.h