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 QDYNAMICTOOLBAR_P_H
5#define QDYNAMICTOOLBAR_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 "qtoolbar.h"
20#include "QtGui/qaction.h"
21#include "private/qwidget_p.h"
22#include <QtCore/qbasictimer.h>
23
24QT_REQUIRE_CONFIG(toolbar);
25
26QT_BEGIN_NAMESPACE
27
28class QToolBarLayout;
29
30class QToolBarPrivate : public QWidgetPrivate
31{
32 Q_DECLARE_PUBLIC(QToolBar)
33
34public:
35 inline QToolBarPrivate()
36 : explicitIconSize(false), explicitToolButtonStyle(false), movable(true), floatable(true),
37 allowedAreas(Qt::AllToolBarAreas), orientation(Qt::Horizontal),
38 toolButtonStyle(Qt::ToolButtonIconOnly),
39 layout(nullptr), state(nullptr)
40#ifdef Q_OS_MACOS
41 , macWindowDragging(false)
42#endif
43 { }
44
45 void init();
46 void actionTriggered();
47 void _q_toggleView(bool b);
48 void _q_updateIconSize(const QSize &sz);
49 void _q_updateToolButtonStyle(Qt::ToolButtonStyle style);
50
51 bool explicitIconSize;
52 bool explicitToolButtonStyle;
53 bool movable;
54 bool floatable;
55 Qt::ToolBarAreas allowedAreas;
56 Qt::Orientation orientation;
57 Qt::ToolButtonStyle toolButtonStyle;
58 QSize iconSize;
59
60 QAction *toggleViewAction;
61
62 QToolBarLayout *layout;
63
64 struct DragState {
65 QPoint pressPos;
66 bool dragging;
67 bool moving;
68 QLayoutItem *widgetItem;
69 };
70 DragState *state;
71
72#ifdef Q_OS_MACOS
73 bool macWindowDragging;
74 QPoint macWindowDragPressPosition;
75#endif
76
77 bool mousePressEvent(QMouseEvent *e);
78 bool mouseReleaseEvent(QMouseEvent *e);
79 bool mouseMoveEvent(QMouseEvent *e);
80
81 void updateWindowFlags(bool floating, bool unplug = false);
82 void setWindowState(bool floating, bool unplug = false, const QRect &rect = QRect());
83 void initDrag(const QPoint &pos);
84 void startDrag(bool moving = false);
85 void endDrag();
86
87 void unplug(const QRect &r);
88 void plug(const QRect &r);
89
90 QBasicTimer waitForPopupTimer;
91};
92
93QT_END_NAMESPACE
94
95#endif // QDYNAMICTOOLBAR_P_H
96

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