10#if QT_CONFIG(draganddrop)
21#if QT_CONFIG(rubberband)
29#include <private/qwidgetaction_p.h>
30#include <private/qmainwindowlayout_p.h>
31#include <private/qhighdpiscaling_p.h>
34#include <qpa/qplatformnativeinterface.h>
43#define POPUP_TIMER_INTERVAL 500
80 if (
b ==
q->isHidden()) {
102 q->setToolButtonStyle(style);
116 if (
unplug && !QMainWindowLayout::needsPlatformDrag())
125 bool visible = !
q->isHidden();
126 bool wasFloating =
q->isFloating();
130 if (floating != wasFloating)
134 q->setGeometry(
rect);
139 if (floating != wasFloating)
140 emit q->topLevelChanged(floating);
147 if (
state !=
nullptr)
154 if (
layout->pluggingWidget !=
nullptr)
163 if (
q->isRightToLeft())
181 const bool wasFloating =
q->isFloating();
190#if QT_CONFIG(draganddrop)
191 if (QMainWindowLayout::needsPlatformDrag() &&
state->
dragging) {
216 if (
q->isFloatable()) {
234 QStyleOptionToolBar
opt;
235 q->initStyleOption(&
opt);
244 && mainWindow->unifiedTitleAndToolBarOnMac()
246 macWindowDragging =
true;
247 macWindowDragPressPosition =
event->pos();
269 if (QMainWindowLayout::needsPlatformDrag())
272 if (
state !=
nullptr) {
277 if (!macWindowDragging)
279 macWindowDragging =
false;
280 macWindowDragPressPosition =
QPoint();
293 if (!macWindowDragging)
296 const QPoint delta =
event->pos() - macWindowDragPressPosition;
297 w->move(
w->pos() + delta);
310 if (
layout->pluggingWidget ==
nullptr
314 event->position().toPoint().x() >= 0 &&
event->position().toPoint().x() <
q->width() :
315 event->position().toPoint().y() >= 0 &&
event->position().toPoint().y() <
q->height());
318 if (!moving && !wasDragging)
328 QPoint pos =
event->globalPosition().toPoint();
331 if (
q->isLeftToRight())
344 const QWindow *
handle =
q->window() ?
q->window()->windowHandle() :
nullptr;
348 :
event->globalPosition().toPoint() - globalPressPos;
351 pos =
q->y() + delta.
y();
353 if (
q->isRightToLeft()) {
356 pos =
q->x() + delta.
x();
553 d->layout->invalidate();
610 if (areas ==
d->allowedAreas)
612 d->allowedAreas = areas;
619 return d->allowedAreas;
646 d->layout->invalidate();
647 d->layout->activate();
653{ Q_D(
const QToolBar);
return d->orientation; }
666{ Q_D(
const QToolBar);
return d->iconSize; }
680 if (
item && (
item->widget() ==
this))
689 if (
d->iconSize != sz) {
696 d->layout->invalidate();
715{ Q_D(
const QToolBar);
return d->toolButtonStyle; }
720 d->explicitToolButtonStyle =
true;
736 for(
int i = 0;
i < actions.
size();
i++)
786 action->d_func()->autoCreated =
true;
805 action->d_func()->autoCreated =
true;
820 int index =
d->layout->indexOf(action);
823 return d->layout->itemAt(
index)->widget()->geometry();
854 auto action =
static_cast<QAction *
>(
event->action());
855 QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(action);
857 switch (
event->type()) {
859 Q_ASSERT_X(widgetAction ==
nullptr ||
d->layout->indexOf(widgetAction) == -1,
860 "QToolBar",
"widgets cannot be inserted multiple times");
867 if (widgetAction !=
nullptr && widgetAction->d_func()->autoCreated)
870 int index =
d->layout->count();
871 if (
event->before()) {
875 d->layout->insertAction(
index, action);
880 d->layout->invalidate();
884 int index =
d->layout->indexOf(action);
886 delete d->layout->takeAt(
index);
892 Q_ASSERT_X(
false,
"QToolBar::actionEvent",
"internal error");
900 switch (
event->type()) {
905 d->layout->invalidate();
906 if (!
d->explicitIconSize)
908 d->layout->updateMarginAndSpacing();
911 d->layout->invalidate();
926 QStyleOptionToolBar
opt;
929 if (
d->layout->expanded ||
d->layout->animating ||
isWindow()) {
952 if (popup ==
nullptr || popup->
isHidden())
956 while (
w !=
nullptr) {
962 QMenu *
menu = qobject_cast<QMenu*>(popup);
981 if (!nativeInterface)
999 switch (
event->type()) {
1004 d->waitForPopupTimer.stop();
1006 d->layout->setExpanded(
false);
1022 d->layout->checkUsePopupMenu();
1041 QStyleOptionToolBar
opt;
1055 if (
d->state !=
nullptr &&
d->state->dragging) {
1061 d->mouseMoveEvent(&fake);
1064 if (!
d->layout->expanded)
1073 d->waitForPopupTimer.stop();
1074 d->layout->setExpanded(
false);
1092{ Q_D(
const QToolBar);
return d->toggleViewAction; }
1105 int index =
d->layout->indexOf(action);
1109 return d->layout->itemAt(
index)->widget();
1128 option->features =
d->layout->movable()
1129 ? QStyleOptionToolBar::Movable
1130 : QStyleOptionToolBar::None;
1142 "QMainWindow->layout() != QMainWindowLayout");
1149#include "moc_qtoolbar.cpp"
The QActionEvent class provides an event that is generated when a QAction is added,...
The QAction class provides an abstraction for user commands that can be added to different user inter...
QList< QObject * > associatedObjects() const
void setSeparator(bool b)
If b is true then this action will be considered a separator.
static QWidget * activePopupWidget()
Returns the active popup widget.
int startDragDistance
the minimum distance required for a drag and drop operation to start.
static QPoint pos()
Returns the position of the cursor (hot spot) of the primary screen in global screen coordinates.
Type type() const
Returns the event type.
static QPlatformNativeInterface * platformNativeInterface()
static Qt::KeyboardModifiers keyboardModifiers()
Returns the current state of the modifier keys on the keyboard.
static Qt::MouseButtons mouseButtons()
Returns the current state of the buttons on the mouse.
The QLayoutItem class provides an abstract item that a QLayout manipulates.
The QLayout class is the base class of geometry managers.
virtual QLayoutItem * itemAt(int index) const =0
Must be implemented in subclasses to return the layout item at index.
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
The QMainWindow class provides a main application window.
QSize iconSize
size of toolbar icons in this mainwindow.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void setParent(QObject *parent)
Makes the object a child of parent.
The QPaintEvent class contains event parameters for paint events.
The QPainter class performs low-level painting on widgets and other paint devices.
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
constexpr void moveTopLeft(const QPoint &p) noexcept
Moves the rectangle, leaving the top-left corner at the given position.
constexpr bool isValid() const noexcept
Returns true if the rectangle is valid, otherwise returns false.
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
constexpr bool isValid() const noexcept
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
\macro QT_RESTRICTED_CAST_FROM_ASCII
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
virtual QRect subElementRect(SubElement subElement, const QStyleOption *option, const QWidget *widget=nullptr) const =0
Returns the sub-area for the given element as described in the provided style option.
@ PE_IndicatorToolBarHandle
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
Draws the given element with the provided painter with the style options specified by option.
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
T fromNativePixels(const T &value, const C *context)
Combined button and popup list for selecting options.
@ WA_X11NetWmWindowTypeToolBar
@ X11BypassWindowManagerHint
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLboolean GLboolean GLboolean b
GLuint64 GLenum void * handle
GLfloat GLfloat GLfloat w
[0]
GLdouble GLdouble GLdouble GLdouble q
#define Q_ASSERT_X(cond, x, msg)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent