KDDockWidgets API Documentation 2.1
Loading...
Searching...
No Matches
DockRegistry.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
12#ifndef KD_DOCKREGISTRY_P_H
13#define KD_DOCKREGISTRY_P_H
14
15#include "kddockwidgets/KDDockWidgets.h"
16#include "kddockwidgets/core/View.h"
17#include "kddockwidgets/QtCompat_p.h"
18#include "kddockwidgets/core/EventFilterInterface.h"
19
20#include <map>
21#include <memory>
22
28namespace KDDockWidgets {
29
30
31namespace Core {
32class FloatingWindow;
33class Layout;
34class SideBar;
35class SideBarGroupings;
36class MainWindow;
37class DockWidget;
38class Group;
39class MainWindowMDIViewInterface;
40class MainWindowViewInterface;
41class FocusScope;
42struct WindowBeingDragged;
43}
44
45class MainWindowMDI;
46
47class DOCKS_EXPORT DockRegistry : public Core::Object, public Core::EventFilterInterface
48{
49 Q_OBJECT
50
51public:
52 enum class DockByNameFlag {
53 None = 0,
54 ConsultRemapping = 1,
55 CreateIfNotFound =
56 2,
57 SilentIfNotFound = 4
58 };
59 Q_DECLARE_FLAGS(DockByNameFlags, DockByNameFlag)
60
61 static DockRegistry *self();
63 void registerDockWidget(Core::DockWidget *);
64 void unregisterDockWidget(Core::DockWidget *);
65
66 void registerMainWindow(Core::MainWindow *);
67 void unregisterMainWindow(Core::MainWindow *);
68
69 void registerFloatingWindow(Core::FloatingWindow *);
70 void unregisterFloatingWindow(Core::FloatingWindow *);
71
72 void registerGroup(Core::Group *);
73 void unregisterGroup(Core::Group *);
74
75 void registerLayoutSaver();
76 void unregisterLayoutSaver();
77
81 Q_INVOKABLE KDDockWidgets::Core::DockWidget *focusedDockWidget() const;
82
83 Q_INVOKABLE bool containsDockWidget(const QString &uniqueName) const;
84 Q_INVOKABLE bool containsMainWindow(const QString &uniqueName) const;
85
87 dockByName(const QString &, KDDockWidgets::DockRegistry::DockByNameFlags = {}) const;
88 Q_INVOKABLE KDDockWidgets::Core::MainWindow *mainWindowByName(const QString &) const;
89
90 bool isSane() const;
91
93 Vector<Core::DockWidget *> dockwidgets() const;
94
96 Vector<Core::DockWidget *> dockWidgets(const Vector<QString> &names);
97
100 Vector<Core::DockWidget *> closedDockwidgets(bool honourSkipped) const;
101
103 Vector<Core::MainWindow *> mainwindows() const;
104
108 Vector<Core::MainWindowViewInterface *> mainDockingAreas() const;
109
111 Vector<Core::MainWindow *> mainWindows(const Vector<QString> &names);
112
114 Vector<Core::Group *> groups() const;
115
118 Vector<Core::FloatingWindow *>
119 floatingWindows(bool includeBeingDeleted = false, bool honourSkipped = false) const;
120
123 Vector<std::shared_ptr<Core::Window>> floatingQWindows() const;
124
126 Q_INVOKABLE bool hasFloatingWindows() const;
127
129 Core::FloatingWindow *
130 floatingWindowForHandle(std::shared_ptr<Core::Window> windowHandle) const;
131
133 Core::FloatingWindow *floatingWindowForHandle(Core::WId hwnd) const;
134
136 Core::MainWindow *mainWindowForHandle(std::shared_ptr<Core::Window> windowHandle) const;
137
149 Vector<std::shared_ptr<Core::Window>> topLevels(bool excludeFloatingDocks = false) const;
150
157 Q_INVOKABLE void clear(const Vector<QString> &affinities = {});
158
162 void clear(const Vector<Core::DockWidget *> &dockWidgets,
163 const Vector<Core::MainWindow *> &mainWindows,
164 const Vector<QString> &affinities);
165
172 void ensureAllFloatingWidgetsAreMorphed();
173
179 bool isEmpty(bool excludeBeingDeleted = false) const;
180
184 Vector<Core::MainWindow *> mainWindowsWithAffinity(const Vector<QString> &affinities) const;
185
187 Core::Layout *layoutForItem(const Core::Item *) const;
188
191 bool itemIsInMainWindow(const Core::Item *) const;
192
193 bool affinitiesMatch(const Vector<QString> &affinities1, const Vector<QString> &affinities2) const;
194
196 Vector<QString> mainWindowsNames() const;
197
199 Vector<QString> dockWidgetNames() const;
200
206 bool isProbablyObscured(std::shared_ptr<Core::Window> target,
207 Core::FloatingWindow *exclude) const;
208
210 bool isProbablyObscured(std::shared_ptr<Core::Window> target, Core::WindowBeingDragged *exclude) const;
211
215 SideBarLocation sideBarLocationForDockWidget(const Core::DockWidget *) const;
216
218 Core::SideBar *sideBarForDockWidget(const Core::DockWidget *) const;
219
221 Core::Group *groupInMDIResize() const;
222
223 void setCurrentCloseReason(CloseReason);
224 CloseReason currentCloseReason();
225
226 class Private;
227 Private *dptr() const;
228
229private:
230 friend class Core::FocusScope;
231 friend class Core::TitleBar;
232
233 explicit DockRegistry(Core::Object *parent = nullptr);
234 bool onDockWidgetPressed(Core::DockWidget *dw, MouseEvent *);
235 void onFocusedViewChanged(std::shared_ptr<Core::View> view);
236 void maybeDelete();
237 void setFocusedDockWidget(Core::DockWidget *);
238
239 // EventFilterInterface:
240 bool onExposeEvent(std::shared_ptr<Core::Window>) override;
241 bool onMouseButtonPress(Core::View *, MouseEvent *) override;
242
243 // To honour Config::Flag_AutoHideAsTabGroups:
244 void addSideBarGrouping(const Vector<Core::DockWidget *> &);
245 void removeSideBarGrouping(const Vector<Core::DockWidget *> &);
246 Vector<Core::DockWidget *> sideBarGroupingFor(Core::DockWidget *) const;
247
248 Private *const d;
249
250 Vector<Core::DockWidget *> m_dockWidgets;
251 Vector<Core::MainWindow *> m_mainWindows;
252 Vector<Core::Group *> m_groups;
253 Vector<Core::FloatingWindow *> m_floatingWindows;
254
261 mutable std::map<QString, QString> m_dockWidgetIdRemapping;
262
263 // To honour Config::Flag_AutoHideAsTabGroups
264 Core::SideBarGroupings *const m_sideBarGroupings;
265};
266
268{
271
272private:
274 CloseReasonSetter &operator=(CloseReason &) = delete;
275};
276
277}
278
279#endif
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
The widget (QWidget or QQuickItem) which holds a layout of dock widgets.
Definition Layout.h:57
The MainWindow base-class. MainWindow and MainWindowBase are only split in two so we can share some c...
Core::FloatingWindow * floatingWindowForHandle(std::shared_ptr< Core::Window > windowHandle) const
returns the FloatingWindow with handle windowHandle
void clear(const Vector< Core::DockWidget * > &dockWidgets, const Vector< Core::MainWindow * > &mainWindows, const Vector< QString > &affinities)
clear Overload that only clears the specified dockWidgets and main windows.
bool isProbablyObscured(std::shared_ptr< Core::Window > target, Core::FloatingWindow *exclude) const
returns if the specified window has some other window on top (with higher Z) This is an approximation...
bool isProbablyObscured(std::shared_ptr< Core::Window > target, Core::WindowBeingDragged *exclude) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Class to abstract QAction, so code still works with QtQuick and Flutter.
SideBarLocation
Each main window supports 4 sidebars.

© 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