19#include <private/qwidgetresizehandler_p.h>
20#include <private/qstylesheetstyle_p.h>
21#include <qpa/qplatformtheme.h>
23#include <private/qhighdpiscaling_p.h>
52{
return (
priv->features & feature) == feature; }
55{
return (dockwidget->
features() & feature) == feature; }
107 QSize dockButtonIconSize()
const;
109 mutable int m_iconSize = -1;
120 switch (
event->type()) {
134 const QStyle *effectiveStyle = style;
136#if QT_CONFIG(style_stylesheet)
137 if (style->
inherits(
"QStyleSheetStyle"))
140#if !defined(QT_NO_STYLE_PROXY)
145 return effectiveStyle->
inherits(
"QWindowsStyle");
148QSize QDockWidgetTitleButton::dockButtonIconSize()
const
150 if (m_iconSize < 0) {
159 return QSize(m_iconSize, m_iconSize);
167 if (!
icon().isNull()) {
209 opt.subControls = { };
210 opt.activeSubControls = { };
239 if (
auto groupWindow =
241 floating = floating || groupWindow->tabLayoutInfo();
252#if defined(Q_OS_ANDROID)
256 static const bool wayland =
258 return !(xcb || wayland);
275 qWarning(
"QDockWidgetLayout::addItem(): please use QDockWidgetLayout::setWidget()");
282 for (
int i = 0;
i < item_list.
size(); ++
i) {
295 for (
int i = 0;
i < item_list.
size(); ++
i) {
312 for (
int i = 0;
i < item_list.
size(); ++
i) {
334 int fw = floating && !nativeDeco
349 if (content.
width() < 0)
354 const QMargins margins =
w->contentsMargins();
356 QSize min =
w->minimumSize().shrunkBy(margins);
365 uint explicitMin = 0;
366 uint explicitMax = 0;
367 if (
w->d_func()->extra !=
nullptr) {
368 explicitMin =
w->d_func()->extra->explicitMinSize;
369 explicitMax =
w->d_func()->extra->explicitMaxSize;
382 return result.boundedTo(max).expandedTo(min);
389 QSize content(-1, -1);
391 content = item_list[
Content]->sizeHint();
399 const QSize content = item_list[
Content]->maximumSize();
413 content = item_list[
Content]->minimumSize();
426 return item_list.
at(
r);
432 if (old !=
nullptr) {
450 return vertical ?
size.height() :
size.width();
455 return vertical ?
size.width() :
size.height();
465 QSize closeSize(0, 0);
466 QSize floatSize(0, 0);
469 closeSize =
item->widget()->sizeHint();
473 floatSize =
item->widget()->sizeHint();
493 QSize closeSize(0, 0);
494 QSize floatSize(0, 0);
496 closeSize =
item->widget()->sizeHint();
498 floatSize =
item->widget()->sizeHint();
506 return qMax(buttonHeight + 2, titleFontMetrics.
height() + 2*mw);
515 int fw =
q->isFloating() && !nativeDeco
534 item->setGeometry(_titleArea);
537 q->initStyleOption(&
opt);
540 if (!
item->isEmpty()) {
545 item->setGeometry(
r);
550 if (!
item->isEmpty()) {
555 item->setGeometry(
r);
564 r.adjust(0, fw, -fw, -fw);
566 r.setTop(_titleArea.
bottom() + 1);
567 r.adjust(fw, 0, -fw, -fw);
569 item->setGeometry(
r);
594 QSize widgetMin(0, 0);
596 widgetMin =
item->minimumSize();
670 QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(
parent());
675 option->title =
d->fixedWindowTitle;
687 if (
b ==
q->isHidden()) {
701 q->initStyleOption(&
opt);
705 bool hideButtons = nativeDeco || customTitleBar;
714#if QT_CONFIG(accessibility)
716 button->setAccessibleName(QDockWidget::tr(
"Float"));
717 button->setAccessibleDescription(QDockWidget::tr(
"Undocks and re-attaches the dock widget"));
723#if QT_CONFIG(accessibility)
725 button->setAccessibleName(QDockWidget::tr(
"Close"));
726 button->setAccessibleDescription(QDockWidget::tr(
"Closes the dock widget"));
735 q->setFloating(!
q->isFloating());
748 if (
state !=
nullptr)
753 if (
layout->pluggingWidget !=
nullptr)
756 state =
new QDockWidgetPrivate::DragState;
758 state->globalPressPos =
q->mapToGlobal(
pos);
759 state->widgetInitialPos =
q->isFloating() ?
q->pos() :
q->mapToGlobal(
QPoint(0, 0));
760 state->dragging =
false;
761 state->widgetItem =
nullptr;
762 state->ownWidgetItem =
false;
764 state->ctrlDrag =
false;
783 bool wasFloating =
q->isFloating();
786 if (
state->widgetItem ==
nullptr) {
791 QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(
parent);
792 if (floatingTab && !
q->isFloating())
793 state->widgetItem =
new QDockWidgetGroupWindowItem(floatingTab);
796 state->ownWidgetItem =
true;
802 state->dragging =
true;
804#if QT_CONFIG(draganddrop)
805 if (QMainWindowLayout::needsPlatformDrag()) {
831 if (
state->dragging) {
836 if (abort || !mwLayout->
plug(
state->widgetItem)) {
839 if (
state->ownWidgetItem) {
840 delete state->widgetItem;
841 state->widgetItem =
nullptr;
847 Qt::WindowFlags
flags =
q->windowFlags();
848 flags &=
~Qt::X11BypassWindowManagerHint;
855 if (
q->isFloating()) {
857#if QT_CONFIG(tabwidget)
861 tabPosition = mwLayout->tabPosition(
area);
862 }
else if (
auto dwgw = qobject_cast<QDockWidgetGroupWindow *>(
q->parent())) {
865 tabPosition = mwLayout->tabPosition(
toDockWidgetArea(dwgw->layoutInfo()->dockPos));
896 if (active && !resizer)
907 if (mainWinLayout ==
nullptr)
915#if QT_CONFIG(mainwindow)
919 = qobject_cast<QDockWidgetLayout*>(
layout);
924 QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(
parent);
931 (qobject_cast<QMainWindow*>(
parent) ==
nullptr && !floatingTab) ||
968#if QT_CONFIG(mainwindow)
975 = qobject_cast<QDockWidgetLayout *>(
layout);
980 && (
event->position().toPoint() -
state->pressPos).manhattanLength()
991 q->setFloating(
true);
1003 QMargins windowMargins =
q->window()->windowHandle()->frameMargins();
1010 const QScreen *wdgScreen =
q->screen();
1013 if (
Q_LIKELY(screenFrom && screenTo && wdgScreen && orgWdgScreen)) {
1017 event->globalPosition().toPoint(), screenTo->
handle());
1022 const QPoint nativeNewPos = nativeWdgOrgPos + (nativeTo - nativeFrom);
1024 - windowMarginOffset;
1028 <<
"QDockWidget failed to find relevant screen info. screenFrom:" << screenFrom
1029 <<
"screenTo:" << screenTo <<
" wdgScreen:" << wdgScreen <<
"orgWdgScreen"
1031 pos =
event->globalPosition().toPoint() -
state->pressPos - windowMarginOffset;
1036 const int dx =
q->geometry().
x() -
q->x();
1037 const int dy =
q->geometry().y() -
q->y();
1041 QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(
parent);
1042 if (floatingTab && !
q->isFloating())
1043 floatingTab->move(
pos);
1047 mwlayout->
hover(
state->widgetItem,
event->globalPosition().toPoint());
1058#if QT_CONFIG(mainwindow)
1061 if (QMainWindowLayout::needsPlatformDrag())
1086 titleRect.
adjust(0, fw, 0, 0);
1089 switch (
event->type()) {
1093 if (
state !=
nullptr)
1095 if (qobject_cast<QMainWindow*>(
parent) ==
nullptr && qobject_cast<QDockWidgetGroupWindow*>(
parent) ==
nullptr)
1100 if (
state ==
nullptr)
1110#if !defined(Q_OS_MAC) && !defined(Q_OS_WASM)
1117#if defined(Q_OS_MAC) || defined(Q_OS_WASM)
1132 qreal ratio =
event->oldSize().width() / (1.0 *
event->size().width());
1133 state->pressPos.setX(
state->pressPos.x() / ratio);
1146 if (!
q->isWindow() && qobject_cast<QDockWidgetGroupWindow*>(
parent) ==
nullptr)
1152 if (
state->ctrlDrag)
1158 QPoint globalMousePos =
event->pos() +
state->pressPos;
1166 r.moveTopLeft(
q->mapToGlobal(
QPoint(0, 0)));
1182 if (!floating &&
parent) {
1185 && !qobject_cast<QDockWidgetGroupWindow *>(
parent))
1189 const bool wasFloating =
q->isFloating();
1192 const bool hidden =
q->isHidden();
1212 if (
unplug && !QMainWindowLayout::needsPlatformDrag())
1215 q->setWindowFlags(
flags);
1219 q->setGeometry(
rect);
1226 if (floating != wasFloating) {
1227 emit q->topLevelChanged(floating);
1228 if (!floating &&
parent) {
1231 emit q->dockLocationChanged(mwlayout->dockWidgetArea(
q));
1404 = qobject_cast<QDockWidgetLayout*>(this->
layout());
1410 if (closableChanged &&
layout->nativeWindowDeco()) {
1411 QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow *>(
parent());
1413 floatingTab->adjustFlags();
1415 d->setWindowState(
true ,
true );
1444 if (
d->state !=
nullptr)
1447 QRect r =
d->undockedGeometry;
1455 if (
x() < 0 ||
y() < 0)
1474 if (areas ==
d->allowedAreas)
1476 d->allowedAreas = areas;
1483 return d->allowedAreas;
1499 switch (event->
type()) {
1511 d->toggleViewAction->setText(
d->fixedWindowTitle);
1513#if QT_CONFIG(tabbar)
1517 info->updateTabBar();
1544 = qobject_cast<QDockWidgetLayout*>(this->
layout());
1546 bool nativeDeco =
layout->nativeWindowDeco();
1548 if (!nativeDeco && !customTitleBar) {
1579 switch (
event->type()) {
1584 d->toggleViewAction->setChecked(
false);
1588 d->toggleViewAction->setChecked(
true);
1589 QPoint parentTopLeft(0, 0);
1608 if (
win !=
nullptr) {
1612#if QT_CONFIG(tabbar)
1620 update(qobject_cast<QDockWidgetLayout *>(this->
layout())->titleArea());
1664 if (
d->state &&
d->state->dragging)
1688 return d->toggleViewAction;
1785 = qobject_cast<QDockWidgetLayout*>(this->
layout());
1790 d->setWindowState(
true ,
true );
1805 = qobject_cast<QDockWidgetLayout*>(this->
layout());
1811#include "qdockwidget.moc"
1812#include "moc_qdockwidget.cpp"
1813#include "moc_qdockwidget_p.cpp"
The QAction class provides an abstraction for user commands that can be added to different user inter...
void setMenuRole(MenuRole menuRole)
void setText(const QString &text)
static QFont font()
Returns the default application font.
int startDragDistance
the minimum distance required for a drag and drop operation to start.
The QCloseEvent class contains parameters that describe a close event.
@ NonClientAreaMouseButtonDblClick
@ ApplicationLayoutDirectionChange
@ NonClientAreaMouseButtonRelease
@ NonClientAreaMouseButtonPress
Type type() const
Returns the event type.
\reentrant \inmodule QtGui
int height() const
Returns the height of the font.
QScreen * primaryScreen
the primary (or default) screen of the application.
QString platformName
The name of the underlying platform plugin.
static QScreen * screenAt(const QPoint &point)
Returns the screen at point, or \nullptr if outside of any screen.
static QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
static QPoint mapPositionFromNative(const QPoint &pos, const QPlatformScreen *platformScreen)
QSize actualSize(const QSize &size, Mode mode=Normal, State state=Off) const
Returns the actual size of the icon for the requested size, mode, and state.
The QLayoutItem class provides an abstract item that a QLayout manipulates.
The QLayout class is the base class of geometry managers.
QRect geometry() const override
\reimp
void removeWidget(QWidget *w)
Removes the widget widget from the layout.
void addChildWidget(QWidget *w)
This function is called from addWidget() functions in subclasses to add w as a managed widget of a la...
void setSizeConstraint(SizeConstraint)
void invalidate() override
\reimp
QWidget * parentWidget() const
Returns the parent widget of this layout, or \nullptr if this layout is not installed on any widget.
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
void hover(QLayoutItem *hoverTarget, const QPoint &mousePos)
void revert(QLayoutItem *widgetItem)
void restore(bool keepSavedState=false)
bool plug(QLayoutItem *widgetItem)
The QMainWindow class provides a main application window.
constexpr int left() const noexcept
Returns the left margin.
constexpr int top() const noexcept
Returns the top margin.
The QMoveEvent class contains event parameters for move events.
const QObjectList & children() const
Returns a list of child objects.
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
The QPaintEvent class contains event parameters for paint events.
\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.
The QProxyStyle class is a convenience class that simplifies dynamically overriding QStyle elements.
QStyle * baseStyle() const
Returns the proxy base style object.
\inmodule QtCore\reentrant
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr void setRight(int pos) noexcept
Sets the right edge of the rectangle to the given x coordinate.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr void setBottom(int pos) noexcept
Sets the bottom edge of the rectangle to the given y coordinate.
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr void setLeft(int pos) noexcept
Sets the left edge of the rectangle to the given x coordinate.
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
The QResizeEvent class contains event parameters for resize events.
The QScreen class is used to query screen properties. \inmodule QtGui.
QPlatformScreen * handle() const
Get the platform screen handle.
QRect availableVirtualGeometry
the available geometry of the virtual desktop to which this screen belongs
constexpr int height() const noexcept
Returns the height.
constexpr QSize shrunkBy(QMargins m) const noexcept
constexpr int width() const noexcept
Returns the width.
constexpr void setWidth(int w) noexcept
Sets the width to the given width.
constexpr void setHeight(int h) noexcept
Sets the height to the given height.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
int compare(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
\variable QStyleOptionFocusRect::backgroundColor
void initFrom(const QWidget *w)
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
@ SH_DockWidget_ButtonsHaveFrame
@ SP_TitleBarNormalButton
@ PM_DockWidgetFrameWidth
@ PM_DockWidgetTitleMargin
@ PM_DockWidgetTitleBarButtonMargin
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
@ SE_DockWidgetFloatButton
@ SE_DockWidgetCloseButton
QString title
the window's title in the windowing system
qDeleteAll(list.begin(), list.end())
Combined button and popup list for selecting options.
@ X11BypassWindowManagerHint
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
static int area(const QSize &s)
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLboolean GLboolean GLboolean b
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble q
static bool isWindow(QObject *object)
QFileInfo info(fileName)
[8]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent