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

#include <qdockwidget_p.h>

Inheritance diagram for QDockWidgetPrivate:
QWidgetPrivate QObjectPrivate QObjectData

Classes

struct  DragState
 

Public Functions

void _q_toggleTopLevel ()
 
void _q_toggleView (bool)
 
void endDrag (bool abort=false)
 
void init ()
 
void initDrag (const QPoint &pos, bool nca)
 
bool isAnimating () const
 
bool mouseDoubleClickEvent (QMouseEvent *event)
 
bool mouseMoveEvent (QMouseEvent *event)
 
bool mousePressEvent (QMouseEvent *event)
 
bool mouseReleaseEvent (QMouseEvent *event)
 
void moveEvent (QMoveEvent *event)
 
void nonClientAreaMouseEvent (QMouseEvent *event)
 
void plug (const QRect &rect)
 
 QDockWidgetPrivate ()
 
void setWindowState (bool floating, bool unplug=false, const QRect &rect=QRect())
 
void startDrag ()
 
void unplug (const QRect &rect)
 
void updateButtons ()
 
- 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::DockWidgetAreas allowedAreas
 
QDockWidget::DockWidgetFeatures features
 
QString fixedWindowTitle
 
QWidgetResizeHandlerresizer
 
DragStatestate
 
QActiontoggleViewAction
 
QRect undockedGeometry
 
- 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 72 of file qdockwidget_p.h.

Constructors and Destructors

◆ QDockWidgetPrivate()

QDockWidgetPrivate::QDockWidgetPrivate ( )
inline

Functions

◆ _q_toggleTopLevel()

void QDockWidgetPrivate::_q_toggleTopLevel ( )

Definition at line 682 of file qdockwidget.cpp.

Referenced by QDockWidgetPrivate().

683 {
684  Q_Q(QDockWidget);
685  q->setFloating(!q->isFloating());
686 }
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
#define Q_Q(Class)
Definition: qglobal.h:2483

◆ _q_toggleView()

void QDockWidgetPrivate::_q_toggleView ( bool  b)

Definition at line 640 of file qdockwidget.cpp.

Referenced by QDockWidgetPrivate().

641 {
642  Q_Q(QDockWidget);
643  if (b == q->isHidden()) {
644  if (b)
645  q->show();
646  else
647  q->close();
648  }
649 }
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
#define Q_Q(Class)
Definition: qglobal.h:2483

◆ endDrag()

void QDockWidgetPrivate::endDrag ( bool  abort = false)

Definition at line 747 of file qdockwidget.cpp.

748 {
749  Q_Q(QDockWidget);
750  Q_ASSERT(state != 0);
751 
752  q->releaseMouse();
753 
754  if (state->dragging) {
755  QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
756  Q_ASSERT(mwLayout != 0);
757 
758  if (abort || !mwLayout->plug(state->widgetItem)) {
760  if (state->ownWidgetItem)
761  delete state->widgetItem;
762  mwLayout->restore();
763 #ifdef Q_WS_X11
764  // get rid of the X11BypassWindowManager window flag and activate the resizer
765  Qt::WindowFlags flags = q->windowFlags();
767  q->setWindowFlags(flags);
769  q->show();
770 #else
771  QDockWidgetLayout *myLayout
775 #endif
776  undockedGeometry = q->geometry();
777  q->activateWindow();
778  } else {
779  mwLayout->revert(state->widgetItem);
780  }
781  }
782  }
783  delete state;
784  state = 0;
785 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
void revert(QLayoutItem *widgetItem)
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
QLayout * layout
Definition: qwidget_p.h:704
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_Q(Class)
Definition: qglobal.h:2483
void restore(bool keepSavedState=false)
static bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature)
Definition: qdockwidget.cpp:74
bool plug(QLayoutItem *widgetItem)
Definition: qnamespace.h:54
QWidget * widgetForRole(Role r) const
QWidgetResizeHandler * resizer
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
DragState * state
Definition: qdockwidget_p.h:99

◆ init()

void QDockWidgetPrivate::init ( )

