5#ifndef QMDISUBWINDOW_P_H
6#define QMDISUBWINDOW_P_H
19#include <QtWidgets/private/qtwidgetsglobal_p.h>
23#include <QStyleOptionTitleBar>
27#if QT_CONFIG(sizegrip)
32#include <private/qwidget_p.h>
34#include <QtCore/private/qenumindexedarray_p.h>
36QT_REQUIRE_CONFIG(mdiarea);
56 if (classname && strcmp(classname,
"ControlElement") == 0)
80 QPointer<QWidget> previousLeft;
81 QPointer<QWidget> previousRight;
85 QPointer<QWidget> m_controllerWidget;
86 QPointer<QWidget> m_menuLabel;
87 QPointer<QMdiSubWindow> mdiChild;
93 Q_DECLARE_PUBLIC(QMdiSubWindow)
108 static constexpr size_t NumOperations = size_t{BottomRightResize} + 1;
115 HResizeReverse = 0x10,
116 VResizeReverse = 0x20
119 enum WindowStateAction {
128 NumWindowStateActions
131 struct OperationInfo {
132 constexpr Qt::CursorShape cursorShape()
const {
return Qt::CursorShape(_cursorShape); }
137 using OperationInfoMap = QEnumIndexedArray<
143 QMdiSubWindowPrivate();
146 QPointer<QWidget> baseWidget;
147 QPointer<QWidget> restoreFocusWidget;
148 QPointer<QMdi::ControlContainer> controlContainer;
149#if QT_CONFIG(sizegrip)
150 QPointer<QSizeGrip> sizeGrip;
152#if QT_CONFIG(rubberband)
153 QRubberBand *rubberBand;
155 QPoint mousePressPosition;
157 QSize internalMinimumSize;
158 QSize userMinimumSize;
162 bool isInInteractiveMode;
163#if QT_CONFIG(rubberband)
164 bool isInRubberBandMode;
167 bool ignoreWindowTitleChange;
168 bool ignoreNextActivationEvent;
169 bool activationEnabled;
170 bool isShadeRequestFromMinimizeMode;
172 bool isWidgetHiddenByUs;
174 bool isExplicitlyDeactivated;
175 int keyboardSingleStep;
176 int keyboardPageStep;
177 QBasicTimer resizeTimer;
178 std::optional<Operation> currentOperation = std::nullopt;
179 QStyle::SubControl hoveredSubControl;
180 QStyle::SubControl activeSubControl;
181 Qt::FocusReason focusInReason;
182 QEnumIndexedArray<QRegion, Operation, NumOperations> regions;
183 QPointer<QMenu> systemMenu;
185 QEnumIndexedArrayFor<QPointer<QAction>, NumWindowStateActions> actions;
187 QMdiSubWindow::SubWindowOptions options;
188 QString lastChildWindowTitle;
189 QPalette titleBarPalette;
193 QStyleOptionTitleBar cachedStyleOptions;
194 QString originalTitle;
197 void _q_updateStaysOnTopHint();
198 void _q_enterInteractiveMode();
199 void _q_processFocusChanged(QWidget *old, QWidget *now);
202 void leaveInteractiveMode();
203 void removeBaseWidget();
204 static constexpr OperationInfoMap initOperationMap();
206 void createSystemMenu();
209 void updateDirtyRegions();
210 void updateGeometryConstraints();
212 void setNewGeometry(
const QPoint &pos);
213 void setMinimizeMode();
214 void setNormalMode();
215 void setMaximizeMode();
216 void setActive(
bool activate,
bool changeFocus =
true);
217 void processClickedSubControl();
218 QRegion getRegion(Operation operation)
const;
219 std::optional<Operation> getOperation(QPoint pos)
const;
220 QStyleOptionTitleBar titleBarOptions()
const;
221 void ensureWindowState(Qt::WindowState state);
222 int titleBarHeight(
const QStyleOptionTitleBar &options)
const;
223 void sizeParameters(
int *margin,
int *minWidth)
const;
224 bool drawTitleBarWhenMaximized()
const;
225#if QT_CONFIG(menubar)
226 QMenuBar *menuBar()
const;
227 void showButtonsInMenuBar(QMenuBar *menuBar);
228 void removeButtonsFromMenuBar();
230 void updateWindowTitle(
bool requestFromChild);
231#if QT_CONFIG(rubberband)
232 void enterRubberBandMode();
233 void leaveRubberBandMode();
235 QPalette desktopPalette()
const;
236 void updateActions();
237 void setFocusWidget();
239 void storeFocusWidget();
240 void setWindowFlags(Qt::WindowFlags windowFlags) override;
241 using QWidgetPrivate::setVisible;
242 void setVisible(WindowStateAction,
bool visible =
true);
244 void setEnabled(WindowStateAction,
bool enable =
true);
246 void addToSystemMenu(WindowStateAction,
const QString &text,
const char *slot);
249 QSize iconSize()
const;
250#if QT_CONFIG(sizegrip)
251 void setSizeGrip(QSizeGrip *sizeGrip);
252 void setSizeGripVisible(
bool visible =
true)
const;
254 void updateInternalWindowTitle();
255 QString originalWindowTitle();
256 QString originalWindowTitleHelper()
const;
257 void setNewWindowTitle();
259 inline int titleBarHeight()
const
261 Q_Q(
const QMdiSubWindow);
262 if (!parent || q->windowFlags() & Qt::FramelessWindowHint
263 || (q->isMaximized() && !drawTitleBarWhenMaximized())) {
266 QStyleOptionTitleBar options = titleBarOptions();
267 int height = options.rect.height();
268 if (hasBorder(options))
269 height += q->isMinimized() ? 8 : 4;
273 inline QStyle::SubControl getSubControl(
const QPoint &pos)
const
275 Q_Q(
const QMdiSubWindow);
276 QStyleOptionTitleBar titleBarOptions =
this->titleBarOptions();
277 return q->style()->hitTestComplexControl(QStyle::CC_TitleBar, &titleBarOptions, pos, q);
280 inline void setNewGeometry(QRect *geometry)
284 geometry->setSize(geometry->size().expandedTo(internalMinimumSize));
285#if QT_CONFIG(rubberband)
286 if (isInRubberBandMode)
287 rubberBand->setGeometry(*geometry);
290 q->setGeometry(*geometry);
293 inline bool hasBorder(
const QStyleOptionTitleBar &options)
const
295 Q_Q(
const QMdiSubWindow);
296 return !q->style()->styleHint(QStyle::SH_TitleBar_NoBorder, &options, q);
299 inline bool autoRaise()
const
301 Q_Q(
const QMdiSubWindow);
302 return q->style()->styleHint(QStyle::SH_TitleBar_AutoRaise,
nullptr, q);
305 inline bool isResizeOperation()
const
307 return currentOperation && currentOperation != Move;
310 inline bool isMoveOperation()
const
312 return currentOperation == Move;
QWidget * controllerWidget() const
QWidget * systemMenuLabel() const
void updateWindowIcon(const QIcon &windowIcon)
ControlContainer(QMdiSubWindow *mdiChild)
QPointer< QMdiSubWindow > mdiChild
void * qt_metacast(const char *classname) override
ControlElement(QMdiSubWindow *child)
QSize sizeHint() const override
bool event(QEvent *event) override
This virtual function receives events to an object and should return true if the event e was recogniz...
void mousePressEvent(QMouseEvent *mouseEvent) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
void mouseReleaseEvent(QMouseEvent *mouseEvent) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse release even...
void mouseDoubleClickEvent(QMouseEvent *mouseEvent) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse double click...
void paintEvent(QPaintEvent *paintEvent) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
Combined button and popup list for selecting options.
static const int BoundaryMargin
static bool isChildOfQMdiSubWindow(const QWidget *child)
static const int NumSubControls
static const QStyle::SubControl SubControls[]
constexpr auto operationMap
static int getMoveDeltaComponent(uint cflags, uint moveFlag, uint resizeFlag, int delta, int maxDelta, int minDelta)
static bool isHoverControl(QStyle::SubControl control)
static const Qt::WindowFlags CustomizeWindowFlags
static int getResizeDeltaComponent(uint cflags, uint resizeFlag, uint resizeReverseFlag, int delta)
static bool isMacStyle(QStyle *style)
QString qt_setWindowTitle_helperHelper(const QString &, const QWidget *)
Returns a modified window title with the [*] place holder replaced according to the rules described i...
static ControlElement< T > * ptr(QWidget *widget)
static bool isChildOfTabbedQMdiArea(const QMdiSubWindow *child)