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 QDYNAMICMAINWINDOW_H |
5 | #define QDYNAMICMAINWINDOW_H |
6 | |
7 | #include <QtWidgets/qtwidgetsglobal.h> |
8 | #include <QtWidgets/qwidget.h> |
9 | #if QT_CONFIG(tabwidget) |
10 | #include <QtWidgets/qtabwidget.h> |
11 | #endif |
12 | |
13 | QT_REQUIRE_CONFIG(mainwindow); |
14 | |
15 | QT_BEGIN_NAMESPACE |
16 | |
17 | class QDockWidget; |
18 | class QMainWindowPrivate; |
19 | class ; |
20 | class QStatusBar; |
21 | class QToolBar; |
22 | class ; |
23 | |
24 | class Q_WIDGETS_EXPORT QMainWindow : public QWidget |
25 | { |
26 | Q_OBJECT |
27 | |
28 | Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize) |
29 | Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle) |
30 | #if QT_CONFIG(dockwidget) |
31 | Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated) |
32 | #if QT_CONFIG(tabbar) |
33 | Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode) |
34 | #endif // QT_CONFIG(tabbar) |
35 | #if QT_CONFIG(tabwidget) |
36 | Q_PROPERTY(QTabWidget::TabShape tabShape READ tabShape WRITE setTabShape) |
37 | #endif // QT_CONFIG(tabwidget) |
38 | Q_PROPERTY(bool dockNestingEnabled READ isDockNestingEnabled WRITE setDockNestingEnabled) |
39 | #endif // QT_CONFIG(dockwidget) |
40 | Q_PROPERTY(DockOptions dockOptions READ dockOptions WRITE setDockOptions) |
41 | #if QT_CONFIG(toolbar) |
42 | Q_PROPERTY(bool unifiedTitleAndToolBarOnMac READ unifiedTitleAndToolBarOnMac |
43 | WRITE setUnifiedTitleAndToolBarOnMac) |
44 | #endif |
45 | |
46 | public: |
47 | enum DockOption { |
48 | AnimatedDocks = 0x01, |
49 | AllowNestedDocks = 0x02, |
50 | AllowTabbedDocks = 0x04, |
51 | ForceTabbedDocks = 0x08, // implies AllowTabbedDocks, !AllowNestedDocks |
52 | VerticalTabs = 0x10, // implies AllowTabbedDocks |
53 | GroupedDragging = 0x20 // implies AllowTabbedDocks |
54 | }; |
55 | Q_ENUM(DockOption) |
56 | Q_DECLARE_FLAGS(DockOptions, DockOption) |
57 | Q_FLAG(DockOptions) |
58 | |
59 | explicit QMainWindow(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); |
60 | ~QMainWindow(); |
61 | |
62 | QSize iconSize() const; |
63 | void setIconSize(const QSize &iconSize); |
64 | |
65 | Qt::ToolButtonStyle toolButtonStyle() const; |
66 | void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle); |
67 | |
68 | #if QT_CONFIG(dockwidget) |
69 | bool isAnimated() const; |
70 | bool isDockNestingEnabled() const; |
71 | #endif |
72 | |
73 | #if QT_CONFIG(tabbar) |
74 | bool documentMode() const; |
75 | void setDocumentMode(bool enabled); |
76 | #endif |
77 | |
78 | #if QT_CONFIG(tabwidget) |
79 | QTabWidget::TabShape tabShape() const; |
80 | void setTabShape(QTabWidget::TabShape tabShape); |
81 | QTabWidget::TabPosition tabPosition(Qt::DockWidgetArea area) const; |
82 | void setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition); |
83 | #endif // QT_CONFIG(tabwidget) |
84 | |
85 | void setDockOptions(DockOptions options); |
86 | DockOptions dockOptions() const; |
87 | |
88 | bool isSeparator(const QPoint &pos) const; |
89 | |
90 | #if QT_CONFIG(menubar) |
91 | QMenuBar *menuBar() const; |
92 | void setMenuBar(QMenuBar *); |
93 | |
94 | QWidget *menuWidget() const; |
95 | void setMenuWidget(QWidget *); |
96 | #endif |
97 | |
98 | #if QT_CONFIG(statusbar) |
99 | QStatusBar *statusBar() const; |
100 | void setStatusBar(QStatusBar *statusbar); |
101 | #endif |
102 | |
103 | QWidget *centralWidget() const; |
104 | void setCentralWidget(QWidget *widget); |
105 | |
106 | QWidget *takeCentralWidget(); |
107 | |
108 | #if QT_CONFIG(dockwidget) |
109 | void setCorner(Qt::Corner corner, Qt::DockWidgetArea area); |
110 | Qt::DockWidgetArea corner(Qt::Corner corner) const; |
111 | #endif |
112 | |
113 | #if QT_CONFIG(toolbar) |
114 | void addToolBarBreak(Qt::ToolBarArea area = Qt::TopToolBarArea); |
115 | void insertToolBarBreak(QToolBar *before); |
116 | |
117 | void addToolBar(Qt::ToolBarArea area, QToolBar *toolbar); |
118 | void addToolBar(QToolBar *toolbar); |
119 | QToolBar *addToolBar(const QString &title); |
120 | void insertToolBar(QToolBar *before, QToolBar *toolbar); |
121 | void removeToolBar(QToolBar *toolbar); |
122 | void removeToolBarBreak(QToolBar *before); |
123 | |
124 | bool unifiedTitleAndToolBarOnMac() const; |
125 | |
126 | Qt::ToolBarArea toolBarArea(const QToolBar *toolbar) const; |
127 | bool toolBarBreak(QToolBar *toolbar) const; |
128 | #endif // QT_CONFIG(toolbar) |
129 | |
130 | #if QT_CONFIG(dockwidget) |
131 | void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget); |
132 | void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget, |
133 | Qt::Orientation orientation); |
134 | void splitDockWidget(QDockWidget *after, QDockWidget *dockwidget, |
135 | Qt::Orientation orientation); |
136 | #if QT_CONFIG(tabbar) |
137 | void tabifyDockWidget(QDockWidget *first, QDockWidget *second); |
138 | QList<QDockWidget*> tabifiedDockWidgets(QDockWidget *dockwidget) const; |
139 | #endif |
140 | void removeDockWidget(QDockWidget *dockwidget); |
141 | bool restoreDockWidget(QDockWidget *dockwidget); |
142 | |
143 | Qt::DockWidgetArea dockWidgetArea(QDockWidget *dockwidget) const; |
144 | |
145 | void resizeDocks(const QList<QDockWidget *> &docks, |
146 | const QList<int> &sizes, Qt::Orientation orientation); |
147 | #endif // QT_CONFIG(dockwidget) |
148 | |
149 | QByteArray saveState(int version = 0) const; |
150 | bool restoreState(const QByteArray &state, int version = 0); |
151 | |
152 | #if QT_CONFIG(menu) |
153 | virtual QMenu *createPopupMenu(); |
154 | #endif |
155 | |
156 | public Q_SLOTS: |
157 | #if QT_CONFIG(dockwidget) |
158 | void setAnimated(bool enabled); |
159 | void setDockNestingEnabled(bool enabled); |
160 | #endif |
161 | #if QT_CONFIG(toolbar) |
162 | void setUnifiedTitleAndToolBarOnMac(bool set); |
163 | #endif |
164 | |
165 | Q_SIGNALS: |
166 | void iconSizeChanged(const QSize &iconSize); |
167 | void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle); |
168 | #if QT_CONFIG(dockwidget) |
169 | void tabifiedDockWidgetActivated(QDockWidget *dockWidget); |
170 | #endif |
171 | |
172 | protected: |
173 | #ifndef QT_NO_CONTEXTMENU |
174 | void contextMenuEvent(QContextMenuEvent *event) override; |
175 | #endif |
176 | bool event(QEvent *event) override; |
177 | |
178 | private: |
179 | Q_DECLARE_PRIVATE(QMainWindow) |
180 | Q_DISABLE_COPY(QMainWindow) |
181 | friend class QDockWidgetGroupWindow; |
182 | }; |
183 | |
184 | Q_DECLARE_OPERATORS_FOR_FLAGS(QMainWindow::DockOptions) |
185 | |
186 | QT_END_NAMESPACE |
187 | |
188 | #endif // QDYNAMICMAINWINDOW_H |
189 | |