59 #include <private/qwidgetaction_p.h> 61 #include <private/qt_mac_p.h> 62 #include <private/qt_cocoa_helpers_mac_p.h> 65 #include <private/qmainwindowlayout_p.h> 73 #define POPUP_TIMER_INTERVAL 500 100 QStyle *style = q->style();
108 if (q->parentWidget() && q->parentWidget()->isWindow()) {
119 toggleViewAction->setCheckable(
true);
127 if (b == q->isHidden()) {
149 q->setToolButtonStyle(style);
168 q->setWindowFlags(flags);
174 bool visible = !q->isHidden();
175 bool wasFloating = q->isFloating();
181 if (floating != wasFloating)
185 q->setGeometry(rect);
190 if (floating != wasFloating)
191 emit q->topLevelChanged(floating);
214 if (q->isRightToLeft())
234 #if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) 257 if (q->isFloatable()) {
259 #if defined(Q_WS_X11) || defined(Q_WS_MAC) 278 q->initStyleOption(&opt);
287 && mainWindow->unifiedTitleAndToolBarOnMac()
288 && q->childAt(event->
pos()) == 0) {
352 event->x() >= 0 &&
event->x() < q->width() :
353 event->y() >= 0 &&
event->y() < q->height());
356 if (!moving && !wasDragging) {
358 grabMouseWhileInWindow();
366 QPoint pos =
event->globalPos();
369 if (q->isLeftToRight())
382 QPoint delta =
event->globalPos() - globalPressPos;
384 pos = q->
y() + delta.
y();
386 if (q->isRightToLeft()) {
387 pos = win->
width() - q->width() - q->x() - delta.
x();
389 pos = q->x() + delta.
x();
649 if (!movable == !
d->movable)
652 d->layout->invalidate();
718 if (areas ==
d->allowedAreas)
720 d->allowedAreas = areas;
733 return d->allowedAreas;
753 if (orientation ==
d->orientation)
763 d->layout->invalidate();
764 d->layout->activate();
799 item = layout->
itemAt(i++);
800 if (item && (item->
widget() ==
this))
802 }
while (!sz.
isValid() && item != 0);
807 sz =
QSize(metric, metric);
809 if (
d->iconSize != sz) {
814 d->explicitIconSize = iconSize.
isValid();
816 d->layout->invalidate();
839 d->explicitToolButtonStyle =
true;
840 if (
d->toolButtonStyle == toolButtonStyle)
855 for(
int i = 0; i < actions.
size(); i++)
903 const QObject *receiver,
const char* member)
923 const QObject *receiver,
const char* member)
977 action->d_func()->autoCreated =
true;
996 action->d_func()->autoCreated =
true;
1014 int index =
d->layout->indexOf(action);
1017 return d->layout->itemAt(index)->widget()->geometry();
1030 int index =
d->layout->indexOf(widget);
1048 QAction *action =
event->action();
1051 switch (event->
type()) {
1053 Q_ASSERT_X(widgetAction == 0 ||
d->layout->indexOf(widgetAction) == -1,
1054 "QToolBar",
"widgets cannot be inserted multiple times");
1061 if (widgetAction != 0 && widgetAction->d_func()->autoCreated)
1064 int index =
d->layout->count();
1066 index =
d->layout->indexOf(event->
before());
1067 Q_ASSERT_X(index != -1,
"QToolBar::insertAction",
"internal error");
1069 d->layout->insertAction(index, action);
1074 d->layout->invalidate();
1078 int index =
d->layout->indexOf(action);
1080 delete d->layout->takeAt(index);
1086 Q_ASSERT_X(
false,
"QToolBar::actionEvent",
"internal error");
1094 switch (event->
type()) {
1099 d->layout->invalidate();
1100 if (!
d->explicitIconSize)
1102 d->layout->updateMarginAndSpacing();
1105 d->layout->invalidate();
1123 if (
d->layout->expanded ||
d->layout->animating ||
isWindow()) {
1146 if (popup == 0 || popup->
isHidden())
1162 for (
int i = 0; i < widgets.
count(); ++i) {
1170 #if defined(Q_WS_MAC) 1184 switch (event->
type()) {
1186 if (
d->waitForPopupTimer.timerId() ==
static_cast<QTimerEvent*
>(
event)->timerId()) {
1189 d->waitForPopupTimer.stop();
1191 d->layout->setExpanded(
false);
1202 #if defined(Q_WS_MAC) 1210 # if !defined(QT_MAC_USE_COCOA) 1215 int earlyResult = -1;
1217 bool needUpdate =
true;
1221 needUpdate = oldSizeHint !=
sizeHint();
1228 DisableScreenUpdates();
1231 EnableScreenUpdates();
1235 if (earlyResult != -1)
1239 # endif // !QT_MAC_USE_COCOA 1243 d->layout->checkUsePopupMenu();
1244 #if defined(Q_WS_MAC) 1251 if (
d->mousePressEvent(static_cast<QMouseEvent*>(event)))
1256 if (
d->mouseReleaseEvent(static_cast<QMouseEvent*>(event)))
1264 #ifndef QT_NO_CURSOR 1276 if (
d->mouseMoveEvent(static_cast<QMouseEvent*>(event)))
1291 if (
d->state != 0 &&
d->state->dragging) {
1297 d->mouseMoveEvent(&fake);
1300 if (!
d->layout->expanded)
1309 d->waitForPopupTimer.stop();
1310 d->layout->setExpanded(
false);
1362 int index =
d->layout->indexOf(action);
1366 return d->layout->itemAt(index)->widget();
1398 Q_ASSERT_X(layout != 0,
"QToolBar::initStyleOption()",
1399 "QMainWindow->layout() != QMainWindowLayout");
1422 #include "moc_qtoolbar.cpp" 1424 #endif // QT_NO_TOOLBAR
T qobject_cast(QObject *object)
The QPainter class performs low-level painting on widgets and other paint devices.
QAction * before() const
If type() is ActionAdded , returns the action that should appear before action(). ...
virtual QLayoutItem * itemAt(int index) const =0
Must be implemented in subclasses to return the layout item at index.
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
void revert(QLayoutItem *widgetItem)
void setSeparator(bool b)
If b is true then this action will be considered a separator.
QStyle::State state
the style flags that are used when drawing the control
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
The QHoverEvent class contains parameters that describe a mouse event.
void syncUnifiedToolbarVisibility()
QMainWindowLayoutState layoutState
int count(const T &t) const
Returns the number of occurrences of value in the list.
The QActionEvent class provides an event that is generated when a QAction is added, removed, or changed.
QList< int > hover(QLayoutItem *widgetItem, const QPoint &mousePos)
The QString class provides a Unicode character string.
T * qobject_cast(QObject *object)
The QObject class is the base class of all Qt objects.
bool macWindowToolbarIsVisible(void *window)
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
void setParent(QObject *)
Makes the object a child of parent.
OSWindowRef qt_mac_window_for(const QWidget *)
void setObjectName(const QString &name)
void getStyleOptionInfo(QStyleOptionToolBar *option, QToolBar *toolBar) const
QList< QWidget * > associatedWidgets() const
Returns a list of widgets this action has been added to.
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QLayoutItem class provides an abstract item that a QLayout manipulates.
QSize iconSize
size of toolbar icons in this mainwindow.
Qt::ToolBarArea toolBarArea(QToolBar *toolbar) const
Returns the Qt::ToolBarArea for toolbar.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
virtual void childEvent(QChildEvent *)
This event handler can be reimplemented in a subclass to receive child events.
void initFrom(const QWidget *w)
The QLayout class is the base class of geometry managers.
const T & at(int i) const
Returns the item at index position i in the list.
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
The QResizeEvent class contains event parameters for resize events.
void restore(bool keepSavedState=false)
static int startDragDistance()
Qt::MouseButton button() const
Returns the button that caused the event.
void moveTopLeft(const QPoint &p)
Moves the rectangle, leaving the top-left corner at the given position.
static QWidget * parentWidget(const QWidget *w)
The QMouseEvent class contains parameters that describe a mouse event.
void moveToolBar(QToolBar *toolbar, int pos)
The QChildEvent class contains event parameters for child object events.
bool unifiedTitleAndToolBarOnMac
whether the window uses the unified title and toolbar look on Mac OS X
#define Q_ASSERT_X(cond, where, what)
virtual QRect subElementRect(SubElement subElement, const QStyleOption *option, const QWidget *widget=0) const =0
Returns the sub-area for the given element as described in the provided style option.
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
static Qt::KeyboardModifiers keyboardModifiers()
Returns the current state of the modifier keys on the keyboard.
static QWidget * activePopupWidget()
Returns the active popup widget.
The QTimerEvent class contains parameters that describe a timer event.
bool plug(QLayoutItem *widgetItem)
QObject * parent() const
Returns a pointer to the parent object.
The QPoint class defines a point in the plane using integer precision.
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given element with the provided painter with the style options specified by option...
The QMainWindow class provides a main application window.
int size() const
Returns the number of items in the list.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
void macWindowToolbarShow(const QWidget *widget, bool show)
The QRect class defines a rectangle in the plane using integer precision.
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
int y() const
Returns the y coordinate of this point.
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
The QSize class defines the size of a two-dimensional object using integer point precision.
static Qt::MouseButtons mouseButtons()
Returns the current state of the buttons on the mouse.
int x() const
Returns the x coordinate of this point.
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
The QPaintEvent class contains event parameters for paint events.
void fixSizeInUnifiedToolbar(QToolBar *tb) const
QToolBarAreaLayout toolBarAreaLayout
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
const QPoint & globalPos() const
Returns the global position of the mouse cursor at the time of the event.
QRect rect
the area that should be used for various calculations and painting
The QAction class provides an abstract user interface action that can be inserted into widgets...
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
The QList class is a template class that provides lists.
QLayoutItem * unplug(QWidget *widget)
The QIcon class provides scalable icons in different modes and states.