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);
114#if QT_CONFIG(draganddrop)
117 if (
unplug && !QMainWindowLayout::needsPlatformDrag())
127 bool visible = !
q->isHidden();
128 bool wasFloating =
q->isFloating();
132 if (floating != wasFloating)
136 q->setGeometry(
rect);
141 if (floating != wasFloating)
142 emit q->topLevelChanged(floating);
149 if (
state !=
nullptr)
156 if (
layout->pluggingWidget !=
nullptr)
165 if (
q->isRightToLeft())
183#if QT_CONFIG(draganddrop)
184 const bool wasFloating =
q->isFloating();
194#if QT_CONFIG(draganddrop)
195 if (QMainWindowLayout::needsPlatformDrag() &&
state->
dragging) {
220 if (
q->isFloatable()) {
238 QStyleOptionToolBar
opt;
239 q->initStyleOption(&
opt);
248 && mainWindow->unifiedTitleAndToolBarOnMac()
250 macWindowDragging =
true;
251 macWindowDragPressPosition =
event->pos();
271#if QT_CONFIG(draganddrop)
274 if (QMainWindowLayout::needsPlatformDrag())
278 if (
state !=
nullptr) {
283 if (!macWindowDragging)
285 macWindowDragging =
false;
286 macWindowDragPressPosition =
QPoint();
299 if (!macWindowDragging)
302 const QPoint delta =
event->pos() - macWindowDragPressPosition;
303 w->move(
w->pos() + delta);
316 if (
layout->pluggingWidget ==
nullptr
320 event->position().toPoint().x() >= 0 &&
event->position().toPoint().x() <
q->width() :
321 event->position().toPoint().y() >= 0 &&
event->position().toPoint().y() <
q->height());
324 if (!moving && !wasDragging)
334 QPoint pos =
event->globalPosition().toPoint();
337 if (
q->isLeftToRight())
350 const QWindow *
handle =
q->window() ?
q->window()->windowHandle() :
nullptr;
354 :
event->globalPosition().toPoint() - globalPressPos;
359 if (
q->isRightToLeft()) {
362 pos =
q->x() + delta.
x();
563 d->layout->invalidate();
620 if (areas ==
d->allowedAreas)
622 d->allowedAreas = areas;
629 return d->allowedAreas;
656 d->layout->invalidate();
657 d->layout->activate();
663{ Q_D(
const QToolBar);
return d->orientation; }
676{ Q_D(
const QToolBar);
return d->iconSize; }
684 if (mw && mw->layout()) {
690 if (
item && (
item->widget() ==
this))
699 if (
d->iconSize != sz) {
706 d->layout->invalidate();
725{ Q_D(
const QToolBar);
return d->toolButtonStyle; }
730 d->explicitToolButtonStyle =
true;
746 for(
int i = 0;
i < actions.size();
i++)
796 action->d_func()->autoCreated =
true;
815 action->d_func()->autoCreated =
true;
830 int index =
d->layout->indexOf(action);
833 return d->layout->itemAt(
index)->widget()->geometry();
864 auto action =
static_cast<QAction *
>(
event->action());
865 QWidgetAction *widgetAction = qobject_cast<QWidgetAction *>(action);
867 switch (
event->type()) {
869 Q_ASSERT_X(widgetAction ==
nullptr ||
d->layout->indexOf(widgetAction) == -1,
870 "QToolBar",
"widgets cannot be inserted multiple times");
877 if (widgetAction !=
nullptr && widgetAction->d_func()->autoCreated)
878 widgetAction->setParent(
this);
880 int index =
d->layout->count();
881 if (
event->before()) {
885 d->layout->insertAction(
index, action);
890 d->layout->invalidate();
894 int index =
d->layout->indexOf(action);
896 delete d->layout->takeAt(
index);
902 Q_ASSERT_X(
false,
"QToolBar::actionEvent",
"internal error");
910 switch (
event->type()) {
915 d->layout->invalidate();
916 if (!
d->explicitIconSize)
918 d->layout->updateMarginAndSpacing();
921 d->layout->invalidate();
936 QStyleOptionToolBar
opt;
939 if (
d->layout->expanded ||
d->layout->animating ||
isWindow()) {
962 if (popup ==
nullptr || popup->
isHidden())
966 while (
w !=
nullptr) {
972 QMenu *
menu = qobject_cast<QMenu*>(popup);
991 if (!nativeInterface)
1009 switch (
event->type()) {
1014 d->waitForPopupTimer.stop();
1016 d->layout->setExpanded(
false);
1032 d->layout->checkUsePopupMenu();
1051 QStyleOptionToolBar
opt;
1065 if (
d->state !=
nullptr &&
d->state->dragging) {
1071 d->mouseMoveEvent(&fake);
1074 if (!
d->layout->expanded)
1083 d->waitForPopupTimer.stop();
1084 d->layout->setExpanded(
false);
1103{ Q_D(
const QToolBar);
return d->toggleViewAction; }
1116 int index =
d->layout->indexOf(action);
1120 return d->layout->itemAt(
index)->widget();
1139 option->features =
d->layout->movable()
1140 ? QStyleOptionToolBar::Movable
1141 : QStyleOptionToolBar::None;
1153 "QMainWindow->layout() != QMainWindowLayout");
1160#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.
QLayout * layout() override
\reimp
const_reference at(qsizetype i) const noexcept
The QMainWindow class provides a main application window.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
The QPaintEvent class contains event parameters for paint events.
The QPainter class performs low-level painting on widgets and other paint devices.
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\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.
QPointF position() const
Returns the position of the point in this event, relative to the widget or item that received the eve...
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)