qmainwindow.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2016 The Qt Company Ltd.
  4. ** Contact: https://www.qt.io/licensing/
  5. **
  6. ** This file is part of the QtWidgets module of the Qt Toolkit.
  7. **
  8. ** $QT_BEGIN_LICENSE:LGPL$
  9. ** Commercial License Usage
  10. ** Licensees holding valid commercial Qt licenses may use this file in
  11. ** accordance with the commercial license agreement provided with the
  12. ** Software or, alternatively, in accordance with the terms contained in
  13. ** a written agreement between you and The Qt Company. For licensing terms
  14. ** and conditions see https://www.qt.io/terms-conditions. For further
  15. ** information use the contact form at https://www.qt.io/contact-us.
  16. **
  17. ** GNU Lesser General Public License Usage
  18. ** Alternatively, this file may be used under the terms of the GNU Lesser
  19. ** General Public License version 3 as published by the Free Software
  20. ** Foundation and appearing in the file LICENSE.LGPL3 included in the
  21. ** packaging of this file. Please review the following information to
  22. ** ensure the GNU Lesser General Public License version 3 requirements
  23. ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
  24. **
  25. ** GNU General Public License Usage
  26. ** Alternatively, this file may be used under the terms of the GNU
  27. ** General Public License version 2.0 or (at your option) the GNU General
  28. ** Public license version 3 or any later version approved by the KDE Free
  29. ** Qt Foundation. The licenses are as published by the Free Software
  30. ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
  31. ** included in the packaging of this file. Please review the following
  32. ** information to ensure the GNU General Public License requirements will
  33. ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
  34. ** https://www.gnu.org/licenses/gpl-3.0.html.
  35. **
  36. ** $QT_END_LICENSE$
  37. **
  38. ****************************************************************************/
  39. #ifndef QDYNAMICMAINWINDOW_H
  40. #define QDYNAMICMAINWINDOW_H
  41. #include <QtWidgets/qwidget.h>
  42. #include <QtWidgets/qtabwidget.h>
  43. QT_BEGIN_NAMESPACE
  44. #ifndef QT_NO_MAINWINDOW
  45. class QDockWidget;
  46. class QMainWindowPrivate;
  47. class QMenuBar;
  48. class QStatusBar;
  49. class QToolBar;
  50. class QMenu;
  51. class Q_WIDGETS_EXPORT QMainWindow : public QWidget
  52. {
  53. Q_OBJECT
  54. Q_FLAGS(DockOptions)
  55. Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
  56. Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle)
  57. #ifndef QT_NO_DOCKWIDGET
  58. Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated)
  59. #ifndef QT_NO_TABBAR
  60. Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
  61. #endif // QT_NO_TABBAR
  62. #ifndef QT_NO_TABWIDGET
  63. Q_PROPERTY(QTabWidget::TabShape tabShape READ tabShape WRITE setTabShape)
  64. #endif // QT_NO_TABWIDGET
  65. Q_PROPERTY(bool dockNestingEnabled READ isDockNestingEnabled WRITE setDockNestingEnabled)
  66. #endif // QT_NO_DOCKWIDGET
  67. Q_PROPERTY(DockOptions dockOptions READ dockOptions WRITE setDockOptions)
  68. #ifndef QT_NO_TOOLBAR
  69. Q_PROPERTY(bool unifiedTitleAndToolBarOnMac READ unifiedTitleAndToolBarOnMac WRITE setUnifiedTitleAndToolBarOnMac)
  70. #endif
  71. public:
  72. enum DockOption {
  73. AnimatedDocks = 0x01,
  74. AllowNestedDocks = 0x02,
  75. AllowTabbedDocks = 0x04,
  76. ForceTabbedDocks = 0x08, // implies AllowTabbedDocks, !AllowNestedDocks
  77. VerticalTabs = 0x10, // implies AllowTabbedDocks
  78. GroupedDragging = 0x20 // implies AllowTabbedDocks
  79. };
  80. Q_ENUM(DockOption)
  81. Q_DECLARE_FLAGS(DockOptions, DockOption)
  82. explicit QMainWindow(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
  83. ~QMainWindow();
  84. QSize iconSize() const;
  85. void setIconSize(const QSize &iconSize);
  86. Qt::ToolButtonStyle toolButtonStyle() const;
  87. void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle);
  88. #ifndef QT_NO_DOCKWIDGET
  89. bool isAnimated() const;
  90. bool isDockNestingEnabled() const;
  91. #endif
  92. #ifndef QT_NO_TABBAR
  93. bool documentMode() const;
  94. void setDocumentMode(bool enabled);
  95. #endif
  96. #ifndef QT_NO_TABWIDGET
  97. QTabWidget::TabShape tabShape() const;
  98. void setTabShape(QTabWidget::TabShape tabShape);
  99. QTabWidget::TabPosition tabPosition(Qt::DockWidgetArea area) const;
  100. void setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition);
  101. #endif // QT_NO_TABWIDGET
  102. void setDockOptions(DockOptions options);
  103. DockOptions dockOptions() const;
  104. bool isSeparator(const QPoint &pos) const;
  105. #ifndef QT_NO_MENUBAR
  106. QMenuBar *menuBar() const;
  107. void setMenuBar(QMenuBar *menubar);
  108. QWidget *menuWidget() const;
  109. void setMenuWidget(QWidget *menubar);
  110. #endif
  111. #ifndef QT_NO_STATUSBAR
  112. QStatusBar *statusBar() const;
  113. void setStatusBar(QStatusBar *statusbar);
  114. #endif
  115. QWidget *centralWidget() const;
  116. void setCentralWidget(QWidget *widget);
  117. QWidget *takeCentralWidget();
  118. #ifndef QT_NO_DOCKWIDGET
  119. void setCorner(Qt::Corner corner, Qt::DockWidgetArea area);
  120. Qt::DockWidgetArea corner(Qt::Corner corner) const;
  121. #endif
  122. #ifndef QT_NO_TOOLBAR
  123. void addToolBarBreak(Qt::ToolBarArea area = Qt::TopToolBarArea);
  124. void insertToolBarBreak(QToolBar *before);
  125. void addToolBar(Qt::ToolBarArea area, QToolBar *toolbar);
  126. void addToolBar(QToolBar *toolbar);
  127. QToolBar *addToolBar(const QString &title);
  128. void insertToolBar(QToolBar *before, QToolBar *toolbar);
  129. void removeToolBar(QToolBar *toolbar);
  130. void removeToolBarBreak(QToolBar *before);
  131. bool unifiedTitleAndToolBarOnMac() const;
  132. Qt::ToolBarArea toolBarArea(QToolBar *toolbar) const;
  133. bool toolBarBreak(QToolBar *toolbar) const;
  134. #endif
  135. #ifndef QT_NO_DOCKWIDGET
  136. void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget);
  137. void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget,
  138. Qt::Orientation orientation);
  139. void splitDockWidget(QDockWidget *after, QDockWidget *dockwidget,
  140. Qt::Orientation orientation);
  141. void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
  142. QList<QDockWidget*> tabifiedDockWidgets(QDockWidget *dockwidget) const;
  143. void removeDockWidget(QDockWidget *dockwidget);
  144. bool restoreDockWidget(QDockWidget *dockwidget);
  145. Qt::DockWidgetArea dockWidgetArea(QDockWidget *dockwidget) const;
  146. void resizeDocks(const QList<QDockWidget *> &docks,
  147. const QList<int> &sizes, Qt::Orientation orientation);
  148. #endif // QT_NO_DOCKWIDGET
  149. QByteArray saveState(int version = 0) const;
  150. bool restoreState(const QByteArray &state, int version = 0);
  151. #ifndef QT_NO_MENU
  152. virtual QMenu *createPopupMenu();
  153. #endif
  154. public Q_SLOTS:
  155. #ifndef QT_NO_DOCKWIDGET
  156. void setAnimated(bool enabled);
  157. void setDockNestingEnabled(bool enabled);
  158. #endif
  159. #ifndef QT_NO_TOOLBAR
  160. void setUnifiedTitleAndToolBarOnMac(bool set);
  161. #endif
  162. Q_SIGNALS:
  163. void iconSizeChanged(const QSize &iconSize);
  164. void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle);
  165. protected:
  166. #ifndef QT_NO_CONTEXTMENU
  167. void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE;
  168. #endif
  169. bool event(QEvent *event) Q_DECL_OVERRIDE;
  170. private:
  171. Q_DECLARE_PRIVATE(QMainWindow)
  172. Q_DISABLE_COPY(QMainWindow)
  173. };
  174. Q_DECLARE_OPERATORS_FOR_FLAGS(QMainWindow::DockOptions)
  175. #endif // QT_NO_MAINWINDOW
  176. QT_END_NAMESPACE
  177. #endif // QDYNAMICMAINWINDOW_H