Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qmdisubwindow_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QMDISUBWINDOW_P_H
5#define QMDISUBWINDOW_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
19#include "qmdisubwindow.h"
20
21#include <QStyle>
22#include <QStyleOptionTitleBar>
23#if QT_CONFIG(menubar)
24#include <QMenuBar>
25#endif
26#if QT_CONFIG(sizegrip)
27#include <QSizeGrip>
28#endif
29#include <QPointer>
30#include <QDebug>
31#include <private/qwidget_p.h>
32
34
36
37class QVBoxLayout;
38class QMouseEvent;
39
40namespace QMdi {
41template<typename T>
42class ControlElement : public T // ELFVERSION:ignore
43{
44public:
50
51 void *qt_metacast(const char *classname) override
52 {
53 if (classname && strcmp(classname, "ControlElement") == 0)
54 return this;
55 return nullptr;
56 }
57
58 QPointer<QMdiSubWindow> mdiChild;
59};
60
61class ControlContainer : public QObject // ELFVERSION:ignore
62{
63public:
66
67#if QT_CONFIG(menubar)
68 void showButtonsInMenuBar(QMenuBar *menuBar);
69 void removeButtonsFromMenuBar(QMenuBar *menuBar = nullptr);
70 QMenuBar *menuBar() const { return m_menuBar; }
71#endif
72 void updateWindowIcon(const QIcon &windowIcon);
73 QWidget *controllerWidget() const { return m_controllerWidget; }
74 QWidget *systemMenuLabel() const { return m_menuLabel; }
75
76private:
77 QPointer<QWidget> previousLeft;
78 QPointer<QWidget> previousRight;
79#if QT_CONFIG(menubar)
80 QPointer<QMenuBar> m_menuBar;
81#endif
82 QPointer<QWidget> m_controllerWidget;
83 QPointer<QWidget> m_menuLabel;
84 QPointer<QMdiSubWindow> mdiChild;
85};
86} // namespace QMdi
87
89{
90 Q_DECLARE_PUBLIC(QMdiSubWindow)
91public:
92 // Enums and typedefs.
105
107 HMove = 0x01,
108 VMove = 0x02,
109 HResize = 0x04,
110 VResize = 0x08,
111 HResizeReverse = 0x10,
112 VResizeReverse = 0x20
113 };
114
123 /* Add new states _above_ this line! */
124 NumWindowStateActions
125 };
126
131 bool hover;
132 OperationInfo(uint changeFlags, Qt::CursorShape cursorShape, bool hover = true)
133 : changeFlags(changeFlags),
134 cursorShape(cursorShape),
135 hover(hover)
136 {}
137 };
138
139 typedef QMap<Operation, OperationInfo> OperationInfoMap;
140
142
143 // Variables.
144 QPointer<QWidget> baseWidget;
145 QPointer<QWidget> restoreFocusWidget;
146 QPointer<QMdi::ControlContainer> controlContainer;
147#if QT_CONFIG(sizegrip)
148 QPointer<QSizeGrip> sizeGrip;
149#endif
150#if QT_CONFIG(rubberband)
151 QRubberBand *rubberBand;
152#endif
161#if QT_CONFIG(rubberband)
162 bool isInRubberBandMode;
163#endif
181 QPointer<QMenu> systemMenu;
182#ifndef QT_NO_ACTION
183 QPointer<QAction> actions[NumWindowStateActions];
184#endif
185 QMdiSubWindow::SubWindowOptions options;
193
194 // Slots.
195 void _q_updateStaysOnTopHint();
196 void _q_enterInteractiveMode();
197 void _q_processFocusChanged(QWidget *old, QWidget *now);
198
199 // Functions.
200 void leaveInteractiveMode();
201 void removeBaseWidget();
202 void initOperationMap();
203#if QT_CONFIG(menu)
204 void createSystemMenu();
205#endif
206 void updateCursor();
207 void updateDirtyRegions();
208 void updateGeometryConstraints();
209 void updateMask();
210 void setNewGeometry(const QPoint &pos);
211 void setMinimizeMode();
212 void setNormalMode();
213 void setMaximizeMode();
214 void setActive(bool activate, bool changeFocus = true);
215 void processClickedSubControl();
216 QRegion getRegion(Operation operation) const;
217 Operation getOperation(const QPoint &pos) const;
218 QStyleOptionTitleBar titleBarOptions() const;
219 void ensureWindowState(Qt::WindowState state);
220 int titleBarHeight(const QStyleOptionTitleBar &options) const;
221 void sizeParameters(int *margin, int *minWidth) const;
222 bool drawTitleBarWhenMaximized() const;
223#if QT_CONFIG(menubar)
224 QMenuBar *menuBar() const;
225 void showButtonsInMenuBar(QMenuBar *menuBar);
226 void removeButtonsFromMenuBar();
227#endif
228 void updateWindowTitle(bool requestFromChild);
229#if QT_CONFIG(rubberband)
230 void enterRubberBandMode();
231 void leaveRubberBandMode();
232#endif
233 QPalette desktopPalette() const;
234 void updateActions();
235 void setFocusWidget();
236 bool restoreFocus();
237 void storeFocusWidget();
238 void setWindowFlags(Qt::WindowFlags windowFlags) override;
239 void setVisible(WindowStateAction, bool visible = true);
240#ifndef QT_NO_ACTION
241 void setEnabled(WindowStateAction, bool enable = true);
242#if QT_CONFIG(menu)
243 void addToSystemMenu(WindowStateAction, const QString &text, const char *slot);
244#endif
245#endif // QT_NO_ACTION
246 QSize iconSize() const;
247#if QT_CONFIG(sizegrip)
248 void setSizeGrip(QSizeGrip *sizeGrip);
249 void setSizeGripVisible(bool visible = true) const;
250#endif
251 void updateInternalWindowTitle();
252 QString originalWindowTitle();
253 QString originalWindowTitleHelper() const;
254 void setNewWindowTitle();
255
256 inline int titleBarHeight() const
257 {
258 Q_Q(const QMdiSubWindow);
259 if (!parent || q->windowFlags() & Qt::FramelessWindowHint
260 || (q->isMaximized() && !drawTitleBarWhenMaximized())) {
261 return 0;
262 }
263 QStyleOptionTitleBar options = titleBarOptions();
264 int height = options.rect.height();
265 if (hasBorder(options))
266 height += q->isMinimized() ? 8 : 4;
267 return height;
268 }
269
271 {
272 Q_Q(const QMdiSubWindow);
273 QStyleOptionTitleBar titleBarOptions = this->titleBarOptions();
274 return q->style()->hitTestComplexControl(QStyle::CC_TitleBar, &titleBarOptions, pos, q);
275 }
276
277 inline void setNewGeometry(QRect *geometry)
278 {
279 Q_Q(QMdiSubWindow);
280 Q_ASSERT(parent);
281 geometry->setSize(geometry->size().expandedTo(internalMinimumSize));
282#if QT_CONFIG(rubberband)
283 if (isInRubberBandMode)
284 rubberBand->setGeometry(*geometry);
285 else
286#endif
287 q->setGeometry(*geometry);
288 }
289
290 inline bool hasBorder(const QStyleOptionTitleBar &options) const
291 {
292 Q_Q(const QMdiSubWindow);
293 return !q->style()->styleHint(QStyle::SH_TitleBar_NoBorder, &options, q);
294 }
295
296 inline bool autoRaise() const
297 {
298 Q_Q(const QMdiSubWindow);
299 return q->style()->styleHint(QStyle::SH_TitleBar_AutoRaise, nullptr, q);
300 }
301
302 inline bool isResizeOperation() const
303 {
304 return currentOperation != None && currentOperation != Move;
305 }
306
307 inline bool isMoveOperation() const
308 {
309 return currentOperation == Move;
310 }
311};
312
314
315#endif // QMDISUBWINDOW_P_H
\reentrant
Definition qfont.h:22
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
QPointer< QWidget > restoreFocusWidget
QStyle::SubControl hoveredSubControl
bool isMoveOperation() const
QPointer< QMdi::ControlContainer > controlContainer
QStyleOptionTitleBar cachedStyleOptions
OperationInfoMap operationMap
QPointer< QMenu > systemMenu
bool isResizeOperation() const
QMap< Operation, OperationInfo > OperationInfoMap
QPointer< QWidget > baseWidget
QStyle::SubControl activeSubControl
void setNewGeometry(QRect *geometry)
bool hasBorder(const QStyleOptionTitleBar &options) const
QStyle::SubControl getSubControl(const QPoint &pos) const
Qt::FocusReason focusInReason
QMdiSubWindow::SubWindowOptions options
The QMdiSubWindow class provides a subwindow class for QMdiArea.
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)
The QMenuBar class provides a horizontal menu bar.
Definition qmenubar.h:20
\inmodule QtGui
Definition qevent.h:196
\inmodule QtCore
Definition qobject.h:103
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr int height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:239
constexpr void setSize(const QSize &s) noexcept
Sets the size of the rectangle to the given size.
Definition qrect.h:387
constexpr QSize size() const noexcept
Returns the size of the rectangle.
Definition qrect.h:242
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
The QRubberBand class provides a rectangle or line that can indicate a selection or a boundary.
Definition qrubberband.h:18
The QSizeGrip class provides a resize handle for resizing top-level windows.
Definition qsizegrip.h:16
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\variable QStyleOptionToolBox::selectedPosition
@ SH_TitleBar_NoBorder
Definition qstyle.h:611
@ SH_TitleBar_AutoRaise
Definition qstyle.h:636
@ CC_TitleBar
Definition qstyle.h:337
SubControl
This enum describes the available sub controls.
Definition qstyle.h:347
The QVBoxLayout class lines up widgets vertically.
Definition qboxlayout.h:91
virtual void setWindowFlags(Qt::WindowFlags windowFlags)
void setVisible(bool)
Definition qwidget.cpp:8274
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QString text
opt iconSize
else opt state
[0]
Combined button and popup list for selecting options.
WindowState
Definition qnamespace.h:251
CursorShape
@ FramelessWindowHint
Definition qnamespace.h:225
FocusReason
@ None
Definition qhash.cpp:531
GLint GLsizei GLsizei height
GLboolean enable
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_AUTOTEST_EXPORT
#define QT_REQUIRE_CONFIG(feature)
unsigned int uint
Definition qtypes.h:34
QObject::connect nullptr
QLayoutItem * child
[0]
QMenuBar * menuBar
[0]
OperationInfo(uint changeFlags, Qt::CursorShape cursorShape, bool hover=true)