4#ifndef QMAINWINDOWLAYOUT_P_H
5#define QMAINWINDOWLAYOUT_P_H
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
21#include "QtWidgets/qlayout.h"
23#include "QtWidgets/qtabbar.h"
24#include "QtGui/qpainter.h"
25#include "QtGui/qevent.h"
27#include "QtCore/qbasictimer.h"
28#include "QtCore/qlist.h"
29#include "QtCore/qset.h"
30#include "private/qlayoutengine_p.h"
31#include "private/qwidgetanimator_p.h"
32#if QT_CONFIG(dockwidget)
33#include "private/qdockwidget_p.h"
48#include <QtCore/qloggingcategory.h>
49#include <QtCore/qpointer.h>
60template <
typename Layout>
63 Layout *layout() {
return static_cast<Layout *
>(
this); }
64 const Layout *layout()
const {
return static_cast<const Layout *
>(
this); }
65 QWidget *window() {
return layout()->parentWidget(); }
75#if QT_CONFIG(dockwidget)
82 bool hasOldCursor =
false;
83 bool cursorAdjusted =
false;
86 QList<int> movingSeparator;
87 QPoint movingSeparatorOrigin, movingSeparatorPos;
90 bool startSeparatorMove(
const QPoint &
pos);
93 bool windowEvent(
QEvent *e);
99#if QT_CONFIG(dockwidget)
102template <
typename Layout>
107 if (
path.size() == 1) {
109 switch (
path.first()) {
126template <
typename Layout>
133 if (!hoverSeparator.isEmpty())
134 w->
update(
layout()->dockAreaLayoutInfo()->separatorRect(hoverSeparator));
135 hoverSeparator.clear();
137 if (cursorAdjusted) {
138 cursorAdjusted =
false;
140 w->setCursor(oldCursor);
144 }
else if (movingSeparator.isEmpty()) {
145 QList<int> pathToSeparator =
layout()->dockAreaLayoutInfo()->findSeparator(
pos);
147 if (pathToSeparator != hoverSeparator) {
148 if (!hoverSeparator.isEmpty())
149 w->
update(
layout()->dockAreaLayoutInfo()->separatorRect(hoverSeparator));
151 hoverSeparator = pathToSeparator;
153 if (hoverSeparator.isEmpty()) {
154 if (cursorAdjusted) {
155 cursorAdjusted =
false;
157 w->setCursor(oldCursor);
162 w->update(
layout()->dockAreaLayoutInfo()->separatorRect(hoverSeparator));
163 if (!cursorAdjusted) {
164 oldCursor =
w->cursor();
167 adjustedCursor = separatorCursor(hoverSeparator);
168 w->setCursor(adjustedCursor);
169 cursorAdjusted =
true;
176template <
typename Layout>
180 switch (
event->type()) {
184 layout()->dockAreaLayoutInfo()->paintSeparators(&
p,
w,
r, hoverPos);
199 adjustCursor(
QPoint(0, 0));
202 adjustCursor(
QPoint(0, 0));
248 if (cursorAdjusted && adjustedCursor.shape() !=
w->cursor().shape()) {
249 oldCursor =
w->cursor();
253 w->setCursor(adjustedCursor);
260 separatorMoveTimer.stop();
261 if (movingSeparator.isEmpty())
263 if (movingSeparatorOrigin == movingSeparatorPos)
267 window()->update(
layout()->dockAreaLayoutInfo()->separatorRegion());
270 layout()->dockAreaLayoutInfo()->separatorMove(movingSeparator, movingSeparatorOrigin,
272 movingSeparatorPos = movingSeparatorOrigin;
282template <
typename Layout>
285 movingSeparator =
layout()->dockAreaLayoutInfo()->findSeparator(
pos);
287 if (movingSeparator.isEmpty())
291 movingSeparatorPos = movingSeparatorOrigin =
pos;
295template <
typename Layout>
298 if (movingSeparator.isEmpty())
300 movingSeparatorPos =
pos;
301 separatorMoveTimer.start(0,
window());
304template <
typename Layout>
307 if (movingSeparator.isEmpty())
309 movingSeparator.clear();
310 layout()->savedState.clear();
318 explicit QDockWidgetGroupWindow(
QWidget *parent =
nullptr, Qt::WindowFlags
f = {})
327 void destroyOrHideIfEmpty();
328 bool hasVisibleDockWidgets()
const;
330 bool hasNativeDecos()
const;
333 void updateCurrentGapRect();
338 void destroyIfSingleItemLeft();
339 QList<QDockWidget *> dockWidgets()
const {
return findChildren<QDockWidget *>(); }
341 QRect currentGapRect;
342 QList<int> currentGapPos;
353 QSize m_removedFrameSize;
358class QDockWidgetGroupWindowItem :
public QWidgetItem
361 explicit QDockWidgetGroupWindowItem(QDockWidgetGroupWindow *parent) :
QWidgetItem(parent) {}
365 QSize minimumSize()
const override
367 if (
auto dw =
widget()->findChild<QDockWidget *>())
368 return dw->minimumSize();
369 return lay()->minimumSize();
371 QSize maximumSize()
const override
376 return lay()->maximumSize();
378 QSize sizeHint()
const override
383 return lay()->sizeHint();
388 QLayout *lay()
const {
return const_cast<QDockWidgetGroupWindowItem *
>(
this)->
widget()->
layout(); }
406#if QT_CONFIG(toolbar)
410#if QT_CONFIG(dockwidget)
417 void apply(
bool animated);
418 void deleteAllLayoutItems();
419 void deleteCentralWidgetItem();
421 QSize sizeHint()
const;
422 QSize minimumSize()
const;
430 QRect itemRect(
const QList<int> &
path)
const;
431 QRect gapRect(
const QList<int> &
path)
const;
436 QWidget *centralWidget()
const;
443 bool isValid()
const;
453class QMainWindowTabBar;
468 void setDockOptions(QMainWindow::DockOptions opts);
473#if QT_CONFIG(statusbar)
479 QWidget *centralWidget()
const;
483#if QT_CONFIG(toolbar)
485 void insertToolBarBreak(
QToolBar *before);
486 void removeToolBarBreak(
QToolBar *before);
491 bool toolBarBreak(
QToolBar *toolBar)
const;
492 void getStyleOptionInfo(QStyleOptionToolBar *
option,
QToolBar *toolBar)
const;
493 void removeToolBar(
QToolBar *toolbar);
494 void toggleToolBarsVisible();
499#if QT_CONFIG(dockwidget)
502 enum DockWidgetAreaSize {Visible, Maximum};
515 void setVerticalTabsEnabled(
bool enabled);
519 bool documentMode()
const;
520 void setDocumentMode(
bool enabled);
523 QSet<QTabBar*> usedTabBars;
524 QList<QTabBar*> unusedTabBars;
525 bool verticalTabsEnabled;
528 QSet<QWidget*> usedSeparatorWidgets;
529 QList<QWidget*> unusedSeparatorWidgets;
532#if QT_CONFIG(tabwidget)
541 QDockWidgetGroupWindow *createTabbedDockWindow();
545 QDockAreaLayout *dockAreaLayoutInfo() {
return &layoutState.dockAreaLayout; }
559 void setGeometry(
const QRect &
r)
override;
562 int count()
const override;
564 QSize sizeHint()
const override;
565 QSize minimumSize()
const override;
568 void invalidate()
override;
575#if QT_CONFIG(rubberband)
576 QPointer<QRubberBand> gapIndicator;
578#if QT_CONFIG(dockwidget)
579 QPointer<QDockWidgetGroupWindow> currentHoveredFloat;
580 void setCurrentHoveredFloat(QDockWidgetGroupWindow *
w);
587 bool isInApplyState =
false;
594 void applyRestoredState();
595 void restore(
bool keepSavedState =
false);
598#if QT_CONFIG(draganddrop)
599 static bool needsPlatformDrag();
608 void updateGapIndicator();
609#if QT_CONFIG(dockwidget)
612 void tabMoved(
int from,
int to);
617 void updateTabBarShapes();
619 bool isInRestoreState =
false;
622#if QT_CONFIG(dockwidget) && !defined(QT_NO_DEBUG_STREAM)
The QCursor class provides a mouse cursor with an arbitrary shape.
\inmodule QtCore\reentrant
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
The QLayoutItem class provides an abstract item that a QLayout manipulates.
The QLayout class is the base class of geometry managers.
void update()
Updates the layout for parentWidget().
QList< int > hoverSeparator
QLayoutItem * centralWidgetItem
QList< int > currentGapPos
QBasicTimer discardRestoredStateTimer
QWidgetAnimator widgetAnimator
std::unique_ptr< QMainWindowLayoutState > restoredState
QMainWindow::DockOptions dockOptions
QMainWindowLayoutState layoutState
The QMainWindow class provides a main application window.
T findChild(QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
Returns the child of this object that can be cast into type T and that is called name,...
The QPaintEvent class contains event parameters for paint events.
The QPainter class performs low-level painting on widgets and other paint devices.
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
The QRegion class specifies a clip region for a painter.
The QRubberBand class provides a rectangle or line that can indicate a selection or a boundary.
QPointF position() const
Returns the position of the point in this event, relative to the widget or item that received the eve...
Qt::MouseButton button() const
Returns the button that caused the event.
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
The QStatusBar class provides a horizontal bar suitable for presenting status information.
The QTabBar class provides a tab bar, e.g.
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
static int area(const QSize &s)
#define Q_DECLARE_LOGGING_CATEGORY(name)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLsizei const GLchar *const * path
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static constexpr QChar sep
static const struct TessellationWindingOrderTab cw[]
#define Q_AUTOTEST_EXPORT
#define QT_REQUIRE_CONFIG(feature)
settings remove("monkey")