Definition at line 578 of file qdockwidget.cpp.

Referenced by QDockWidgetPrivate().

579 {
580  Q_Q(QDockWidget);
581 
584 
585  QAbstractButton *button = new QDockWidgetTitleButton(q);
586  button->setObjectName(QLatin1String("qt_dockwidget_floatbutton"));
587  QObject::connect(button, SIGNAL(clicked()), q, SLOT(_q_toggleTopLevel()));
589 
590  button = new QDockWidgetTitleButton(q);
591  button->setObjectName(QLatin1String("qt_dockwidget_closebutton"));
592  QObject::connect(button, SIGNAL(clicked()), q, SLOT(close()));
594 
595  resizer = new QWidgetResizeHandler(q);
596  resizer->setMovingEnabled(false);
597  resizer->setActive(false);
598 
599 #ifndef QT_NO_ACTION
600  toggleViewAction = new QAction(q);
602  fixedWindowTitle = qt_setWindowTitle_helperHelper(q->windowTitle(), q);
604  QObject::connect(toggleViewAction, SIGNAL(triggered(bool)),
605  q, SLOT(_q_toggleView(bool)));
606 #endif
607 
608  updateButtons();
609 }
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
QLayout * layout
Definition: qwidget_p.h:704
void setCheckable(bool)
Definition: qaction.cpp:1094
#define SLOT(a)
Definition: qobjectdefs.h:226
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void setWidgetForRole(Role r, QWidget *w)
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
#define Q_Q(Class)
Definition: qglobal.h:2483
#define SIGNAL(a)
Definition: qobjectdefs.h:227
QAction * toggleViewAction
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
QString qt_setWindowTitle_helperHelper(const QString &, const QWidget *)
Returns a modified window title with the [*] place holder replaced according to the rules described i...
Definition: qwidget.cpp:6240
void setText(const QString &text)
Definition: qaction.cpp:860
void _q_toggleView(bool)
void setSizeConstraint(SizeConstraint)
Definition: qlayout.cpp:1435
QWidgetResizeHandler * resizer
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64

◆ initDrag()

void QDockWidgetPrivate::initDrag ( const QPoint pos,
bool  nca 
)

Definition at line 688 of file qdockwidget.cpp.

