KDDockWidgets API Documentation 2.0
Loading...
Searching...
No Matches
KDDockWidgets.h
Go to the documentation of this file.
1/*
2 This file is part of KDDockWidgets.
3
4 SPDX-FileCopyrightText: 2019 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 "kddockwidgets/docks_export.h"
23
24#include "QtCompat_p.h"
25
26#ifdef KDDW_FRONTEND_QT
27#include "Qt5Qt6Compat_p.h"
28
29#ifdef Q_OS_WIN
30// Only on Windows, where this is popular. On linux the Qt::Tool windows need reparenting.
31// Untested on macOS.
32#define KDDOCKWIDGETS_SUPPORTS_NESTED_MAINWINDOWS
33#define KDDW_FRONTEND_QT_WINDOWS
34#endif
35
36#ifdef KDDW_FRONTEND_QTWIDGETS
37#include <QWidget>
38#endif
39
40#endif
41
42namespace KDDockWidgets::QtQuick {
43}
45}
48namespace KDDockWidgets::Flutter {
49}
50
51namespace KDDockWidgets {
52QT_DOCKS_EXPORT
53Q_NAMESPACE
54
55namespace QtWidgets {
56class DockWidget;
57}
58
59namespace Core {
60class Item;
61class ItemBoxContainer;
62}
63
71Q_ENUM_NS(Location)
72
84Q_DECLARE_FLAGS(MainWindowOptions, MainWindowOption)
85Q_ENUM_NS(MainWindowOptions)
86
87
101Q_DECLARE_FLAGS(DockWidgetOptions, DockWidgetOption)
102Q_ENUM_NS(DockWidgetOptions)
103
104
106 None = 0,
107 Skip = 1,
109};
110Q_DECLARE_FLAGS(LayoutSaverOptions, LayoutSaverOption)
111
112enum class IconPlace {
113 TitleBar = 1,
114 TabBar = 2,
115 ToggleAction = 4,
117};
118Q_ENUM_NS(IconPlace)
119Q_DECLARE_FLAGS(IconPlaces, IconPlace)
120
121enum class FrontendType {
122 QtWidgets = 1,
123 QtQuick,
124 Flutter,
125};
126Q_ENUM_NS(FrontendType)
127
128
132enum class DefaultSizeMode {
133 ItemSize,
135 Fair,
139};
140Q_ENUM_NS(DefaultSizeMode)
141
142
148Q_ENUM_NS(AddingOption)
149
156
157
168{
169 // Implicit ctors for convenience:
170
171 InitialOption() = default;
172
174 : visibility(v)
175 {
176 }
177
178 InitialOption(Size size)
179 : preferredSize(size)
180 {
181 }
182
184 : visibility(v)
185 , preferredSize(size)
186 {
187 }
188
189 bool startsHidden() const
190 {
191 return visibility == InitialVisibilityOption::StartHidden;
192 }
193
195 {
197 }
198
200 {
201 return o == Qt::Horizontal ? preferredSize.width() : preferredSize.height();
202 }
203
205 {
206 return preferredLength(o) > 0;
207 }
208
216
227
230 : sizeMode(mode)
231 {
232 }
233
234private:
235 friend class Core::Item;
236 friend class Core::ItemBoxContainer;
237
239};
240
249Q_DECLARE_FLAGS(RestoreOptions, RestoreOption)
250Q_ENUM_NS(RestoreOptions)
251
253 Classic,
254 Segmented,
255 None
256};
257Q_ENUM_NS(DropIndicatorType)
258
259
265Q_DECLARE_FLAGS(SuggestedGeometryHints, SuggestedGeometryHint)
266Q_ENUM_NS(SuggestedGeometryHint)
267
268
269enum class SideBarLocation {
270 None = 0,
271 North,
272 East,
273 West,
274 South,
275 Last
276};
277
280 Close,
281 Float,
282 Minimize,
283 Maximize,
284 Normal, // Restore from maximized state
285 AutoHide,
287};
288Q_ENUM_NS(TitleBarButtonType)
289
290
311Q_ENUM_NS(DropLocation)
312
313
329Q_DECLARE_FLAGS(CursorPositions, CursorPosition)
330Q_ENUM_NS(CursorPosition)
331
332
333
341Q_DECLARE_FLAGS(FrameOptions, FrameOption)
342Q_ENUM_NS(FrameOptions)
343
344
349Q_DECLARE_FLAGS(StackOptions, StackOption)
350Q_ENUM_NS(StackOptions)
351
352
354 None = 0,
355 FromGlobalConfig = 1, // KDDockWidgets::Config is used instead
359 NativeTitleBar = 16,
363 UseQtWindow = 256,
364 UseQtTool = 512
365};
366Q_DECLARE_FLAGS(FloatingWindowFlags, FloatingWindowFlag)
367
368
369enum class WindowState {
370 None = 0,
371 Minimized = 1,
372 Maximized = 2,
373 FullScreen = 4
374};
375Q_DECLARE_FLAGS(WindowStates, WindowState)
376
377
378
382void DOCKS_EXPORT initFrontend(FrontendType);
383
386DOCKS_EXPORT const char *spdlogLoggerName();
387
388#ifdef KDDW_FRONTEND_QTWIDGETS
389
393template<typename T>
394inline T *findAncestor(QWidget *widget)
395{
396 QWidget *p = widget;
397 while (p) {
398 if (auto w = qobject_cast<T *>(p))
399 return w;
400
401 if (p->isWindow()) {
402 // No need to check across window boundaries.
403 // Main window is parent of floating windows.
404 return nullptr;
405 }
406
407 p = p->parentWidget();
408 }
409
410 return nullptr;
411}
412#endif
413
414template<typename T>
415T bound(T minVal, T value, T maxVal)
416{
417 return std::max(minVal, std::min(value, maxVal));
418}
419
420inline bool fuzzyCompare(double a, double b, double epsilon = 0.0001)
421{
422 return std::abs(a - b) < epsilon;
423}
424
425} // end namespace
426
427Q_DECLARE_OPERATORS_FOR_FLAGS(KDDockWidgets::FrameOptions)
429Q_DECLARE_METATYPE(KDDockWidgets::Location)
430
431#define KDDW_DELETE_COPY_CTOR(NAME) \
432 NAME(const NAME &) = delete; \
433 NAME(const NAME &&) = delete; \
434 NAME &operator=(const NAME &) = delete; \
435 NAME &operator=(const NAME &&) = delete;
436
437#define KDDW_UNUSED(name) (( void )name);
438
439
440#endif
Class to abstract QAction, so code still works with QtQuick and Flutter.
@ MainWindowOption_MDI
‍Makes the MainWindow always have a central group, for tabbing documents
@ MainWindowOption_HasCentralWidget
@ MainWindowOption_HasCentralFrame
‍No option set
@ Location_OnTop
‍Left docking location
@ Location_OnRight
‍Top docking location
@ Location_OnBottom
‍Right docking location
@ RestoreOption_RelativeToMainWindow
@ RestoreOption_AbsoluteFloatingDockWindows
Skips scaling of floating dock windows relative to the main window.
@ SuggestedGeometryHint_PreserveCenter
@ SuggestedGeometryHint_GeometryIsFromDocked
bool fuzzyCompare(double a, double b, double epsilon=0.0001)
SideBarLocation
Each main window supports 4 sidebars.
AddingOption
Only here for source-compat with v1.2. Do not use. Use InitialVisibilityOption instead.
DockWidgetOption
DockWidget options to pass at construction time.
@ DockWidgetOption_MDINestable
@ DockWidgetOption_None
No option, the default.
@ DockWidgetOption_NotClosable
The DockWidget can't be closed on the [x], only programmatically.
@ DockWidgetOption_DeleteOnClose
Deletes the DockWidget when closed.
@ DockWidgetOption_NotDockable
The DockWidget can't be docked, it's always floating.
TitleBarButtonType
describes a type of button you can have in the title bar
LayoutSaverOption
Options which will affect LayoutSaver save/restore.
@ None
Just use the defaults.
@ Segmented
Segmented indicators.
T bound(T minVal, T value, T maxVal)
DropLocation
Enum describing the different drop indicator types.
void DOCKS_EXPORT initFrontend(FrontendType)
Initializes the desired frontend This function should be called before using any docking....
@ StartHidden
Don't show the dock widget when adding it.
@ PreserveCurrentTab
When adding as tabbed, don't change the current index.
@ StartVisible
The dock widget is made visible when docked.
DOCKS_EXPORT const char * spdlogLoggerName()
@ NoDefaultSizeMode
Don't do any sizing.
@ Fair
Gives an equal relative size as the items that are already in the layout.
Orientation
bool isWindow() const const
QWidget * parentWidget() const const
Struct describing the preferred dock widget size and visibility when adding it to a layout.
int preferredLength(Qt::Orientation o) const
bool hasPreferredLength(Qt::Orientation o) const
InitialOption(InitialVisibilityOption v)
Size preferredSize
Allows to control the size a dock widget should get when docked.
InitialOption(DefaultSizeMode mode)
InitialOption(InitialVisibilityOption v, Size size)

© 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 by doxygen 1.9.8