KDDockWidgets API Documentation 2.1
Loading...
Searching...
No Matches
core/Group.h
Go to the documentation of this file.
1/*
2 This file is part of KDDockWidgets.
3
4 SPDX-FileCopyrightText: 2020 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
12#pragma once
13
14#include "DockWidget.h"
15#include "kddockwidgets/KDDockWidgets.h"
16#include "kddockwidgets/LayoutSaver.h"
17#include "kddockwidgets/QtCompat_p.h"
18#include "kddockwidgets/core/Controller.h"
19#include "kddockwidgets/core/FocusScope.h"
20#include "kddockwidgets/docks_export.h"
21
22class TestDocks;
23
24namespace KDDockWidgets {
25class WidgetResizeHandler;
26}
27
28namespace KDDockWidgets::Core {
29
30class LayoutingGuest;
31class DropArea;
32class MDILayout;
33class DockWidget;
34class FloatingWindow;
35class MainWindow;
36class Stack;
37class TabBar;
38class TitleBar;
39
40class DOCKS_EXPORT Group : public Controller, public FocusScope
41{
42 Q_OBJECT
43public:
45
46 explicit Group(View *parent = nullptr, FrameOptions = FrameOption_None,
47 int userType = 0);
48 virtual ~Group() override;
49
50 static Group *deserialize(const LayoutSaver::Group &);
51 LayoutSaver::Group serialize() const;
52
54 void addTab(DockWidget *, const InitialOption & = {});
56 void addTab(Group *, const InitialOption & = {});
58 void addTab(FloatingWindow *floatingWindow, const InitialOption & = {});
59
61 void insertWidget(DockWidget *, int index, const InitialOption & = {});
62
64 void removeWidget(DockWidget *);
65
67 FloatingWindow *detachTab(DockWidget *);
68
70 int indexOfDockWidget(const DockWidget *);
71
73 int currentIndex() const;
74
76 void setCurrentTabIndex(int index);
77
79 void setCurrentDockWidget(DockWidget *);
80
82 void insertDockWidget(DockWidget *, int index);
83
85 DockWidget *dockWidgetAt(int index) const;
86
88 DockWidget *currentDockWidget() const;
89
91 int dockWidgetCount() const;
92
94 Core::Stack *stack() const;
95 Core::TabBar *tabBar() const;
96
97 void updateTitleAndIcon();
98 void onDockWidgetTitleChanged(DockWidget *);
99 void updateTitleBarVisibility();
100 void updateFloatingActions();
101 bool containsMouse(Point globalPos) const;
102 Core::TitleBar *titleBar() const;
103 Core::TitleBar *actualTitleBar() const;
104 QString title() const;
105 Icon icon() const;
106 Vector<DockWidget *> dockWidgets() const;
107
108 bool isTheOnlyGroup() const;
109
111 bool isOverlayed() const;
112
115 void unoverlay();
116
124 bool isFloating() const;
125
131 bool isInFloatingWindow() const;
132
136 bool isInMainWindow() const;
137
145 bool isCentralGroup() const;
146
148 bool isDockable() const;
149
160 bool alwaysShowsTabs() const;
161
163 bool containsDockWidget(DockWidget *w) const;
164
166 FloatingWindow *floatingWindow() const;
167
172 MainWindow *mainWindow() const;
173
181 void restoreToPreviousPosition();
182
183 int currentTabIndex() const;
184 FrameOptions options() const;
185 bool anyNonClosable() const;
186 bool anyNonDockable() const;
187
190 bool isEmpty() const
191 {
192 return dockWidgetCount() == 0;
193 }
194
197 {
198 return dockWidgetCount() == 1;
199 }
200
203 Core::Item *layoutItem() const;
204
206 static int dbg_numFrames();
207
211 bool beingDeletedLater() const;
212
218 bool hasTabsVisible() const;
219
220 Vector<QString> affinities() const;
221
223 void setLayoutItem(Core::Item *item);
224
230 virtual Rect dragRect() const;
231
233 bool allDockWidgetsHave(DockWidgetOption) const;
234
236 bool anyDockWidgetsHas(DockWidgetOption) const;
237
239 bool allDockWidgetsHave(LayoutSaverOption) const;
240
242 bool anyDockWidgetsHas(LayoutSaverOption) const;
243
245 void setAllowedResizeSides(CursorPositions sides);
246
249 bool isMDI() const;
250
253 bool isMDIWrapper() const;
254
257 DockWidget *mdiDockWidgetWrapper() const;
258
261 DropArea *mdiDropAreaWrapper() const;
262
265 Group *mdiFrame() const;
266
268 MDILayout *mdiLayout() const;
269
273 bool hasNestedMDIDockWidgets() const;
274
276 int userType() const;
277
279 WidgetResizeHandler *resizeHandler() const;
280
281 void renameTab(int index, const QString &);
282 void changeTabIcon(int index, const Icon &);
284 void setLayout(Layout *);
285
286 void onDockWidgetCountChanged();
287
289 FloatingWindowFlags requestedFloatingWindowFlags() const;
290
291 LayoutingGuest *asLayoutingGuest() const;
292
294 static Core::Group *fromItem(const Core::Item *);
295
296 static bool s_inFloatHack;
297
298protected:
299 void isFocusedChangedCallback() override;
300 void focusedWidgetChangedCallback() override;
301 void setParentView_impl(View *parent) override;
302
303public:
309 Size dockWidgetsMinSize() const;
310
323 Size biggestDockWidgetMaxSize() const;
324 int nonContentsHeight() const;
325
326 class Private;
327 Private *dptr() const;
328
329private:
330 Private *const d;
331 bool m_inCtor = true; // Needs to be initialized early, as pointed out by UBSAN
332protected:
333 bool m_inDtor = false;
334
338
339#ifdef DOCKS_DEVELOPER_MODE
340public:
341#else
342private:
343#endif
345 friend class ::TestDocks;
346 friend class KDDockWidgets::Core::Stack;
347
348 void scheduleDeleteLater();
349 void createMDIResizeHandler();
350 void onCloseEvent(CloseEvent *);
351
352 Layout *m_layout = nullptr;
353 WidgetResizeHandler *m_resizeHandler = nullptr;
354 bool m_updatingTitleBar = false;
355 bool m_beingDeleted = false;
356};
357
358}
#define KDDW_DELETE_COPY_CTOR(NAME)
The DockWidget base-class. DockWidget and Core::DockWidget are only split in two so we can share some...
Allows to implement a similar functionality to QtQuick's FocusScope item, in QtWidgets.
Definition FocusScope.h:31
Core::TabBar *const m_tabBar
Definition core/Group.h:336
bool hasSingleDockWidget() const
returns whether there's only 1 dock widget.
Definition core/Group.h:196
bool isEmpty() const
returns whether there's 0 dock widgets. If not persistent then the Frame will delete itself.
Definition core/Group.h:190
Vector< Group * > List
Definition core/Group.h:44
Core::Stack *const m_stack
Definition core/Group.h:335
Core::TitleBar *const m_titleBar
Definition core/Group.h:337
The widget (QWidget or QQuickItem) which holds a layout of dock widgets.
Definition Layout.h:57
The MDILayout class implements a layout suitable for MDI style docking. Where dock widgets are free t...
Class to abstract QAction, so code still works with QtQuick and Flutter.
DockWidgetOption
DockWidget options to pass at construction time.
LayoutSaverOption
Options which will affect LayoutSaver save/restore.
Represents a dock widget.
Struct describing the preferred dock widget size and visibility when adding it to a layout.

© 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