689 {
690  if (state != 0)
691  return;
692 
693  Q_Q(QDockWidget);
695  Q_ASSERT(win != 0);
697  Q_ASSERT(layout != 0);
698  if (layout->pluggingWidget != 0) // the main window is animating a docking operation
699  return;
700 
702  state->dragging = false;
703  state->widgetItem = 0;
704  state->ownWidgetItem = false;
705  state->nca = nca;
706  state->ctrlDrag = false;
707 
708  if (!q->isFloating()) {
709  // When dragging the widget out of the docking area,
710  // use the middle of title area as pressPos
711  QDockWidgetLayout *dwlayout = qobject_cast<QDockWidgetLayout*>(q->layout());
712  Q_ASSERT(dwlayout != 0);
713  int width = undockedGeometry.isNull() ? q->width() : undockedGeometry.width();
714  state->pressPos.setY(dwlayout->titleArea().height() / 2);
715  state->pressPos.setX(width / 2);
716  } else {
717  state->pressPos = pos;
718  }
719 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
QLayout * layout
Definition: qwidget_p.h:704
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_Q(Class)
Definition: qglobal.h:2483
void setY(int y)
Sets the y coordinate of this point to the given y coordinate.
Definition: qpoint.h:137
QRect titleArea() const
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
QObject * parent
Definition: qobject.h:92
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
DragState * state
Definition: qdockwidget_p.h:99
void setX(int x)
Sets the x coordinate of this point to the given x coordinate.
Definition: qpoint.h:134

◆ isAnimating()

bool QDockWidgetPrivate::isAnimating ( ) const

Definition at line 787 of file qdockwidget.cpp.

788 {
789  Q_Q(const QDockWidget);
790 
792  if (mainWin == 0)
793  return false;
794 
795  QMainWindowLayout *mainWinLayout = qt_mainwindow_layout(mainWin);
796  if (mainWinLayout == 0)
797  return false;
798 
799  return (void*)mainWinLayout->pluggingWidget == (void*)q;
800 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
#define Q_Q(Class)
Definition: qglobal.h:2483
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
QObject * parent
Definition: qobject.h:92
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)

◆ mouseDoubleClickEvent()

bool QDockWidgetPrivate::mouseDoubleClickEvent ( QMouseEvent event)

Definition at line 835 of file qdockwidget.cpp.

836 {
838 
839  if (!dwLayout->nativeWindowDeco()) {
840  QRect titleArea = dwLayout->titleArea();
841 
842  if (event->button() == Qt::LeftButton && titleArea.contains(event->pos()) &&
845  return true;
846  }
847  }
848  return false;
849 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
QLayout * layout
Definition: qwidget_p.h:704
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
static bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature)
Definition: qdockwidget.cpp:74
QRect titleArea() const
bool nativeWindowDeco() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ mouseMoveEvent()

bool QDockWidgetPrivate::mouseMoveEvent ( QMouseEvent event)

Definition at line 851 of file qdockwidget.cpp.

852 {
853  bool ret = false;
854 #if !defined(QT_NO_MAINWINDOW)
855  Q_Q(QDockWidget);
856 
857  if (!state)
858  return ret;
859 
860  QDockWidgetLayout *dwlayout
862  QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
863  if (!dwlayout->nativeWindowDeco()) {
864  if (!state->dragging
865  && mwlayout->pluggingWidget == 0
866  && (event->pos() - state->pressPos).manhattanLength()
868  startDrag();
869 #ifdef Q_OS_WIN
870  grabMouseWhileInWindow();
871 #else
872  q->grabMouse();
873 #endif
874  ret = true;
875  }
876  }
877 
878  if (state->dragging && !state->nca) {
879  QPoint pos = event->globalPos() - state->pressPos;
880  q->move(pos);
881 
882  if (!state->ctrlDrag)
883  mwlayout->hover(state->widgetItem, event->globalPos());
884 
885  ret = true;
886  }
887 
888 #endif // !defined(QT_NO_MAINWINDOW)
889  return ret;
890 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
QLayout * layout
Definition: qwidget_p.h:704
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
#define Q_Q(Class)
Definition: qglobal.h:2483
static int startDragDistance()
bool nativeWindowDeco() const
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
DragState * state
Definition: qdockwidget_p.h:99
const QPoint & globalPos() const
Returns the global position of the mouse cursor at the time of the event.
Definition: qevent.h:96

◆ mousePressEvent()

bool QDockWidgetPrivate::mousePressEvent ( QMouseEvent event)

Definition at line 802 of file qdockwidget.cpp.

803 {
804 #if !defined(QT_NO_MAINWINDOW)
805  Q_Q(QDockWidget);
806 
807  QDockWidgetLayout *dwLayout
809 
810  if (!dwLayout->nativeWindowDeco()) {
811  QRect titleArea = dwLayout->titleArea();
812 
813  if (event->button() != Qt::LeftButton ||
814  !titleArea.contains(event->pos()) ||
815  // check if the tool window is movable... do nothing if it
816  // is not (but allow moving if the window is floating)
817  (!hasFeature(this, QDockWidget::DockWidgetMovable) && !q->isFloating()) ||
818  qobject_cast<QMainWindow*>(parent) == 0 ||
819  isAnimating() || state != 0) {
820  return false;
821  }
822 
823  initDrag(event->pos(), false);
824 
825  if (state)
827 
828  return true;
829  }
830 
831 #endif // !defined(QT_NO_MAINWINDOW)
832  return false;
833 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
void initDrag(const QPoint &pos, bool nca)
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
QLayout * layout
Definition: qwidget_p.h:704
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
#define Q_Q(Class)
Definition: qglobal.h:2483
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
static bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature)
Definition: qdockwidget.cpp:74
bool isAnimating() const
QRect titleArea() const
bool nativeWindowDeco() const
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QObject * parent
Definition: qobject.h:92
DragState * state
Definition: qdockwidget_p.h:99

◆ mouseReleaseEvent()

bool QDockWidgetPrivate::mouseReleaseEvent ( QMouseEvent event)

Definition at line 892 of file qdockwidget.cpp.

893 {
894 #if !defined(QT_NO_MAINWINDOW)
895 
896  if (event->button() == Qt::LeftButton && state && !state->nca) {
897  endDrag();
898  return true; //filter out the event
899  }
900 
901 #endif // !defined(QT_NO_MAINWINDOW)
902  return false;
903 }
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
void endDrag(bool abort=false)
DragState * state
Definition: qdockwidget_p.h:99

◆ moveEvent()

void QDockWidgetPrivate::moveEvent ( QMoveEvent event)

Definition at line 979 of file qdockwidget.cpp.

980 {
981  Q_Q(QDockWidget);
982 
983  if (state == 0 || !state->dragging || !state->nca || !q->isWindow())
984  return;
985 
986  // When the native window frame is being dragged, all we get is these mouse
987  // move events.
988 
989  if (state->ctrlDrag)
990  return;
991 
992  QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
993  Q_ASSERT(layout != 0);
994 
995  QPoint globalMousePos = event->pos() + state->pressPos;
996  layout->hover(state->widgetItem, globalMousePos);
997 }
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
QLayout * layout
Definition: qwidget_p.h:704
QList< int > hover(QLayoutItem *widgetItem, const QPoint &mousePos)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_Q(Class)
Definition: qglobal.h:2483
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
DragState * state
Definition: qdockwidget_p.h:99

◆ nonClientAreaMouseEvent()

void QDockWidgetPrivate::nonClientAreaMouseEvent ( QMouseEvent event)

Definition at line 905 of file qdockwidget.cpp.

906 {
907  Q_Q(QDockWidget);
908 
909  int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q);
910 
911  QRect geo = q->geometry();
912  QRect titleRect = q->frameGeometry();
913 #ifdef Q_WS_MAC
915  titleRect.setTop(geo.top());
916  titleRect.setBottom(geo.bottom());
917  titleRect.setRight(geo.left() - 1);
918  } else
919 #endif
920  {
921  titleRect.setLeft(geo.left());
922  titleRect.setRight(geo.right());
923  titleRect.setBottom(geo.top() - 1);
924  titleRect.adjust(0, fw, 0, 0);
925  }
926 
927  switch (event->type()) {
929  if (!titleRect.contains(event->globalPos()))
930  break;
931  if (state != 0)
932  break;
933  if (qobject_cast<QMainWindow*>(parent) == 0)
934  break;
935  if (isAnimating())
936  break;
937  initDrag(event->pos(), true);
938  if (state == 0)
939  break;
940 #ifdef Q_OS_WIN
941  // On Windows, NCA mouse events don't contain modifier info
942  state->ctrlDrag = GetKeyState(VK_CONTROL) & 0x8000;
943 #else
944  state->ctrlDrag = event->modifiers() & Qt::ControlModifier;
945 #endif
946  startDrag();
947  break;
949  if (state == 0 || !state->dragging)
950  break;
951  if (state->nca) {
952  endDrag();
953  }
954 #ifdef Q_OS_MAC
955  else { // workaround for lack of mouse-grab on Mac
956  QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
957  Q_ASSERT(layout != 0);
958 
959  q->move(event->globalPos() - state->pressPos);
960  if (!state->ctrlDrag)
961  layout->hover(state->widgetItem, event->globalPos());
962  }
963 #endif
964  break;
966 #ifdef Q_OS_MAC
967  if (state)
968  endDrag();
969 #endif
970  break;
973  break;
974  default:
975  break;
976  }
977 }
void initDrag(const QPoint &pos, bool nca)
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:267
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
QLayout * layout
Definition: qwidget_p.h:704
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
QList< int > hover(QLayoutItem *widgetItem, const QPoint &mousePos)
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
#define Q_Q(Class)
Definition: qglobal.h:2483
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:264
QDockWidget::DockWidgetFeatures features
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
bool isAnimating() const
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
void endDrag(bool abort=false)
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QObject * parent
Definition: qobject.h:92
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
DragState * state
Definition: qdockwidget_p.h:99
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
const QPoint & globalPos() const
Returns the global position of the mouse cursor at the time of the event.
Definition: qevent.h:96

