Qt 4.8
Classes | Public Functions | Public Variables | List of all members
QToolBarPrivate Class Reference

#include <qtoolbar_p.h>

Inheritance diagram for QToolBarPrivate:
QWidgetPrivate QObjectPrivate QObjectData

Classes

struct  DragState
 

Public Functions

void _q_toggleView (bool b)
 
void _q_updateIconSize (const QSize &sz)
 
void _q_updateToolButtonStyle (Qt::ToolButtonStyle style)
 
void actionTriggered ()
 
void endDrag ()
 
void init ()
 
void initDrag (const QPoint &pos)
 
bool mouseMoveEvent (QMouseEvent *e)
 
bool mousePressEvent (QMouseEvent *e)
 
bool mouseReleaseEvent (QMouseEvent *e)
 
void plug (const QRect &r)
 
 QToolBarPrivate ()
 
void setWindowState (bool floating, bool unplug=false, const QRect &rect=QRect())
 
void startDrag (bool moving=false)
 
void unplug (const QRect &r)
 
void updateWindowFlags (bool floating, bool unplug=false)
 
- Public Functions inherited from QWidgetPrivate
void _q_showIfNotHidden ()
 
virtual void aboutToDestroy ()
 
void activateChildLayoutsRecursively ()
 
QSize adjustedSize () const
 
void adjustQuitOnCloseAttribute ()
 
QInputContextassignedInputContext () const
 
QPainterbeginSharedPainter ()
 
QWidgetchildAt_helper (const QPoint &, bool) const
 
QWidgetchildAtRecursiveHelper (const QPoint &p, bool, bool includeFrame=false) const
 
QRect clipRect () const
 
QRegion clipRegion () const
 
void clipToEffectiveMask (QRegion &region) const
 
bool close_helper (CloseMode mode)
 
void create_sys (WId window, bool initializeWindow, bool destroyOldWindow)
 
QWindowSurfacecreateDefaultWindowSurface ()
 
QWindowSurfacecreateDefaultWindowSurface_sys ()
 
void createExtra ()
 Creates the widget extra data. More...
 
void createRecursively ()
 
void createSysExtra ()
 
void createTLExtra ()
 
void createTLSysExtra ()
 
void createWinId (WId id=0)
 
void deactivateWidgetCleanup ()
 
void deleteExtra ()
 Deletes the widget extra data. More...
 
void deleteSysExtra ()
 
void deleteTLSysExtra ()
 
void drawWidget (QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter=0, QWidgetBackingStore *backingStore=0)
 
QWidgeteffectiveFocusWidget ()
 
QRect effectiveRectFor (const QRect &rect) const
 
bool endSharedPainter ()
 
void enforceNativeChildren ()
 
QWExtraextraData () const
 
QRect frameStrut () const
 
void getLayoutItemMargins (int *left, int *top, int *right, int *bottom) const
 
const QRegiongetOpaqueChildren () const
 
void handleSoftwareInputPanel (Qt::MouseButton button, bool clickCausedFocus)
 
virtual bool hasHeightForWidth () const
 
void hide_helper ()
 
void hide_sys ()
 Platform-specific part of QWidget::hide(). More...
 
void hideChildren (bool spontaneous)
 
void inheritStyle ()
 
void init (QWidget *desktopWidget, Qt::WindowFlags f)
 
QInputContextinputContext () const
 
