KDDockWidgets API Documentation 2.1
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#define KDDW_FRONTEND_QT_WINDOWS
31#endif
32
33#ifdef KDDW_FRONTEND_QTWIDGETS
34#include <QWidget>
35#endif
36
37#endif
38
39namespace KDDockWidgets::QtQuick {
40}
42}
45namespace KDDockWidgets::Flutter {
46}
47
48namespace KDDockWidgets {
49QT_DOCKS_EXPORT
50Q_NAMESPACE
51
52namespace QtWidgets {
53class DockWidget;
54}
55
56namespace Core {
57class Item;
58class ItemBoxContainer;
59}
60
68Q_ENUM_NS(Location)
69
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,
110};
111Q_DECLARE_FLAGS(LayoutSaverOptions, LayoutSaverOption)
112
113enum class IconPlace {
114 TitleBar = 1,
115 TabBar = 2,
116 ToggleAction = 4,
118};
119Q_ENUM_NS(IconPlace)
120Q_DECLARE_FLAGS(IconPlaces, IconPlace)
121
122enum class FrontendType {
123 QtWidgets = 1,
124 QtQuick,
125 Flutter,
126};
127Q_ENUM_NS(FrontendType)
128
129
133enum class DefaultSizeMode {
134 ItemSize,
136 Fair,
140};
141Q_ENUM_NS(DefaultSizeMode)
142
143
149Q_ENUM_NS(AddingOption)
150
157
164
165
175struct DOCKS_EXPORT InitialOption
176{
177 // Implicit ctors for convenience:
178
181 InitialOption(Size size);
183
184 bool startsHidden() const
185 {
186 return visibility == InitialVisibilityOption::StartHidden;
187 }
188
190 {
192 }
193
196 {
197 return o == Qt::Horizontal ? preferredSize.width() : preferredSize.height();
198 }
199
201 {
202 return preferredLength(o) > 0;
203 }
204
212
223
225 NeighbourSqueezeStrategy neighbourSqueezeStrategy = s_defaultNeighbourSqueezeStrategy;
226
229
230private:
231 friend class Core::Item;
232 friend class Core::ItemBoxContainer;
233
235};
236
245Q_DECLARE_FLAGS(RestoreOptions, RestoreOption)
246Q_ENUM_NS(RestoreOptions)
247
249 Classic,
250 Segmented,
251 None
252};
253Q_ENUM_NS(DropIndicatorType)
254
255
261Q_DECLARE_FLAGS(SuggestedGeometryHints, SuggestedGeometryHint)
262Q_ENUM_NS(SuggestedGeometryHint)
263
264
265enum class SideBarLocation {
266 None = 0,
267 North,
268 East,
269 West,
270 South,
271 Last
272};
273
276 Close = 1,
277 Float = 2,
278 Minimize = 4,
279 Maximize = 8,
280 Normal = 16, // Restore from maximized state
281 AutoHide = 32,
282 UnautoHide = 64,
284};
285Q_ENUM_NS(TitleBarButtonType)
286Q_DECLARE_FLAGS(TitleBarButtonTypes, TitleBarButtonType)
287
288
309Q_ENUM_NS(DropLocation)
310
311
327Q_DECLARE_FLAGS(CursorPositions, CursorPosition)
328Q_ENUM_NS(CursorPosition)
329
330
331
339Q_DECLARE_FLAGS(FrameOptions, FrameOption)
340Q_ENUM_NS(FrameOptions)
341
342
347Q_DECLARE_FLAGS(StackOptions, StackOption)
348Q_ENUM_NS(StackOptions)
349
350
352 None = 0,
353 FromGlobalConfig = 1, // KDDockWidgets::Config is used instead
357 NativeTitleBar = 16,
361 UseQtWindow = 256,
362 UseQtTool = 512,
363 StartsMinimized = 1024
364};
365Q_DECLARE_FLAGS(FloatingWindowFlags, FloatingWindowFlag)
366
367
368enum class WindowState {
369 None = 0,
370 Minimized = 1,
371 Maximized = 2,
372 FullScreen = 4
373};
374Q_DECLARE_FLAGS(WindowStates, WindowState)
375
376
377enum class CloseReason {
378 Unspecified = 0,
380 Action = 2,
381 MovedToSideBar = 4,
382 OverlayCollapse = 8
383};
384
389void DOCKS_EXPORT initFrontend(FrontendType);
390
393DOCKS_EXPORT const char *spdlogLoggerName();
394
395#ifdef KDDW_FRONTEND_QTWIDGETS
396
400template<typename T>
401inline T *findAncestor(QWidget *widget)
402{
403 QWidget *p = widget;
404 while (p) {
405 if (auto w = qobject_cast<T *>(p))
406 return w;
407
408 if (p->isWindow()) {
409 // No need to check across window boundaries.
410 // Main window is parent of floating windows.
411 return nullptr;
412 }
413
414 p = p->parentWidget();
415 }
416
417 return nullptr;
418}
419#endif
420
421template<typename T>
422T bound(T minVal, T value, T maxVal)
423{
424 return std::max(minVal, std::min(value, maxVal));
425}
426
427inline bool fuzzyCompare(double a, double b, double epsilon = 0.0001)
428{
429 return std::abs(a - b) < epsilon;
430}
431
432} // end namespace
433
434Q_DECLARE_OPERATORS_FOR_FLAGS(KDDockWidgets::FrameOptions)
436Q_DECLARE_METATYPE(KDDockWidgets::Location)
437
438#define KDDW_DELETE_COPY_CTOR(NAME) \
439 NAME(const NAME &) = delete; \
440 NAME(const NAME &&) = delete; \
441 NAME &operator=(const NAME &) = delete; \
442 NAME &operator=(const NAME &&) = delete;
443
444#define KDDW_UNUSED(name) (( void )name);
445
446
447#endif
Class to abstract QAction, so code still works with QtQuick and Flutter.
@ MainWindowOption_ManualInit
@ MainWindowOption_MDI
‍Makes the MainWindow always have a central group, for tabbing documents
@ MainWindowOption_QDockWidgets
@ 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
@ Action
User clicked titlebar close button.
@ OverlayCollapse
User clicked the pin-button (or programmatically) (auto-hide/sidebar/pin-unpin functionality)
@ MovedToSideBar
User clicked menu with QAction.
@ TitleBarCloseButton
probably programmatically
LayoutSaverOption
Options which will affect LayoutSaver save/restore.
@ None
Just use the defaults.
@ Skip
The dock widget won't participate in save/restore.
@ CheckForPreviousRestore
before, and try to recover its previous main window position
@ AllNeighbours
The squeeze is spread between all neighbours, not just immediate ones first.
@ 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
Returns preferred height if the container is vertical, otherwise preferred width.
bool hasPreferredLength(Qt::Orientation o) const
Size preferredSize
Allows to control the size a dock widget should get when docked.
static NeighbourSqueezeStrategy s_defaultNeighbourSqueezeStrategy

© 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