KDDockWidgets API Documentation 2.0
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 *, InitialOption = {});
56 void addTab(Group *, InitialOption = {});
58 void addTab(FloatingWindow *floatingWindow, InitialOption = {});
59
61 void insertWidget(DockWidget *, int index, 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 isCentralFrame() 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
246 void setAllowedResizeSides(CursorPositions sides);
247
250 bool isMDI() const;
251
254 bool isMDIWrapper() const;
255
258 DockWidget *mdiDockWidgetWrapper() const;
259
262 DropArea *mdiDropAreaWrapper() const;
263
266 Group *mdiFrame() const;
267
269 MDILayout *mdiLayout() const;
270
274 bool hasNestedMDIDockWidgets() const;
275
277 int userType() const;
278
280 WidgetResizeHandler *resizeHandler() const;
281
282 void renameTab(int index, const QString &);
283 void changeTabIcon(int index, const Icon &);
285 void setLayout(Layout *);
286
287 void onDockWidgetCountChanged();
288
290 FloatingWindowFlags requestedFloatingWindowFlags() const;
291
292 LayoutingGuest *asLayoutingGuest() const;
293
295 static Core::Group *fromItem(const Core::Item *);
296
297protected:
298 void isFocusedChangedCallback() override;
299 void focusedWidgetChangedCallback() override;
300 void setParentView_impl(View *parent) override;
301
302public:
308 Size dockWidgetsMinSize() const;
309
322 Size biggestDockWidgetMaxSize() const;
323 int nonContentsHeight() const;
324
325 class Private;
326 Private *dptr() const;
327
328private:
329 Private *const d;
330 bool m_inCtor = true; // Needs to be initialized early, as pointed out by UBSAN
331protected:
332 bool m_inDtor = false;
333
337
338private:
340 friend class ::TestDocks;
341 friend class KDDockWidgets::Core::Stack;
342
343 void scheduleDeleteLater();
344 void onCloseEvent(CloseEvent *);
345
346 Layout *m_layout = nullptr;
347 WidgetResizeHandler *m_resizeHandler = nullptr;
348 bool m_updatingTitleBar = false;
349 bool m_beingDeleted = false;
350};
351
352}
#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:335
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:334
Core::TitleBar *const m_titleBar
Definition core/Group.h:336
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