void invalidateBuffer (const QRegion &)
 Invalidates the rgn (in widget's coordinates) of the backing store, i.e. More...
 
void invalidateBuffer (const QRect &)
 This function is equivalent to calling invalidateBuffer(QRegion(rect), ...), but is more efficient as it eliminates QRegion operations/allocations and can use the rect more precisely for additional cut-offs. More...
 
void invalidateBuffer_resizeHelper (const QPoint &oldPos, const QSize &oldSize)
 Invalidates the buffer when the widget is resized. More...
 
void invalidateGraphicsEffectsRecursively ()
 
bool isAboutToShow () const
 
bool isBackgroundInherited () const
 
bool isOverlapped (const QRect &) const
 
void lower_sys ()
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QWidgetBackingStoremaybeBackingStore () const
 
QTLWExtramaybeTopData () const
 
void moveRect (const QRect &, int dx, int dy)
 
bool nativeChildrenForced () const
 
QFont naturalWidgetFont (uint inheritedMask) const
 
QPalette naturalWidgetPalette (uint inheritedMask) const
 Returns the palette that the widget w inherits from its ancestors and QApplication::palette. More...
 
void paintBackground (QPainter *, const QRegion &, int flags=DrawAsRoot) const
 
bool paintOnScreen () const
 
void paintSiblingsRecursive (QPaintDevice *pdev, const QObjectList &children, int index, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter, QWidgetBackingStore *backingStore)
 
bool pointInsideRectAndMask (const QPoint &) const
 
QRegion prepareToRender (const QRegion &region, QWidget::RenderFlags renderFlags)
 
void propagatePaletteChange ()
 Propagate this widget's palette to all children, except style sheet widgets, and windows that don't enable window propagation (palettes don't normally propagate to windows). More...
 
 QWidgetPrivate (int version=QObjectPrivateVersion)
 
void raise_sys ()
 
QPaintDeviceredirected (QPoint *offset) const
 
void registerDropSite (bool)
 
void render (QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags, bool readyToRender)
 
void render_helper (QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
 
void repaint_sys (const QRegion &rgn)
 
void reparentFocusWidgets (QWidget *oldtlw)
 
void resolveFont ()
 Determine which font is implicitly imposed on this widget by its ancestors and QApplication::font, resolve this against its own font (attributes from the implicit font are copied over). More...
 
void resolveLayoutDirection ()
 
void resolveLocale ()
 
void resolvePalette ()
 Determine which palette is inherited from this widget's ancestors and QApplication::palette, resolve this against this widget's palette (attributes from the inherited palette are copied over this widget's palette). More...
 
void restoreRedirected ()
 
void scroll_sys (int dx, int dy)
 
void scroll_sys (int dx, int dy, const QRect &r)
 
void scrollChildren (int dx, int dy)
 
void scrollRect (const QRect &, int dx, int dy)
 
void sendPendingMoveAndResizeEvents (bool recursive=false, bool disableUpdates=false)
 
void sendStartupMessage (const char *message) const
 Platform-specific part of QWidget::show(). More...
 
void setConstraints_sys ()
 
void setCursor_sys (const QCursor &cursor)
 
void setDirtyOpaqueRegion ()
 
void setEnabled_helper (bool)
 
void setFocus_sys ()
 
void setFont_helper (const QFont &font)
 
void setGeometry_sys (int, int, int, int, bool)
 
void setLayoutDirection_helper (Qt::LayoutDirection)
 
void setLayoutItemMargins (int left, int top, int right, int bottom)
 
void setLayoutItemMargins (QStyle::SubElement element, const QStyleOption *opt=0)
 
void setLocale_helper (const QLocale &l, bool forceUpdate=false)
 
void setMask_sys (const QRegion &)
 
bool setMaximumSize_helper (int &maxw, int &maxh)
 
bool setMinimumSize_helper (int &minw, int &minh)
 
void setModal_sys ()
 
void setNetWmWindowTypes ()
 
void setOpaque (bool opaque)
 
void setPalette_helper (const QPalette &)
 
void setParent_sys (QWidget *parent, Qt::WindowFlags)
 
void setRedirected (QPaintDevice *replacement, const QPoint &offset)
 
void setSharedPainter (QPainter *painter)
 
void setStyle_helper (QStyle *newStyle, bool propagate, bool metalHack=false)
 
void setUpdatesEnabled_helper (bool)
 
void setWindowFilePath_helper (const QString &filePath)
 
void setWindowIcon_helper ()
 
void setWindowIcon_sys (bool forceReset=false)
 
void setWindowIconText_helper (const QString &cap)
 
void setWindowIconText_sys (const QString &cap)
 
void setWindowOpacity_sys (qreal opacity)
 
void setWindowRole ()
 
void setWindowTitle_helper (const QString &cap)
 
void setWindowTitle_sys (const QString &cap)
 
void setWinId (WId)
 
QPaintersharedPainter () const
 
void show_helper ()
 
void show_recursive ()
 Makes the widget visible in the isVisible() meaning of the word. More...
 
void show_sys ()
 Platform-specific part of QWidget::show(). More...
 
void showChildren (bool spontaneous)
 
void stackUnder_sys (QWidget *)
 
void subtractOpaqueChildren (QRegion &rgn, const QRect &clipRect) const
 
void subtractOpaqueSiblings (QRegion &source, bool *hasDirtySiblingsAbove=0, bool alsoNonOpaque=false) const
 
void syncBackingStore ()
 
void syncBackingStore (const QRegion &region)
 
QTLWExtratopData () const
 
void unsetCursor_sys ()
 
void updateFont (const QFont &)
 Assign font to this widget, and propagate it to all children, except style sheet widgets (handled differently) and windows that don't enable window propagation. More...
 
void updateFrameStrut ()
 Computes the frame rectangle when needed. More...
 
void updateGeometry_helper (bool forceUpdate)
 
void updateIsOpaque ()
 
void updateIsTranslucent ()
 
void updateSystemBackground ()
 
void updateX11AcceptFocus ()
 
void x11UpdateIsOpaque ()
 
 ~QWidgetPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Public Variables

Qt::ToolBarAreas allowedAreas
 
bool explicitIconSize
 
bool explicitToolButtonStyle
 
bool floatable
 
QSize iconSize
 
QToolBarLayoutlayout
 
bool macWindowDragging
 
QPoint macWindowDragPressPosition
 
bool movable
 
Qt::Orientation orientation
 
DragStatestate
 
QActiontoggleViewAction
 
Qt::ToolButtonStyle toolButtonStyle
 
QBasicTimer waitForPopupTimer
 
- Public Variables inherited from QWidgetPrivate
QString accessibleDescription
 
QString accessibleName
 
QList< QAction * > actions
 
QPalette::ColorRole bg_role: 8
 
signed char bottomLayoutItemMargin
 
short bottommargin
 
QWidgetData data
 
QRegion dirty
 
uint dirtyOpaqueChildren: 1
 
QWExtraextra
 
QPaintEngineextraPaintEngine
 
QPalette::ColorRole fg_role: 8
 
QWidgetfocus_child
 
QWidgetfocus_next
 
QWidgetfocus_prev
 
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
 
QGraphicsEffectgraphicsEffect
 
Qt::HANDLE hd
 
uint high_attributes [4]
 
QPointer< QInputContextic
 
Qt::InputMethodHints imHints
 
uint inDirtyList: 1
 
uint inheritedFontResolveMask
 
uint inheritedPaletteResolveMask
 
uint inheritsInputMethodHints: 1
 
uint inSetParent: 1
 
uint isGLWidget: 1
 
uint isMoved: 1
 
uint isOpaque: 1
 
uint isScrolled: 1
 
QLayoutlayout
 
signed char leftLayoutItemMargin
 
short leftmargin
 
QLocale locale
 
QRegionneedsFlush
 
QRegion opaqueChildren
 
Qt::HANDLE picture
 
const QMetaObjectpolished
 
QPaintDeviceredirectDev
 
QPoint redirectOffset
 
signed char rightLayoutItemMargin
 
short rightmargin
 
QSizePolicy size_policy
 
QString statusTip
 
QString toolTip
 
signed char topLayoutItemMargin
 
short topmargin
 
uint usesDoubleBufferedGLContext: 1
 
QString whatsThis
 
QWidgetItemV2widgetItem
 
QX11Info xinfo
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QWidgetPrivate
enum  CloseMode { CloseNoEvent, CloseWithEvent, CloseWithSpontaneousEvent }
 
enum  Direction { DirectionNorth = 0x01, DirectionEast = 0x10, DirectionSouth = 0x02, DirectionWest = 0x20 }
 
enum  DrawWidgetFlags {
  DrawAsRoot = 0x01, DrawPaintOnScreen = 0x02, DrawRecursive = 0x04, DrawInvisible = 0x08,
  DontSubtractOpaqueChildren = 0x10, DontSetCompositionMode = 0x20, DontDrawOpaqueChildren = 0x40, DontDrawNativeChildren = 0x80
}
 
- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Functions inherited from QWidgetPrivate
static void adjustFlags (Qt::WindowFlags &flags, QWidget *w=0)
 
static QGraphicsProxyWidgetnearestGraphicsProxyWidget (const QWidget *origin)
 Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this widget and its ancestors. More...
 
static int pointToRect (const QPoint &p, const QRect &r)
 
static QRect screenGeometry (const QWidget *widget)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 
- Static Public Variables inherited from QWidgetPrivate
static QWidgetSetallWidgets = 0
 
static int instanceCounter = 0
 
static QWidgetkeyboardGrabber = 0
 
static QWidgetMappermapper = 0
 
static int maxInstances = 0
 
static QWidgetmouseGrabber = 0
 

Detailed Description

Definition at line 68 of file qtoolbar_p.h.

Constructors and Destructors

◆ QToolBarPrivate()

QToolBarPrivate::QToolBarPrivate ( )
inline

Definition at line 73 of file qtoolbar_p.h.

74  : explicitIconSize(false), explicitToolButtonStyle(false), movable(true), floatable(true),
77  layout(0), state(0)
78 #ifdef Q_WS_MAC
79  , macWindowDragging(false)
80 #endif
81  { }
bool macWindowDragging
Definition: qtoolbar_p.h:111
bool explicitToolButtonStyle
Definition: qtoolbar_p.h:90
QToolBarLayout * layout
Definition: qtoolbar_p.h:100
Qt::ToolButtonStyle toolButtonStyle
Definition: qtoolbar_p.h:95
Qt::ToolBarAreas allowedAreas
Definition: qtoolbar_p.h:93
Qt::Orientation orientation
Definition: qtoolbar_p.h:94
DragState * state
Definition: qtoolbar_p.h:108
bool explicitIconSize
Definition: qtoolbar_p.h:89

Functions

◆ _q_toggleView()

void QToolBarPrivate::_q_toggleView ( bool  b)

Definition at line 124 of file qtoolbar.cpp.

Referenced by init(), and QToolBarPrivate().

125 {
126  Q_Q(QToolBar);
127  if (b == q->isHidden()) {
128  if (b)
129  q->show();
130  else
131  q->close();
132  }
133 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62

◆ _q_updateIconSize()

void QToolBarPrivate::_q_updateIconSize ( const QSize sz)

Definition at line 135 of file qtoolbar.cpp.

Referenced by QToolBarPrivate().

136 {
137  Q_Q(QToolBar);
138  if (!explicitIconSize) {
139  // iconSize not explicitly set
140  q->setIconSize(sz);
141  explicitIconSize = false;
142  }
143 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
bool explicitIconSize
Definition: qtoolbar_p.h:89

◆ _q_updateToolButtonStyle()

void QToolBarPrivate::_q_updateToolButtonStyle ( Qt::ToolButtonStyle  style)

Definition at line 145 of file qtoolbar.cpp.

Referenced by QToolBarPrivate().

146 {
147  Q_Q(QToolBar);
149  q->setToolButtonStyle(style);
150  explicitToolButtonStyle = false;
151  }
152 }
bool explicitToolButtonStyle
Definition: qtoolbar_p.h:90
#define Q_Q(Class)
Definition: qglobal.h:2483
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62

◆ actionTriggered()

void QToolBarPrivate::actionTriggered ( )

Referenced by QToolBarPrivate().

◆ endDrag()

void QToolBarPrivate::endDrag ( )

Definition at line 245 of file qtoolbar.cpp.

Referenced by mouseReleaseEvent().

246 {
247  Q_Q(QToolBar);
248  Q_ASSERT(state != 0);
249 
250  q->releaseMouse();
251 
252  if (state->dragging) {
253  QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
254  Q_ASSERT(layout != 0);
255 
256  if (!layout->plug(state->widgetItem)) {
257  if (q->isFloatable()) {
258  layout->restore();
259 #if defined(Q_WS_X11) || defined(Q_WS_MAC)
260  setWindowState(true); // gets rid of the X11BypassWindowManager window flag
261  // and activates the resizer
262 #endif
263  q->activateWindow();
264  } else {
265  layout->revert(state->widgetItem);
266  }
267  }
268  }
269 
270  delete state;
271  state = 0;
272 }
QLayoutItem * widgetItem
Definition: qtoolbar_p.h:106
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
void revert(QLayoutItem *widgetItem)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_Q(Class)
Definition: qglobal.h:2483
QToolBarLayout * layout
Definition: qtoolbar_p.h:100
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
void restore(bool keepSavedState=false)
void setWindowState(bool floating, bool unplug=false, const QRect &rect=QRect())
Definition: qtoolbar.cpp:171
DragState * state
Definition: qtoolbar_p.h:108
bool plug(QLayoutItem *widgetItem)

◆ init()

void QToolBarPrivate::init ( )

Definition at line 92 of file qtoolbar.cpp.

Referenced by QToolBarPrivate().

93 {
94  Q_Q(QToolBar);
96  q->setBackgroundRole(QPalette::Button);
97  q->setAttribute(Qt::WA_Hover);
98  q->setAttribute(Qt::WA_X11NetWmWindowTypeToolBar);
99 
100  QStyle *style = q->style();
101  int e = style->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q);
102  iconSize = QSize(e, e);
103 
104  layout = new QToolBarLayout(q);
106 
107 #ifdef Q_WS_MAC
108  if (q->parentWidget() && q->parentWidget()->isWindow()) {
109  // Make sure that the window has the "toolbar" button.
111  qt_mac_updateToolBarButtonHint(parentWidget);
112  reinterpret_cast<QToolBar *>(parentWidget)->d_func()->createWinId(); // Please let me create your winId...
113  extern OSWindowRef qt_mac_window_for(const QWidget *); // qwidget_mac.cpp
114  macWindowToolbarShow(q->parentWidget(), true);
115  }
116 #endif
117 
118  toggleViewAction = new QAction(q);
119  toggleViewAction->setCheckable(true);
120  q->setMovable(q->style()->styleHint(QStyle::SH_ToolBar_Movable, 0, q ));
121  QObject::connect(toggleViewAction, SIGNAL(triggered(bool)), q, SLOT(_q_toggleView(bool)));
122 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
static void qt_mac_updateToolBarButtonHint(QWidget *parentWidget)
Definition: qtoolbar.cpp:78
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
#define SLOT(a)
Definition: qobjectdefs.h:226
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void _q_toggleView(bool b)
Definition: qtoolbar.cpp:124
OSWindowRef qt_mac_window_for(const QWidget *)
Definition: qwidget_mac.mm:484
#define Q_Q(Class)
Definition: qglobal.h:2483
QToolBarLayout * layout
Definition: qtoolbar_p.h:100
#define SIGNAL(a)
Definition: qobjectdefs.h:227
WindowRef OSWindowRef
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...
Definition: qobject.cpp:2580
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
static QWidget * parentWidget(const QWidget *w)
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
void macWindowToolbarShow(const QWidget *widget, bool show)
void createWinId()
Definition: qwidget.cpp:2626
QAction * toggleViewAction
Definition: qtoolbar_p.h:98
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
void updateMarginAndSpacing()

◆ initDrag()

void QToolBarPrivate::initDrag ( const QPoint pos)

Definition at line 194 of file qtoolbar.cpp.

Referenced by mousePressEvent().

195 {
196  Q_Q(QToolBar);
197 
198  if (state != 0)
199  return;
200 
202  Q_ASSERT(win != 0);
204  Q_ASSERT(layout != 0);
205  if (layout->pluggingWidget != 0) // the main window is animating a docking operation
206  return;
207 
208  state = new DragState;
209  state->pressPos = pos;
210  state->dragging = false;
211  state->moving = false;
212  state->widgetItem = 0;
213 
214  if (q->isRightToLeft())
215  state->pressPos = QPoint(q->width() - state->pressPos.x(), state->pressPos.y());
216 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
QLayoutItem * widgetItem
Definition: qtoolbar_p.h:106
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_Q(Class)
Definition: qglobal.h:2483
QToolBarLayout * layout
Definition: qtoolbar_p.h:100
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
DragState * state
Definition: qtoolbar_p.h:108
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QObject * parent
Definition: qobject.h:92
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128

◆ mouseMoveEvent()

bool QToolBarPrivate::mouseMoveEvent ( QMouseEvent e)

Definition at line 325 of file qtoolbar.cpp.

326 {
327  Q_Q(QToolBar);
328 
329  if (!state) {
330 #ifdef Q_WS_MAC
331  if (!macWindowDragging)
332  return false;
333  QWidget *w = q->window();
334  const QPoint delta = event->pos() - macWindowDragPressPosition;
335  w->move(w->pos() + delta);
336  return true;
337 #endif
338  return false;
339  }
340 
342  if (win == 0)
343  return true;
344 
346  Q_ASSERT(layout != 0);
347 
348  if (layout->pluggingWidget == 0
349  && (event->pos() - state->pressPos).manhattanLength() > QApplication::startDragDistance()) {
350  const bool wasDragging = state->dragging;
351  const bool moving = !q->isWindow() && (orientation == Qt::Vertical ?
352  event->x() >= 0 && event->x() < q->width() :
353  event->y() >= 0 && event->y() < q->height());
354 
355  startDrag(moving);
356  if (!moving && !wasDragging) {
357 #ifdef Q_OS_WIN
358  grabMouseWhileInWindow();
359 #else
360  q->grabMouse();
361 #endif
362  }
363  }
364 
365  if (state->dragging) {
366  QPoint pos = event->globalPos();
367  // if we are right-to-left, we move so as to keep the right edge the same distance
368  // from the mouse
369  if (q->isLeftToRight())
370  pos -= state->pressPos;
371  else
372  pos += QPoint(state->pressPos.x() - q->width(), -state->pressPos.y());
373 
374  q->move(pos);
375  layout->hover(state->widgetItem, event->globalPos());
376  } else if (state->moving) {
377 
378  const QPoint rtl(q->width() - state->pressPos.x(), state->pressPos.y()); //for RTL
379  const QPoint globalPressPos = q->mapToGlobal(q->isRightToLeft() ? rtl : state->pressPos);
380  int pos = 0;
381 
382  QPoint delta = event->globalPos() - globalPressPos;
383  if (orientation == Qt::Vertical) {
384  pos = q->y() + delta.y();
385  } else {
386  if (q->isRightToLeft()) {
387  pos = win->width() - q->width() - q->x() - delta.x();
388  } else {
389  pos = q->x() + delta.x();
390  }
391  }
392 
393  layout->moveToolBar(q, pos);
394  }
395  return true;
396 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
bool macWindowDragging
Definition: qtoolbar_p.h:111
QLayoutItem * widgetItem
Definition: qtoolbar_p.h:106
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
EventRef event
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
QList< int > hover(QLayoutItem *widgetItem, const QPoint &mousePos)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_Q(Class)
Definition: qglobal.h:2483
QToolBarLayout * layout
Definition: qtoolbar_p.h:100
QPoint macWindowDragPressPosition
Definition: qtoolbar_p.h:112
int width() const
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
static int startDragDistance()
void moveToolBar(QToolBar *toolbar, int pos)
Qt::Orientation orientation
Definition: qtoolbar_p.h:94
DragState * state
Definition: qtoolbar_p.h:108
QPoint pos
the position of the widget within its parent widget
Definition: qwidget.h:163
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
void startDrag(bool moving=false)
Definition: qtoolbar.cpp:218
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
QObject * parent
Definition: qobject.h:92
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
void move(int x, int y)
This corresponds to move(QPoint(x, y)).
Definition: qwidget.h:1011

◆ mousePressEvent()

bool QToolBarPrivate::mousePressEvent ( QMouseEvent e)

Definition at line 274 of file qtoolbar.cpp.

275 {
276  Q_Q(QToolBar);
278  q->initStyleOption(&opt);
279  if (q->style()->subElementRect(QStyle::SE_ToolBarHandle, &opt, q).contains(event->pos()) == false) {
280 #ifdef Q_WS_MAC
281  // When using the unified toolbar on Mac OS X the user can can click and
282  // drag between toolbar contents to move the window. Make this work by
283  // implementing the standard mouse-dragging code and then call
284  // window->move() in mouseMoveEvent below.
285  if (QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parent)) {
286  if (mainWindow->toolBarArea(q) == Qt::TopToolBarArea
287  && mainWindow->unifiedTitleAndToolBarOnMac()
288  && q->childAt(event->pos()) == 0) {
289  macWindowDragging = true;
290  macWindowDragPressPosition = event->pos();
291  return true;
292  }
293  }
294 #endif
295  return false;
296  }
297 
298  if (event->button() != Qt::LeftButton)
299  return true;
300 
301  if (!layout->movable())
302  return true;
303 
304  initDrag(event->pos());
305  return true;
306 }
bool macWindowDragging
Definition: qtoolbar_p.h:111
EventRef event
bool movable() const
The QStyleOptionToolBar class is used to describe the parameters for drawing a toolbar.
Definition: qstyleoption.h:369
#define Q_Q(Class)
Definition: qglobal.h:2483
QToolBarLayout * layout
Definition: qtoolbar_p.h:100
void initDrag(const QPoint &pos)
Definition: qtoolbar.cpp:194
QPoint macWindowDragPressPosition
Definition: qtoolbar_p.h:112
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
QObject * parent
Definition: qobject.h:92

◆ mouseReleaseEvent()

bool QToolBarPrivate::mouseReleaseEvent ( QMouseEvent e)

Definition at line 308 of file qtoolbar.cpp.

309 {
310  if (state != 0) {
311  endDrag();
312  return true;
313  } else {
314 #ifdef Q_WS_MAC
315  if (!macWindowDragging)
316  return false;
317  macWindowDragging = false;
319  return true;
320 #endif
321  return false;
322  }
323 }
bool macWindowDragging
Definition: qtoolbar_p.h:111
QPoint macWindowDragPressPosition
Definition: qtoolbar_p.h:112
DragState * state
Definition: qtoolbar_p.h:108
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53

◆ plug()

void QToolBarPrivate::plug ( const QRect r)

Definition at line 407 of file qtoolbar.cpp.

408 {
409  setWindowState(false, false, r);
410 }
void setWindowState(bool floating, bool unplug=false, const QRect &rect=QRect())
Definition: qtoolbar.cpp:171

◆ setWindowState()

void QToolBarPrivate::setWindowState ( bool  floating,
bool  unplug = false,
const QRect rect = QRect() 
)

Definition at line 171 of file qtoolbar.cpp.

Referenced by endDrag(), plug(), startDrag(), and unplug().

172 {
173  Q_Q(QToolBar);
174  bool visible = !q->isHidden();
175  bool wasFloating = q->isFloating(); // ...is also currently using popup menus
176 
177  q->hide();
178 
179  updateWindowFlags(floating, unplug);
180 
181  if (floating != wasFloating)
183 
184  if (!rect.isNull())
185  q->setGeometry(rect);
186 
187  if (visible)
188  q->show();
189 
190  if (floating != wasFloating)
191  emit q->topLevelChanged(floating);
192 }
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
void updateWindowFlags(bool floating, bool unplug=false)
Definition: qtoolbar.cpp:154
#define Q_Q(Class)
Definition: qglobal.h:2483
QToolBarLayout * layout
Definition: qtoolbar_p.h:100
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
#define emit
Definition: qobjectdefs.h:76
void unplug(const QRect &r)
Definition: qtoolbar.cpp:398

◆ startDrag()

void QToolBarPrivate::startDrag ( bool  moving = false)

Definition at line 218 of file qtoolbar.cpp.

Referenced by mouseMoveEvent().

219 {
220  Q_Q(QToolBar);
221 
222  Q_ASSERT(state != 0);
223 
224  if ((moving && state->moving) || state->dragging)
225  return;
226 
228  Q_ASSERT(win != 0);
230  Q_ASSERT(layout != 0);
231 
232  if (!moving) {
233  state->widgetItem = layout->unplug(q);
234 #if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
235  if (q->isWindow()) {
236  setWindowState(true, true); //set it to floating
237  }
238 #endif
239  Q_ASSERT(state->widgetItem != 0);
240  }
241  state->dragging = !moving;
242  state->moving = moving;
243 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
QLayoutItem * widgetItem
Definition: qtoolbar_p.h:106
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_Q(Class)
Definition: qglobal.h:2483
QToolBarLayout * layout
Definition: qtoolbar_p.h:100
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
void setWindowState(bool floating, bool unplug=false, const QRect &rect=QRect())
Definition: qtoolbar.cpp:171
DragState * state
Definition: qtoolbar_p.h:108
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
QObject * parent
Definition: qobject.h:92
QLayoutItem * unplug(QWidget *widget)

◆ unplug()

void QToolBarPrivate::unplug ( const QRect r)

Definition at line 398 of file qtoolbar.cpp.

399 {
400  Q_Q(QToolBar);
401  QRect r = _r;
402  r.moveTopLeft(q->mapToGlobal(QPoint(0, 0)));
403  setWindowState(true, true, r);
404  layout->setExpanded(false);
405 }
#define Q_Q(Class)
Definition: qglobal.h:2483
QToolBarLayout * layout
Definition: qtoolbar_p.h:100
void setExpanded(bool b)
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
void moveTopLeft(const QPoint &p)
Moves the rectangle, leaving the top-left corner at the given position.
Definition: qrect.h:368
void setWindowState(bool floating, bool unplug=false, const QRect &rect=QRect())
Definition: qtoolbar.cpp:171
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ updateWindowFlags()

void QToolBarPrivate::updateWindowFlags ( bool  floating,
bool  unplug = false 
)

Definition at line 154 of file qtoolbar.cpp.

Referenced by setWindowState().

155 {
156  Q_Q(QToolBar);
157  Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget;
158 
159  flags |= Qt::FramelessWindowHint;
160 
161  if (unplug) {
163 #ifdef Q_WS_MAC
164  flags |= Qt::WindowStaysOnTopHint;
165 #endif
166  }
167 
168  q->setWindowFlags(flags);
169 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
void unplug(const QRect &r)
Definition: qtoolbar.cpp:398

Properties

◆ allowedAreas

Qt::ToolBarAreas QToolBarPrivate::allowedAreas

Definition at line 93 of file qtoolbar_p.h.

◆ explicitIconSize

bool QToolBarPrivate::explicitIconSize

Definition at line 89 of file qtoolbar_p.h.

Referenced by _q_updateIconSize().

◆ explicitToolButtonStyle

bool QToolBarPrivate::explicitToolButtonStyle

Definition at line 90 of file qtoolbar_p.h.

Referenced by _q_updateToolButtonStyle().

◆ floatable

bool QToolBarPrivate::floatable

Definition at line 92 of file qtoolbar_p.h.

◆ iconSize

QSize QToolBarPrivate::iconSize

Definition at line 96 of file qtoolbar_p.h.

Referenced by init().

◆ layout

QToolBarLayout* QToolBarPrivate::layout

◆ macWindowDragging

bool QToolBarPrivate::macWindowDragging

Definition at line 111 of file qtoolbar_p.h.

Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

◆ macWindowDragPressPosition

QPoint QToolBarPrivate::macWindowDragPressPosition

Definition at line 112 of file qtoolbar_p.h.

Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

◆ movable

bool QToolBarPrivate::movable

Definition at line 91 of file qtoolbar_p.h.

◆ orientation

Qt::Orientation QToolBarPrivate::orientation

Definition at line 94 of file qtoolbar_p.h.

Referenced by mouseMoveEvent().

◆ state

DragState* QToolBarPrivate::state

Definition at line 108 of file qtoolbar_p.h.

Referenced by endDrag(), initDrag(), mouseMoveEvent(), mouseReleaseEvent(), and startDrag().

◆ toggleViewAction

QAction* QToolBarPrivate::toggleViewAction

Definition at line 98 of file qtoolbar_p.h.

Referenced by init().

◆ toolButtonStyle

Qt::ToolButtonStyle QToolBarPrivate::toolButtonStyle

Definition at line 95 of file qtoolbar_p.h.

◆ waitForPopupTimer

QBasicTimer QToolBarPrivate::waitForPopupTimer

Definition at line 128 of file qtoolbar_p.h.


The documentation for this class was generated from the following files: