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

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