KDDockWidgets API Documentation  1.5
KDDockWidgets.h
Go to the documentation of this file.
1 /*
2  This file is part of KDDockWidgets.
3 
4  SPDX-FileCopyrightText: 2019-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5  Author: SĂ©rgio Martins <sergio.martins@kdab.com>
6 
7  SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
8 
9  Contact KDAB at <info@kdab.com> for commercial licensing options.
10 */
11 
19 #ifndef KD_KDDOCKWIDGETS_H
20 #define KD_KDDOCKWIDGETS_H
21 
22 #include "docks_export.h"
23 #include "Qt5Qt6Compat_p.h"
24 
25 #include <QObject>
26 #include <QDebug>
27 
28 #ifdef Q_OS_WIN
29 // Only on Windows, where this is popular. On linux the Qt::Tool windows need reparenting. Untested on macOS.
30 #define KDDOCKWIDGETS_SUPPORTS_NESTED_MAINWINDOWS
31 #endif
32 
33 namespace Layouting {
34 class Item;
35 class ItemBoxContainer;
36 }
37 
38 namespace KDDockWidgets {
39 DOCKS_EXPORT
40 Q_NAMESPACE
41 class MultiSplitter;
42 class DropArea;
43 
45 {
51 };
52 Q_ENUM_NS(Location)
53 
55 {
60 };
62 Q_DECLARE_FLAGS(MainWindowOptions, MainWindowOption)
63 Q_ENUM_NS(MainWindowOptions)
64 
65 enum class DefaultSizeMode
70 {
71  ItemSize,
72  Fair,
73  FairButFloor,
75 };
76 Q_ENUM_NS(DefaultSizeMode)
77 
78 enum AddingOption
81 {
84 };
85 Q_ENUM_NS(AddingOption)
86 
88 {
89  StartVisible = 0,
91 };
92 Q_ENUM_NS(InitialVisibilityOption)
93 
94 
105 {
106  // Implicit ctors for convenience:
107 
108  InitialOption() = default;
109 
111  : visibility(v)
112  {
113  }
114 
116  : preferredSize(size)
117  {
118  }
119 
121  : visibility(v)
122  , preferredSize(size)
123  {
124  }
125 
126  QT_DEPRECATED_X("AddingOption is deprecated and will be removed in v1.5. Use InitialVisibilityOption instead.")
128  : visibility(opt == AddingOption_StartHidden ? InitialVisibilityOption::StartHidden
129  : InitialVisibilityOption::StartVisible)
130  {
131  }
132 
133  bool startsHidden() const
134  {
135  return visibility == InitialVisibilityOption::StartHidden;
136  }
137 
139  {
140  return o == Qt::Horizontal ? preferredSize.width()
141  : preferredSize.height();
142  }
143 
145  {
146  return preferredLength(o) > 0;
147  }
148 
155  InitialVisibilityOption visibility = InitialVisibilityOption::StartVisible;
156 
167 
168 private:
169  friend class Layouting::Item;
170  friend class Layouting::ItemBoxContainer;
171  friend class KDDockWidgets::MultiSplitter;
172  friend class KDDockWidgets::DropArea;
173 
175  : sizeMode(mode)
176  {
177  }
178 
179  DefaultSizeMode sizeMode = DefaultSizeMode::Fair;
180 };
181 
183 {
186 };
188 Q_DECLARE_FLAGS(RestoreOptions, RestoreOption)
189 Q_ENUM_NS(RestoreOptions)
190 
192 {
193  Classic,
194  Segmented,
195  None
196 };
197 Q_ENUM_NS(DropIndicatorType)
198 
201 {
205 };
206 Q_DECLARE_FLAGS(SuggestedGeometryHints, SuggestedGeometryHint)
207 Q_ENUM_NS(SuggestedGeometryHint)
208 
209 enum class SideBarLocation
211 {
212  None,
213  North,
214  East,
215  West,
216  South
217 };
218 
221 {
222  Close,
223  Float,
224  Minimize,
225  Maximize,
226  Normal, // Restore from maximized state
227  AutoHide,
228  UnautoHide
229 };
230 Q_ENUM_NS(TitleBarButtonType)
231 
232 inline Qt5Qt6Compat::qhashtype qHash(SideBarLocation loc, Qt5Qt6Compat::qhashtype seed)
234 {
235  return ::qHash(static_cast<uint>(loc), seed);
236 }
237 
240 {
253 };
254 Q_DECLARE_FLAGS(CursorPositions, CursorPosition)
255 Q_ENUM_NS(CursorPosition)
256 
257 enum FrameOption
259 {
265 };
266 Q_DECLARE_FLAGS(FrameOptions, FrameOption)
267 Q_ENUM_NS(FrameOptions)
268 
269 inline QString locationStr(Location loc)
271 {
272  switch (loc) {
274  return QStringLiteral("none");
276  return QStringLiteral("left");
278  return QStringLiteral("top");
280  return QStringLiteral("right");
282  return QStringLiteral("bottom");
283  }
284 
285  return QString();
286 }
287 }
288 
289 QT_BEGIN_NAMESPACE
292 {
293  d << o.startsHidden();
294  return d;
295 }
296 QT_END_NAMESPACE
297 
298 Q_DECLARE_OPERATORS_FOR_FLAGS(KDDockWidgets::FrameOptions)
299 Q_DECLARE_METATYPE(KDDockWidgets::InitialVisibilityOption)
300 
301 #endif
KDDockWidgets::SuggestedGeometryHint_PreserveCenter
@ SuggestedGeometryHint_PreserveCenter
Definition: KDDockWidgets.h:203
KDDockWidgets::InitialOption::InitialOption
InitialOption(InitialVisibilityOption v, QSize size)
Definition: KDDockWidgets.h:120
KDDockWidgets::FrameOption
FrameOption
Definition: KDDockWidgets.h:259
KDDockWidgets::CursorPosition_All
@ CursorPosition_All
Definition: KDDockWidgets.h:252
KDDockWidgets::InitialVisibilityOption
InitialVisibilityOption
Definition: KDDockWidgets.h:88
KDDockWidgets::FrameOption_None
@ FrameOption_None
Definition: KDDockWidgets.h:260
ItemBoxContainer
KDDockWidgets::InitialOption
Struct describing the preferred dock widget size and visibility when adding it to a layout.
Definition: KDDockWidgets.h:105
KDDockWidgets::CursorPosition_TopRight
@ CursorPosition_TopRight
Definition: KDDockWidgets.h:247
KDDockWidgets::TitleBarButtonType
TitleBarButtonType
describes a type of button you can have in the title bar
Definition: KDDockWidgets.h:221
KDDockWidgets::DefaultSizeMode::ItemSize
@ ItemSize
Simply uses the Item::size() of the item being added. Actual used size might be smaller if our window...
KDDockWidgets::InitialOption::preferredLength
int preferredLength(Qt::Orientation o) const
Definition: KDDockWidgets.h:138
KDDockWidgets::DropIndicatorType
DropIndicatorType
Definition: KDDockWidgets.h:192
KDDockWidgets::Location_OnTop
@ Location_OnTop
Left docking location
Definition: KDDockWidgets.h:48
KDDockWidgets::qHash
Qt5Qt6Compat::qhashtype qHash(SideBarLocation loc, Qt5Qt6Compat::qhashtype seed)
Definition: KDDockWidgets.h:233
KDDockWidgets::CursorPosition
CursorPosition
Definition: KDDockWidgets.h:240
KDDockWidgets::Location
Location
Definition: KDDockWidgets.h:45
KDDockWidgets::SideBarLocation::West
@ West
QSize
KDDockWidgets::InitialVisibilityOption::StartVisible
@ StartVisible
The dock widget is made visible when docked.
QDebug
KDDockWidgets::locationStr
QString locationStr(Location loc)
Definition: KDDockWidgets.h:270
KDDockWidgets::CursorPosition_Left
@ CursorPosition_Left
Definition: KDDockWidgets.h:242
KDDockWidgets::CursorPosition_Bottom
@ CursorPosition_Bottom
Definition: KDDockWidgets.h:245
KDDockWidgets::CursorPosition_Undefined
@ CursorPosition_Undefined
Definition: KDDockWidgets.h:241
KDDockWidgets::Location_OnBottom
@ Location_OnBottom
Right docking location
Definition: KDDockWidgets.h:50
KDDockWidgets::MainWindowOption_None
@ MainWindowOption_None
Definition: KDDockWidgets.h:56
KDDockWidgets::AddingOption_None
@ AddingOption_None
Definition: KDDockWidgets.h:82
KDDockWidgets::DropIndicatorType::Classic
@ Classic
The default.
KDDockWidgets::CursorPosition_Vertical
@ CursorPosition_Vertical
Definition: KDDockWidgets.h:251
KDDockWidgets::FrameOption_IsOverlayed
@ FrameOption_IsOverlayed
Definition: KDDockWidgets.h:263
KDDockWidgets::CursorPosition_TopLeft
@ CursorPosition_TopLeft
Definition: KDDockWidgets.h:246
KDDockWidgets::MainWindowOption_MDI
@ MainWindowOption_MDI
Makes the MainWindow always have a central frame, for tabbing documents
Definition: KDDockWidgets.h:58
KDDockWidgets::SideBarLocation::None
@ None
KDDockWidgets::MainWindowOption_HasCentralWidget
@ MainWindowOption_HasCentralWidget
The layout will be MDI. DockWidgets can have arbitrary positions, not restricted by any layout
Definition: KDDockWidgets.h:59
QString
KDDockWidgets::CursorPosition_Horizontal
@ CursorPosition_Horizontal
Definition: KDDockWidgets.h:250
KDDockWidgets::FrameOption_AlwaysShowsTabs
@ FrameOption_AlwaysShowsTabs
Definition: KDDockWidgets.h:261
KDDockWidgets::InitialOption::InitialOption
InitialOption(QSize size)
Definition: KDDockWidgets.h:115
Qt::Orientation
Orientation
KDDockWidgets::Location_OnLeft
@ Location_OnLeft
Definition: KDDockWidgets.h:47
KDDockWidgets::RestoreOption
RestoreOption
Definition: KDDockWidgets.h:183
KDDockWidgets::InitialOption::InitialOption
InitialOption()=default
KDDockWidgets::FrameOption_NonDockable
@ FrameOption_NonDockable
Definition: KDDockWidgets.h:264
KDDockWidgets::SuggestedGeometryHint_None
@ SuggestedGeometryHint_None
Definition: KDDockWidgets.h:202
KDDockWidgets::Location_OnRight
@ Location_OnRight
Top docking location
Definition: KDDockWidgets.h:49
KDDockWidgets::RestoreOption_None
@ RestoreOption_None
Definition: KDDockWidgets.h:184
KDDockWidgets::InitialOption::hasPreferredLength
bool hasPreferredLength(Qt::Orientation o) const
Definition: KDDockWidgets.h:144
KDDockWidgets::InitialOption::preferredSize
QSize preferredSize
Allows to control the size a dock widget should get when docked.
Definition: KDDockWidgets.h:166
KDDockWidgets::SideBarLocation
SideBarLocation
Each main window supports 4 sidebars.
Definition: KDDockWidgets.h:211
KDDockWidgets::DefaultSizeMode
DefaultSizeMode
Definition: KDDockWidgets.h:70
KDDockWidgets::SideBarLocation::East
@ East
KDDockWidgets::SideBarLocation::South
@ South
KDDockWidgets::TitleBarButtonType::Close
@ Close
KDDockWidgets::SideBarLocation::North
@ North
KDDockWidgets::SuggestedGeometryHint
SuggestedGeometryHint
Definition: KDDockWidgets.h:201
KDDockWidgets::InitialOption::startsHidden
bool startsHidden() const
Definition: KDDockWidgets.h:133
KDDockWidgets::InitialOption::InitialOption
InitialOption(InitialVisibilityOption v)
Definition: KDDockWidgets.h:110
KDDockWidgets::CursorPosition_Right
@ CursorPosition_Right
Definition: KDDockWidgets.h:243
KDDockWidgets::AddingOption_StartHidden
@ AddingOption_StartHidden
Definition: KDDockWidgets.h:83
KDDockWidgets::RestoreOption_RelativeToMainWindow
@ RestoreOption_RelativeToMainWindow
Loading layouts won't change the main window geometry and just use whatever the user has at the momen...
Definition: KDDockWidgets.h:185
KDDockWidgets
Definition: Config.cpp:36
KDDockWidgets::CursorPosition_BottomRight
@ CursorPosition_BottomRight
Definition: KDDockWidgets.h:248
KDDockWidgets::Location_None
@ Location_None
Definition: KDDockWidgets.h:46
KDDockWidgets::FrameOption_IsCentralFrame
@ FrameOption_IsCentralFrame
Definition: KDDockWidgets.h:262
KDDockWidgets::AddingOption
AddingOption
Only here for source-compat with v1.2. Do not use. Use InitialVisibilityOption instead.
Definition: KDDockWidgets.h:81
KDDockWidgets::MainWindowOption
MainWindowOption
Definition: KDDockWidgets.h:55
KDDockWidgets::TitleBarButtonType::Normal
@ Normal
Layouting
Definition: FrameworkWidgetFactory.h:32
operator<<
QT_BEGIN_NAMESPACE QDebug operator<<(QDebug d, KDDockWidgets::InitialOption o)
Definition: KDDockWidgets.h:291
KDDockWidgets::SuggestedGeometryHint_GeometryIsFromDocked
@ SuggestedGeometryHint_GeometryIsFromDocked
Definition: KDDockWidgets.h:204
KDDockWidgets::CursorPosition_BottomLeft
@ CursorPosition_BottomLeft
Definition: KDDockWidgets.h:249
KDDockWidgets::MainWindowOption_HasCentralFrame
@ MainWindowOption_HasCentralFrame
No option set
Definition: KDDockWidgets.h:57
KDDockWidgets::CursorPosition_Top
@ CursorPosition_Top
Definition: KDDockWidgets.h:244
KDDockWidgets::TitleBarButtonType::Float
@ Float

© 2019-2022 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDDockWidgets
Advanced Dock Widget Framework for Qt
https://www.kdab.com/development-resources/qt-tools/kddockwidgets/
Generated on Mon Mar 7 2022 02:01:20 for KDDockWidgets API Documentation by doxygen 1.8.20