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()) {
131QSize QDockWidgetTitleButton::dockButtonIconSize()
const
133 if (m_iconSize < 0) {
136 m_iconSize = (m_iconSize * 5) / 8;
138 return QSize(m_iconSize, m_iconSize);
146 if (!
icon().isNull()) {
188 opt.subControls = { };
189 opt.activeSubControls = { };
201 :
QLayout(parent), verticalTitleBar(
false), item_list(RoleCount, 0)
218 if (
auto groupWindow =
220 floating = floating || groupWindow->tabLayoutInfo();
231#if defined(Q_OS_ANDROID)
235 static const bool wayland =
237 return !(xcb || wayland);
254 qWarning(
"QDockWidgetLayout::addItem(): please use QDockWidgetLayout::setWidget()");
261 for (
int i = 0;
i < item_list.
size(); ++
i) {
274 for (
int i = 0;
i < item_list.
size(); ++
i) {
291 for (
int i = 0;
i < item_list.
size(); ++
i) {
313 int fw = floating && !nativeDeco
328 if (content.
width() < 0)
333 const QMargins margins =
w->contentsMargins();
335 QSize min =
w->minimumSize().shrunkBy(margins);
344 uint explicitMin = 0;
345 uint explicitMax = 0;
346 if (
w->d_func()->extra !=
nullptr) {
347 explicitMin =
w->d_func()->extra->explicitMinSize;
348 explicitMax =
w->d_func()->extra->explicitMaxSize;
361 return result.boundedTo(max).expandedTo(min);
368 QSize content(-1, -1);
370 content = item_list[
Content]->sizeHint();
378 const QSize content = item_list[
Content]->maximumSize();
392 content = item_list[
Content]->minimumSize();
405 return item_list.
at(
r);
411 if (old !=
nullptr) {
429 return vertical ?
size.height() :
size.width();
434 return vertical ?
size.width() :
size.height();
444 QSize closeSize(0, 0);
445 QSize floatSize(0, 0);
448 closeSize =
item->widget()->sizeHint();
452 floatSize =
item->widget()->sizeHint();
472 QSize closeSize(0, 0);
473 QSize floatSize(0, 0);
475 closeSize =
item->widget()->sizeHint();
477 floatSize =
item->widget()->sizeHint();
485 return qMax(buttonHeight + 2, titleFontMetrics.height() + 2*mw);
494 int fw =
q->isFloating() && !nativeDeco
513 item->setGeometry(_titleArea);
516 q->initStyleOption(&
opt);
519 if (!
item->isEmpty()) {
524 item->setGeometry(
r);
529 if (!
item->isEmpty()) {
534 item->setGeometry(
r);
543 r.adjust(0, fw, -fw, -fw);
545 r.setTop(_titleArea.
bottom() + 1);
546 r.adjust(fw, 0, -fw, -fw);
548 item->setGeometry(
r);
573 QSize widgetMin(0, 0);
575 widgetMin =
item->minimumSize();
650 QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(
parent());
654 option->rect = dwlayout->titleArea();
655 option->title =
d->fixedWindowTitle;
667 if (
b ==
q->isHidden()) {
681 q->initStyleOption(&
opt);
684 bool nativeDeco = dwLayout->nativeWindowDeco();
685 bool hideButtons = nativeDeco || customTitleBar;
694#if QT_CONFIG(accessibility)
696 button->setAccessibleName(QDockWidget::tr(
"Float"));
697 button->setAccessibleDescription(QDockWidget::tr(
"Undocks and re-attaches the dock widget"));
703#if QT_CONFIG(accessibility)
705 button->setAccessibleName(QDockWidget::tr(
"Close"));
706 button->setAccessibleDescription(QDockWidget::tr(
"Closes the dock widget"));
715 q->setFloating(!
q->isFloating());
728 if (
state !=
nullptr)
733 if (
layout->pluggingWidget !=
nullptr)
736 state =
new QDockWidgetPrivate::DragState;
738 state->globalPressPos =
q->mapToGlobal(
pos);
739 state->widgetInitialPos =
q->isFloating() ?
q->pos() :
q->mapToGlobal(
QPoint(0, 0));
740 state->dragging =
false;
741 state->widgetItem =
nullptr;
742 state->ownWidgetItem =
false;
744 state->ctrlDrag =
false;
763#if QT_CONFIG(draganddrop)
764 bool wasFloating =
q->isFloating();
768 if (
state->widgetItem ==
nullptr) {
773 QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(
parent);
774 if (floatingTab && !
q->isFloating())
775 state->widgetItem =
new QDockWidgetGroupWindowItem(floatingTab);
778 state->ownWidgetItem =
true;
784 state->dragging =
true;
786#if QT_CONFIG(draganddrop)
787 if (QMainWindowLayout::needsPlatformDrag()) {
813 if (
state->dragging) {
825 if (
state->ownWidgetItem) {
826 delete state->widgetItem;
827 state->widgetItem =
nullptr;
831 if (!dwLayout->nativeWindowDeco()) {
833 Qt::WindowFlags
flags =
q->windowFlags();
834 flags &=
~Qt::X11BypassWindowManagerHint;
841 if (
q->isFloating()) {
843#if QT_CONFIG(tabwidget)
847 tabPosition = mwLayout->tabPosition(
area);
848 }
else if (
auto dwgw = qobject_cast<QDockWidgetGroupWindow *>(
q->parent())) {
851 tabPosition = mwLayout->tabPosition(
toDockWidgetArea(dwgw->layoutInfo()->dockPos));
856 if (
auto *groupWindow = qobject_cast<QDockWidgetGroupWindow *>(
q->parentWidget()))
857 groupWindow->reparent(
q);
864 mwLayout->revert(
state->widgetItem);
887 const auto *dwLayout = qobject_cast<QDockWidgetLayout *>(
layout);
888 if (dwLayout->nativeWindowDeco(
q->isFloating()))
891 if (active && !resizer)
902 if (mainWinLayout ==
nullptr)
905 return (
const void*)mainWinLayout->pluggingWidget == (
const void*)
q;
910#if QT_CONFIG(mainwindow)
914 = qobject_cast<QDockWidgetLayout*>(
layout);
916 if (!dwLayout->nativeWindowDeco()) {
917 QRect titleArea = dwLayout->titleArea();
919 QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(
parent);
926 (qobject_cast<QMainWindow*>(
parent) ==
nullptr && !floatingTab) ||
948 if (!dwLayout->nativeWindowDeco()) {
949 QRect titleArea = dwLayout->titleArea();
966 return mwLayout->isDockWidgetTabbed(
q);
972#if QT_CONFIG(mainwindow)
979 = qobject_cast<QDockWidgetLayout *>(
layout);
981 if (!dwlayout->nativeWindowDeco()) {
983 && mwlayout->pluggingWidget ==
nullptr
984 && (
event->position().toPoint() -
state->pressPos).manhattanLength()
995 q->setFloating(
true);
1008 QMargins windowMargins =
q->window()->windowHandle()->frameMargins();
1009 QPoint windowMarginOffset =
QPoint(windowMargins.left(), windowMargins.top());
1015 const QScreen *wdgScreen =
q->screen();
1018 if (
Q_LIKELY(screenFrom && screenTo && wdgScreen && orgWdgScreen)) {
1020 state->widgetInitialPos, orgWdgScreen->handle());
1022 event->globalPosition().toPoint(), screenTo->handle());
1024 screenFrom->handle());
1027 const QPoint nativeNewPos = nativeWdgOrgPos + (nativeTo - nativeFrom);
1029 - windowMarginOffset;
1033 <<
"QDockWidget failed to find relevant screen info. screenFrom:" << screenFrom
1034 <<
"screenTo:" << screenTo <<
" wdgScreen:" << wdgScreen <<
"orgWdgScreen"
1036 pos =
event->globalPosition().toPoint() -
state->pressPos - windowMarginOffset;
1041 const int dx =
q->geometry().
x() -
q->x();
1042 const int dy =
q->geometry().y() -
q->y();
1046 QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow*>(
parent);
1047 if (floatingTab && !
q->isFloating())
1048 floatingTab->move(
pos);
1052 mwlayout->hover(
state->widgetItem,
event->globalPosition().toPoint());
1063#if QT_CONFIG(mainwindow)
1064#if QT_CONFIG(draganddrop)
1067 if (QMainWindowLayout::needsPlatformDrag())
1090 titleRect.
setLeft(geo.left());
1093 titleRect.
adjust(0, fw, 0, 0);
1096 switch (
event->type()) {
1100 if (
state !=
nullptr)
1102 if (qobject_cast<QMainWindow*>(
parent) ==
nullptr && qobject_cast<QDockWidgetGroupWindow*>(
parent) ==
nullptr)
1107 if (
state ==
nullptr)
1117#if !defined(Q_OS_MAC) && !defined(Q_OS_WASM)
1123#if defined(Q_OS_MAC) || defined(Q_OS_WASM)
1138 qreal ratio =
event->oldSize().width() / (1.0 *
event->size().width());
1152 if (!
q->isWindow() && qobject_cast<QDockWidgetGroupWindow*>(
parent) ==
nullptr)
1158 if (
state->ctrlDrag)
1164 QPoint globalMousePos =
event->pos() +
state->pressPos;
1174 if (dwLayout->nativeWindowDeco(
true))
1175 r.adjust(0, dwLayout->titleHeight(), 0, 0);
1188 if (!floating &&
parent) {
1191 && !qobject_cast<QDockWidgetGroupWindow *>(
parent))
1195 const bool wasFloating =
q->isFloating();
1198 const bool hidden =
q->isHidden();
1206 const bool nativeDeco = dwLayout->nativeWindowDeco(floating);
1216#if QT_CONFIG(draganddrop)
1219 if (
unplug && !QMainWindowLayout::needsPlatformDrag())
1223 q->setWindowFlags(
flags);
1227 q->setGeometry(
rect);
1234 if (floating != wasFloating) {
1235 emit q->topLevelChanged(floating);
1236 if (!floating &&
parent) {
1239 emit q->dockLocationChanged(mwlayout->dockWidgetArea(
q));
1410 = qobject_cast<QDockWidgetLayout*>(this->
layout());
1416 if (closableChanged &&
layout->nativeWindowDeco()) {
1417 QDockWidgetGroupWindow *floatingTab = qobject_cast<QDockWidgetGroupWindow *>(
parent());
1419 floatingTab->adjustFlags();
1421 d->setWindowState(
true ,
true );
1453 if (
d->state !=
nullptr)
1456 QRect r =
d->undockedGeometry;
1464 if (
x() < 0 ||
y() < 0)
1483 if (areas ==
d->allowedAreas)
1485 d->allowedAreas = areas;
1492 return d->allowedAreas;
1508 switch (event->
type()) {
1520 d->toggleViewAction->setText(
d->fixedWindowTitle);
1522#if QT_CONFIG(tabbar)
1526 info->updateTabBar();
1549 event->setAccepted(canClose);
1559 = qobject_cast<QDockWidgetLayout*>(this->
layout());
1561 bool nativeDeco =
layout->nativeWindowDeco();
1563 if (!nativeDeco && !customTitleBar) {
1594 switch (
event->type()) {
1599 d->toggleViewAction->setChecked(
false);
1603 d->toggleViewAction->setChecked(
true);
1604 QPoint parentTopLeft(0, 0);
1623 if (
win !=
nullptr) {
1625 onTop = siblings.size() > 0 && siblings.last() == (
QObject*)
this;
1627#if QT_CONFIG(tabbar)
1635 update(qobject_cast<QDockWidgetLayout *>(this->
layout())->titleArea());
1679 if (
d->state &&
d->state->dragging)
1703 return d->toggleViewAction;
1800 = qobject_cast<QDockWidgetLayout*>(this->
layout());
1805 d->setWindowState(
true ,
true );
1820 = qobject_cast<QDockWidgetLayout*>(this->
layout());
1824#ifndef QT_NO_DEBUG_STREAM
1831 dbg <<
"QDockWidget(0x0)";
1835 dbg <<
"QDockWidget(" <<
static_cast<const void *
>(
dockWidget);
1846#include "qdockwidget.moc"
1847#include "moc_qdockwidget.cpp"
1848#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 triggered(bool checked=false)
This signal is emitted when an action is activated by the user; for example, when the user clicks a m...
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
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
The QMainWindow class provides a main application window.
The QMoveEvent class contains event parameters for move events.
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
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
QString objectName
the name of this object
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
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 void setX(int x) noexcept
Sets the x coordinate of this point to the given x coordinate.
\inmodule QtCore\reentrant
constexpr void moveTopLeft(const QPoint &p) noexcept
Moves the rectangle, leaving the top-left corner at the given position.
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 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 x() 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 y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
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.
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.
@ 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)
static bool onTop(QWaylandQuickShellSurfaceItem *surf)