◆ plug()

void QDockWidgetPrivate::plug ( const QRect rect)

Definition at line 1016 of file qdockwidget.cpp.

1017 {
1018  setWindowState(false, false, rect);
1019 }
void setWindowState(bool floating, bool unplug=false, const QRect &rect=QRect())

◆ setWindowState()

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

Definition at line 1021 of file qdockwidget.cpp.

1022 {
1023  Q_Q(QDockWidget);
1024 
1025  if (!floating && parent) {
1026  QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
1027  if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea)
1028  return; // this dockwidget can't be redocked
1029  }
1030 
1031  bool wasFloating = q->isFloating();
1032  bool hidden = q->isHidden();
1033 
1034  if (q->isVisible())
1035  q->hide();
1036 
1037  Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget;
1038 
1040  const bool nativeDeco = dwLayout->nativeWindowDeco(floating);
1041 
1042  if (nativeDeco) {
1045  flags |= Qt::WindowCloseButtonHint;
1046  } else {
1047  flags |= Qt::FramelessWindowHint;
1048  }
1049 
1050  if (unplug)
1052 
1053  q->setWindowFlags(flags);
1054 
1055 #if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
1056  if (floating && nativeDeco && (q->features() & QDockWidget::DockWidgetVerticalTitleBar)) {
1057  ChangeWindowAttributes(HIViewGetWindow(HIViewRef(q->winId())), kWindowSideTitlebarAttribute, 0);
1058  }
1059 #endif
1060 
1061  if (!rect.isNull())
1062  q->setGeometry(rect);
1063 
1064  updateButtons();
1065 
1066  if (!hidden)
1067  q->show();
1068 
1069  if (floating != wasFloating) {
1070  emit q->topLevelChanged(floating);
1071  if (!floating && parent) {
1072  QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
1073  if (mwlayout)
1074  emit q->dockLocationChanged(mwlayout->dockWidgetArea(q));
1075  }
1076  }
1077 
1078  resizer->setActive(QWidgetResizeHandler::Resize, !unplug && floating && !nativeDeco);
1079 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
void unplug(const QRect &rect)
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
QLayout * layout
Definition: qwidget_p.h:704
#define Q_Q(Class)
Definition: qglobal.h:2483
struct OpaqueControlRef * HIViewRef
#define emit
Definition: qobjectdefs.h:76
static bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature)
Definition: qdockwidget.cpp:74
bool nativeWindowDeco() const
Qt::DockWidgetArea dockWidgetArea(QDockWidget *dockwidget) const
QObject * parent
Definition: qobject.h:92
QWidgetResizeHandler * resizer
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)

◆ startDrag()

void QDockWidgetPrivate::startDrag ( )

Definition at line 721 of file qdockwidget.cpp.

722 {
723  Q_Q(QDockWidget);
724 
725  if (state == 0 || state->dragging)
726  return;
727 
728  QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
729  Q_ASSERT(layout != 0);
730 
731  state->widgetItem = layout->unplug(q);
732  if (state->widgetItem == 0) {
733  /* I have a QMainWindow parent, but I was never inserted with
734  QMainWindow::addDockWidget, so the QMainWindowLayout has no
735  widget item for me. :( I have to create it myself, and then
736  delete it if I don't get dropped into a dock area. */
737  state->widgetItem = new QDockWidgetItem(q);
738  state->ownWidgetItem = true;
739  }
740 
741  if (state->ctrlDrag)
742  layout->restore();
743 
744  state->dragging = true;
745 }
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
QLayout * layout
Definition: qwidget_p.h:704
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_Q(Class)
Definition: qglobal.h:2483
void restore(bool keepSavedState=false)
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
DragState * state
Definition: qdockwidget_p.h:99
QLayoutItem * unplug(QWidget *widget)

◆ unplug()

void QDockWidgetPrivate::unplug ( const QRect rect)

Definition at line 999 of file qdockwidget.cpp.

