qdockwidget.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 QDYNAMICDOCKWIDGET_H
  40. #define QDYNAMICDOCKWIDGET_H
  41. #include <QtWidgets/qwidget.h>
  42. QT_BEGIN_NAMESPACE
  43. #ifndef QT_NO_DOCKWIDGET
  44. class QDockAreaLayout;
  45. class QDockWidgetPrivate;
  46. class QMainWindow;
  47. class QStyleOptionDockWidget;
  48. class Q_WIDGETS_EXPORT QDockWidget : public QWidget
  49. {
  50. Q_OBJECT
  51. Q_FLAGS(DockWidgetFeatures)
  52. Q_PROPERTY(bool floating READ isFloating WRITE setFloating)
  53. Q_PROPERTY(DockWidgetFeatures features READ features WRITE setFeatures NOTIFY featuresChanged)
  54. Q_PROPERTY(Qt::DockWidgetAreas allowedAreas READ allowedAreas
  55. WRITE setAllowedAreas NOTIFY allowedAreasChanged)
  56. Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle DESIGNABLE true)
  57. public:
  58. explicit QDockWidget(const QString &title, QWidget *parent = Q_NULLPTR,
  59. Qt::WindowFlags flags = Qt::WindowFlags());
  60. explicit QDockWidget(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
  61. ~QDockWidget();
  62. QWidget *widget() const;
  63. void setWidget(QWidget *widget);
  64. enum DockWidgetFeature {
  65. DockWidgetClosable = 0x01,
  66. DockWidgetMovable = 0x02,
  67. DockWidgetFloatable = 0x04,
  68. DockWidgetVerticalTitleBar = 0x08,
  69. DockWidgetFeatureMask = 0x0f,
  70. AllDockWidgetFeatures = DockWidgetClosable|DockWidgetMovable|DockWidgetFloatable, // ### Qt 6: remove
  71. NoDockWidgetFeatures = 0x00,
  72. Reserved = 0xff
  73. };
  74. Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)
  75. void setFeatures(DockWidgetFeatures features);
  76. DockWidgetFeatures features() const;
  77. void setFloating(bool floating);
  78. inline bool isFloating() const { return isWindow(); }
  79. void setAllowedAreas(Qt::DockWidgetAreas areas);
  80. Qt::DockWidgetAreas allowedAreas() const;
  81. void setTitleBarWidget(QWidget *widget);
  82. QWidget *titleBarWidget() const;
  83. inline bool isAreaAllowed(Qt::DockWidgetArea area) const
  84. { return (allowedAreas() & area) == area; }
  85. #ifndef QT_NO_ACTION
  86. QAction *toggleViewAction() const;
  87. #endif
  88. Q_SIGNALS:
  89. void featuresChanged(QDockWidget::DockWidgetFeatures features);
  90. void topLevelChanged(bool topLevel);
  91. void allowedAreasChanged(Qt::DockWidgetAreas allowedAreas);
  92. void visibilityChanged(bool visible);
  93. void dockLocationChanged(Qt::DockWidgetArea area);
  94. protected:
  95. void changeEvent(QEvent *event) Q_DECL_OVERRIDE;
  96. void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
  97. void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
  98. bool event(QEvent *event) Q_DECL_OVERRIDE;
  99. void initStyleOption(QStyleOptionDockWidget *option) const;
  100. private:
  101. Q_DECLARE_PRIVATE(QDockWidget)
  102. Q_DISABLE_COPY(QDockWidget)
  103. Q_PRIVATE_SLOT(d_func(), void _q_toggleView(bool))
  104. Q_PRIVATE_SLOT(d_func(), void _q_toggleTopLevel())
  105. friend class QDockAreaLayout;
  106. friend class QDockWidgetItem;
  107. friend class QMainWindowLayout;
  108. friend class QDockWidgetLayout;
  109. friend class QDockAreaLayoutInfo;
  110. };
  111. Q_DECLARE_OPERATORS_FOR_FLAGS(QDockWidget::DockWidgetFeatures)
  112. #endif // QT_NO_DOCKWIDGET
  113. QT_END_NAMESPACE
  114. #endif // QDYNAMICDOCKWIDGET_H