1000 {
1001  Q_Q(QDockWidget);
1002  QRect r;
1003  if (!undockedGeometry.isNull()) {
1004  r = undockedGeometry;
1005  } else {
1006  r = rect;
1007  r.moveTopLeft(q->mapToGlobal(QPoint(0, 0)));
1009  if (dwLayout->nativeWindowDeco(true))
1010  r.adjust(0, dwLayout->titleHeight(), 0, 0);
1011  }
1012 
1013  setWindowState(true, true, r);
1014 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
QLayout * layout
Definition: qwidget_p.h:704
#define Q_Q(Class)
Definition: qglobal.h:2483
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
int titleHeight() const
void moveTopLeft(const QPoint &p)
Moves the rectangle, leaving the top-left corner at the given position.
Definition: qrect.h:368
bool nativeWindowDeco() const
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
void setWindowState(bool floating, bool unplug=false, const QRect &rect=QRect())

◆ updateButtons()

void QDockWidgetPrivate::updateButtons ( )

Definition at line 651 of file qdockwidget.cpp.

Referenced by QDockWidgetPrivate().

652 {
653  Q_Q(QDockWidget);
655 
657  q->initStyleOption(&opt);
658 
659  bool customTitleBar = dwLayout->widgetForRole(QDockWidgetLayout::TitleBar) != 0;
660  bool nativeDeco = dwLayout->nativeWindowDeco();
661  bool hideButtons = nativeDeco || customTitleBar;
662 
663  bool canClose = hasFeature(this, QDockWidget::DockWidgetClosable);
664  bool canFloat = hasFeature(this, QDockWidget::DockWidgetFloatable);
665 
666  QAbstractButton *button
668  button->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarNormalButton, &opt, q));
669  button->setVisible(canFloat && !hideButtons);
670 
671  button
673  button->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarCloseButton, &opt, q));
674  button->setVisible(canClose && !hideButtons);
675 
676  q->setAttribute(Qt::WA_ContentsPropagated,
677  (canFloat || canClose) && !hideButtons);
678 
679  layout->invalidate();
680 }
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
T qobject_cast(QObject *object)
Definition: qobject.h:375
The QStyleOptionDockWidget class is used to describe the parameters for drawing a dock widget...
Definition: qstyleoption.h:504
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
QLayout * layout
Definition: qwidget_p.h:704
void invalidate()
Reimplemented Function
Definition: qlayout.cpp:673
#define Q_Q(Class)
Definition: qglobal.h:2483
virtual void setVisible(bool visible)
Definition: qwidget.cpp:7991
static bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature)
Definition: qdockwidget.cpp:74
bool nativeWindowDeco() const
QWidget * widgetForRole(Role r) const
void setIcon(const QIcon &icon)

Properties

◆ allowedAreas

Qt::DockWidgetAreas QDockWidgetPrivate::allowedAreas

Definition at line 102 of file qdockwidget_p.h.

◆ features

QDockWidget::DockWidgetFeatures QDockWidgetPrivate::features

Definition at line 101 of file qdockwidget_p.h.

Referenced by hasFeature().

◆ fixedWindowTitle

QString QDockWidgetPrivate::fixedWindowTitle

Definition at line 112 of file qdockwidget_p.h.

◆ resizer

QWidgetResizeHandler* QDockWidgetPrivate::resizer

Definition at line 104 of file qdockwidget_p.h.

◆ state

DragState* QDockWidgetPrivate::state

Definition at line 99 of file qdockwidget_p.h.

◆ toggleViewAction

QAction* QDockWidgetPrivate::toggleViewAction

Definition at line 107 of file qdockwidget_p.h.

◆ undockedGeometry

QRect QDockWidgetPrivate::undockedGeometry

Definition at line 111 of file qdockwidget_p.h.


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