KDDockWidgets API Documentation 2.0
Loading...
Searching...
No Matches
DockRegistry.cpp
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#include "DockRegistry.h"
13#include "DockRegistry_p.h"
14#include "DelayedCall_p.h"
15#include "Config.h"
16#include "core/Logging_p.h"
17#include "core/Position_p.h"
18#include "core/Utils_p.h"
19#include "core/Platform_p.h"
20#include "core/WidgetResizeHandler_p.h"
21#include "core/WindowBeingDragged_p.h"
22#include "core/layouting/Item_p.h"
23#include "core/layouting/LayoutingHost_p.h"
24#include "core/DockWidget_p.h"
25#include "core/ObjectGuard_p.h"
27#include "core/FloatingWindow.h"
28#include "core/SideBar.h"
29#include "core/MainWindow.h"
30#include "core/DockWidget.h"
31#include "core/DropArea.h"
32#include "core/Platform.h"
33#include "core/Window_p.h"
34
35#include "kdbindings/signal.h"
36
37#include <set>
38#include <utility>
39
40using namespace KDDockWidgets;
41using namespace KDDockWidgets::Core;
42
43namespace KDDockWidgets::Core {
44
45// Helper class to help implement Config::Flag_AutoHideAsTabGroups
46class SideBarGroupings
47{
48public:
49 void addGrouping(const DockWidget::List &);
50 void removeGrouping(const DockWidget::List &);
51 DockWidget::List groupingFor(DockWidget *) const;
52 void removeFromGroupings(DockWidget *);
53
54private:
55 DockWidget::List &groupingByRef(DockWidget *);
56 Vector<DockWidget::List> m_groupings;
57};
58
59}
60
61DockRegistry::DockRegistry(Core::Object *parent)
62 : Core::Object(parent)
63 , d(new Private())
64 , m_sideBarGroupings(new SideBarGroupings())
65{
67
68 d->m_connection = Platform::instance()->d->focusedViewChanged.connect(
69 &DockRegistry::onFocusedViewChanged, this);
70}
71
73{
74 delete m_sideBarGroupings;
76 d->m_connection.disconnect();
77 delete d;
78}
79
80void DockRegistry::maybeDelete()
81{
82 // We delete the singleton just to make LSAN happy.
83 // We could also simply ask the user do call something like KDDockWidgets::deinit() in the future,
84 // Also, please don't change this to be deleted at static dtor time with Q_GLOBAL_STATIC.
85 if (isEmpty() && d->m_numLayoutSavers == 0)
86 delete this;
87}
88
89void DockRegistry::onFocusedViewChanged(std::shared_ptr<View> view)
90{
91 auto p = view;
92 while (p && !p->isNull()) {
93 if (auto group = p->asGroupController()) {
94 // Special case: The focused widget is inside the group but not inside the dockwidget.
95 // For example, it's a line edit in the QTabBar. We still need to send the signal for
96 // the current dw in the tab group
97 if (auto dw = group->currentDockWidget()) {
98 setFocusedDockWidget(dw);
99 }
100
101 return;
102 }
103
104 if (auto dw = p->asDockWidgetController()) {
105 DockRegistry::self()->setFocusedDockWidget(dw);
106 return;
107 }
108 p = p->parentView();
109 }
110
111 setFocusedDockWidget(nullptr);
112}
113
114void DockRegistry::setFocusedDockWidget(Core::DockWidget *dw)
115{
116 if (d->m_focusedDockWidget.data() == dw)
117 return;
118
119 if (d->m_focusedDockWidget) {
120 // Emit DockWidget::isFocusedChanged(). Needs to be delayed,
121 // as the FocusScope hasn't been updated yet.
122 // It's just for styling purposes, so can be delayed
123 Platform::instance()->runDelayed(0, new DelayedEmitFocusChanged(d->m_focusedDockWidget, false));
124 }
125
126 d->m_focusedDockWidget = dw;
127
128 if (dw) {
129 // Emit DockWidget::isFocusedChanged(). Needs to be delayed,
130 // as the FocusScope hasn't been updated yet.
131 // It's just for styling purposes, so can be delayed
132 Platform::instance()->runDelayed(0, new DelayedEmitFocusChanged(d->m_focusedDockWidget, true));
133 }
134}
135
136bool DockRegistry::isEmpty(bool excludeBeingDeleted) const
137{
138 if (!m_dockWidgets.isEmpty() || !m_mainWindows.isEmpty())
139 return false;
140
141 return excludeBeingDeleted ? !hasFloatingWindows() : m_floatingWindows.isEmpty();
142}
143
144void DockRegistry::checkSanityAll(bool dumpLayout)
145{
146 for (auto layout : std::as_const(m_layouts)) {
147 layout->checkSanity();
148 if (dumpLayout)
149 layout->dumpLayout();
150 }
151}
152
154 const Vector<QString> &affinities2) const
155{
156 if (affinities1.isEmpty() && affinities2.isEmpty())
157 return true;
158
159 for (const QString &a1 : affinities1) {
160 for (const QString &a2 : affinities2) {
161 if (a1 == a2)
162 return true;
163 }
164 }
165
166 return false;
167}
168
170{
171 Vector<QString> names;
172 names.reserve(m_mainWindows.size());
173 for (auto mw : m_mainWindows)
174 names.push_back(mw->uniqueName());
175
176 return names;
177}
178
180{
181 Vector<QString> names;
182 names.reserve(m_dockWidgets.size());
183 for (auto dw : m_dockWidgets)
184 names.push_back(dw->uniqueName());
185
186 return names;
187}
188
189bool DockRegistry::isProbablyObscured(Core::Window::Ptr window,
190 Core::FloatingWindow *exclude) const
191{
192 if (!window)
193 return false;
194
195 const Rect geo = window->geometry();
196 for (Core::FloatingWindow *fw : m_floatingWindows) {
197 Window::Ptr fwWindow = fw->view()->window();
198 if (fw == exclude || fwWindow->equals(window))
199 continue;
200
201 if (fwWindow->geometry().intersects(geo)) {
202 // fw might be below, but we don't have a way to check. So be conservative and return
203 // true.
204 return true;
205 }
206 }
207
208 // Floating windows are Tool (keep above), unless we disabled it in Config
209 auto fw = floatingWindowForHandle(window);
210 const bool targetIsToolWindow =
211 fw && fw->isUtilityWindow();
212
213 for (Core::MainWindow *mw : m_mainWindows) {
214 Window::Ptr mwWindow = mw->view()->window();
215
216 if (mwWindow && !mwWindow->equals(window) && !targetIsToolWindow
217 && mwWindow->geometry().intersects(geo)) {
218 // Two main windows that intersect. Return true. If the target is a tool window it will
219 // be above, so we don't care.
220 return true;
221 }
222 }
223
224 return false;
225}
226
227bool DockRegistry::isProbablyObscured(Core::Window::Ptr target, WindowBeingDragged *exclude) const
228{
230 exclude ? exclude->floatingWindow() : nullptr; // It's null on Wayland. On wayland obscuring
231 // never happens anyway, so not a problem.
232
233 return isProbablyObscured(target, fw);
234}
235
237{
239 return sb->location();
240
242}
243
245{
246 for (auto mw : m_mainWindows) {
247 if (Core::SideBar *sb = mw->sideBarForDockWidget(dw))
248 return sb;
249 }
250
251 return nullptr;
252}
253
255{
256 for (auto mw : m_mainWindows) {
257 if (!mw->isMDI())
258 continue;
259
260 Layout *layout = mw->layout();
261 const Vector<Core::Group *> groups = layout->groups();
262 for (Core::Group *group : groups) {
263 if (WidgetResizeHandler *wrh = group->resizeHandler()) {
264 if (wrh->isResizing())
265 return group;
266 }
267 }
268 }
269
270 return nullptr;
271}
272
273DockRegistry::Private *DockRegistry::dptr() const
274{
275 return d;
276}
277
280{
282 result.reserve(m_mainWindows.size());
283
284 for (auto mw : m_mainWindows) {
285 const Vector<QString> mwAffinities = mw->affinities();
286 if (affinitiesMatch(mwAffinities, affinities))
287 result.push_back(mw);
288 }
289
290 return result;
291}
292
294{
295 return Layout::fromLayoutingHost(item->host());
296}
297
298bool DockRegistry::itemIsInMainWindow(const Item *item) const
299{
300 if (Core::Layout *layout = layoutForItem(item)) {
301 return layout->isInMainWindow(/*honourNesting=*/true);
302 }
303
304 return false;
305}
306
308{
309 static ObjectGuard<DockRegistry> s_dockRegistry;
310
311 if (!s_dockRegistry) {
312 s_dockRegistry = new DockRegistry();
313 }
314
315 return s_dockRegistry;
316}
317
319{
320 if (dock->uniqueName().isEmpty()) {
321 KDDW_ERROR("DockWidget doesn't have an ID");
322 } else if (auto other = dockByName(dock->uniqueName())) {
323 KDDW_ERROR("Another DockWidget {} with name {} already exists.", ( void * )other, dock->uniqueName(), ( void * )dock);
324 }
325
326 m_dockWidgets.push_back(dock);
327}
328
330{
331 if (d->m_focusedDockWidget == dock)
332 d->m_focusedDockWidget = nullptr;
333
334 m_dockWidgets.removeOne(dock);
335 m_sideBarGroupings->removeFromGroupings(dock);
336
337 maybeDelete();
338}
339
341{
342 if (mainWindow->uniqueName().isEmpty()) {
343 KDDW_ERROR("MainWindow doesn't have an ID");
344 } else if (auto other = mainWindowByName(mainWindow->uniqueName())) {
345 KDDW_ERROR("Another MainWindow {} with name {} already exists {}", ( void * )other, mainWindow->uniqueName(), ( void * )mainWindow);
346 }
347
348 m_mainWindows.push_back(mainWindow);
350}
351
353{
354 m_mainWindows.removeOne(mainWindow);
356 maybeDelete();
357}
358
360{
361 m_floatingWindows.push_back(fw);
363}
364
366{
367 m_floatingWindows.removeOne(fw);
369 maybeDelete();
370}
371
373{
374 m_layouts.push_back(layout);
375}
376
378{
379 m_layouts.removeOne(layout);
380}
381
383{
384 m_groups.push_back(group);
385}
386
388{
389 m_groups.removeOne(group);
390}
391
393{
394 d->m_numLayoutSavers++;
395}
396
398{
399 d->m_numLayoutSavers--;
400}
401
403{
404 return d->m_focusedDockWidget;
405}
406
407bool DockRegistry::containsDockWidget(const QString &uniqueName) const
408{
409 return dockByName(uniqueName) != nullptr;
410}
411
412bool DockRegistry::containsMainWindow(const QString &uniqueName) const
413{
414 return mainWindowByName(uniqueName) != nullptr;
415}
416
417Core::DockWidget *DockRegistry::dockByName(const QString &name, DockByNameFlags flags) const
418{
419 for (auto dock : std::as_const(m_dockWidgets)) {
420 if (dock->uniqueName() == name)
421 return dock;
422 }
423
424 if (flags.testFlag(DockByNameFlag::ConsultRemapping)) {
425 // Name doesn't exist, let's check if it was remapped during a layout restore.
426 auto it = m_dockWidgetIdRemapping.find(name);
427 const QString newName = it == m_dockWidgetIdRemapping.cend() ? QString() : it->second;
428 if (!newName.isEmpty())
429 return dockByName(newName);
430 }
431
432 if (flags.testFlag(DockByNameFlag::CreateIfNotFound)) {
433 // DockWidget doesn't exist, ask to create it
434 if (auto factoryFunc = Config::self().dockWidgetFactoryFunc()) {
435 auto dw = factoryFunc(name);
436 if (dw && dw->uniqueName() != name) {
437 // Very special case
438 // The user's factory function returned a dock widget with a different ID.
439 // We support it. Save the mapping though.
440 m_dockWidgetIdRemapping[name] = dw->uniqueName();
441 }
442 return dw;
443 } else {
444 KDDW_ERROR("Couldn't find dock widget name={}", name);
445 }
446 }
447
448 return nullptr;
449}
450
452{
453 for (auto mainWindow : std::as_const(m_mainWindows)) {
454 if (mainWindow->uniqueName() == name)
455 return mainWindow;
456 }
457
458 return nullptr;
459}
460
462{
463 std::set<QString> names;
464 for (auto dock : std::as_const(m_dockWidgets)) {
465 const QString name = dock->uniqueName();
466 if (name.isEmpty()) {
467 KDDW_ERROR("DockRegistry::isSane: DockWidget is missing a name");
468 return false;
469 } else if (names.find(name) != names.cend()) {
470 KDDW_ERROR("DockRegistry::isSane: dockWidgets with duplicate names: {}", name);
471 return false;
472 } else {
473 names.insert(name);
474 }
475 }
476
477 names.clear();
478 for (auto mainwindow : std::as_const(m_mainWindows)) {
479 const QString name = mainwindow->uniqueName();
480 if (name.isEmpty()) {
481 KDDW_ERROR("DockRegistry::isSane: MainWindow is missing a name");
482 return false;
483 } else if (names.find(name) != names.cend()) {
484 KDDW_ERROR("DockRegistry::isSane: mainWindow with duplicate names: {}", name);
485 return false;
486 } else {
487 names.insert(name);
488 }
489
490 if (!mainwindow->layout()->checkSanity())
491 return false;
492 }
493
494 return true;
495}
496
498{
499 return m_dockWidgets;
500}
501
503{
505 result.reserve(names.size());
506
507 for (auto dw : std::as_const(m_dockWidgets)) {
508 if (names.contains(dw->uniqueName()))
509 result.push_back(dw);
510 }
511
512 return result;
513}
514
516{
518 result.reserve(names.size());
519
520 for (auto mw : std::as_const(m_mainWindows)) {
521 if (names.contains(mw->uniqueName()))
522 result.push_back(mw);
523 }
524
525 return result;
526}
527
529{
531 result.reserve(m_dockWidgets.size());
532
533 for (Core::DockWidget *dw : m_dockWidgets) {
534 const bool shouldSkip = honourSkipped && (dw->layoutSaverOptions() & LayoutSaverOption::Skip);
535 if (!shouldSkip && dw->parent() == nullptr && !dw->isVisible())
536 result.push_back(dw);
537 }
538
539 return result;
540}
541
543{
544 return m_mainWindows;
545}
546
548{
550
551 for (auto mw : m_mainWindows) {
552 if (View *view = mw->view()) {
553 auto viewInterface = dynamic_cast<Core::MainWindowViewInterface *>(view);
554 areas.push_back(viewInterface);
555 }
556 }
557
558 return areas;
559}
560
562{
563 return m_layouts;
564}
565
567{
568 return m_groups;
569}
570
571Vector<Core::FloatingWindow *> DockRegistry::floatingWindows(bool includeBeingDeleted, bool honourSkipped) const
572{
573 // Returns all the FloatingWindow which aren't being deleted
575 result.reserve(m_floatingWindows.size());
576 for (Core::FloatingWindow *fw : m_floatingWindows) {
577 if (!includeBeingDeleted && fw->beingDeleted())
578 continue;
579
580 if (honourSkipped && fw->allDockWidgetsHave(LayoutSaverOption::Skip))
581 continue;
582
583 result.push_back(fw);
584 }
585
586 return result;
587}
588
590{
591 Window::List windows;
592 windows.reserve(m_floatingWindows.size());
593 for (Core::FloatingWindow *fw : m_floatingWindows) {
594 if (!fw->beingDeleted()) {
595 if (Core::Window::Ptr window = fw->view()->window()) {
596 windows.push_back(window);
597 } else {
598 KDDW_ERROR("FloatingWindow doesn't have QWindow");
599 }
600 }
601 }
602
603 return windows;
604}
605
607{
608 return std::any_of(m_floatingWindows.begin(), m_floatingWindows.end(),
609 [](Core::FloatingWindow *fw) { return !fw->beingDeleted(); });
610}
611
612Core::FloatingWindow *DockRegistry::floatingWindowForHandle(Core::Window::Ptr windowHandle) const
613{
614 for (Core::FloatingWindow *fw : m_floatingWindows) {
615 if (fw->view()->window()->equals(windowHandle))
616 return fw;
617 }
618
619 return nullptr;
620}
621
623{
624 for (Core::FloatingWindow *fw : m_floatingWindows) {
625 Window::Ptr window = fw->view()->window();
626 if (window && window->handle() == hwnd)
627 return fw;
628 }
629
630 return nullptr;
631}
632
634{
635 if (!window)
636 return nullptr;
637
638 for (Core::MainWindow *mw : m_mainWindows) {
639 if (mw->view()->d->isInWindow(window))
640 return mw;
641 }
642
643 return nullptr;
644}
645
646Window::List DockRegistry::topLevels(bool excludeFloatingDocks) const
647{
648 Window::List windows;
649 windows.reserve(m_floatingWindows.size() + m_mainWindows.size());
650
651 if (!excludeFloatingDocks) {
652 for (Core::FloatingWindow *fw : m_floatingWindows) {
653 if (fw->isVisible()) {
654 if (Core::Window::Ptr window = fw->view()->window()) {
655 windows.push_back(window);
656 } else {
657 KDDW_ERROR("FloatingWindow doesn't have QWindow");
658 }
659 }
660 }
661 }
662
663 for (Core::MainWindow *m : m_mainWindows) {
664 if (m->isVisible()) {
665 if (Core::Window::Ptr window = m->view()->window()) {
666 windows.push_back(window);
667 } else {
668 KDDW_ERROR("MainWindow doesn't have QWindow");
669 }
670 }
671 }
672
673 return windows;
674}
675
677{
678 // Clears everything
679 clear(m_dockWidgets, m_mainWindows, affinities);
680}
681
682void DockRegistry::clear(const Core::DockWidget::List &dockWidgets,
683 const Core::MainWindow::List &mainWindows,
684 const Vector<QString> &affinities)
685{
686 for (auto dw : std::as_const(dockWidgets)) {
687 if (affinities.isEmpty() || affinitiesMatch(affinities, dw->affinities())) {
688 dw->forceClose();
689 dw->d->lastPosition()->removePlaceholders();
690 }
691 }
692
693 for (auto mw : std::as_const(mainWindows)) {
694 if (affinities.isEmpty() || affinitiesMatch(affinities, mw->affinities())) {
695 mw->layout()->clearLayout();
696 }
697 }
698}
699
701{
702 for (Core::DockWidget *dw : std::as_const(m_dockWidgets)) {
703 if (dw->view()->rootView()->equals(dw->view()) && dw->isVisible())
704 dw->d->morphIntoFloatingWindow();
705 }
706}
707
708bool DockRegistry::onMouseButtonPress(View *view, MouseEvent *event)
709{
710 if (!view)
711 return false;
712
713 // When clicking on a MDI Frame we raise the window
714 if (Controller *c = view->d->firstParentOfType(ViewType::Frame)) {
715 auto group = static_cast<Group *>(c);
716 if (group->isMDI())
717 group->view()->raise();
718 }
719
720 // The following code is for hididng the overlay
722 return false;
723
724 if (view->is(ViewType::Frame)) {
725 // break recursion
726 return false;
727 }
728
729 auto p = view->asWrapper();
730 while (p) {
731 if (auto dw = p->asDockWidgetController())
732 return onDockWidgetPressed(dw, event);
733
734 if (auto layout = p->asLayout()) {
735 if (auto mw = layout->mainWindow()) {
736 // The user clicked somewhere in the main window's drop area, but outside of the
737 // overlayed dock widget
738 mw->clearSideBarOverlay();
739 return false;
740 }
741 }
742
743 p = p->parentView();
744 }
745
746
747 return false;
748}
749
750bool DockRegistry::onDockWidgetPressed(Core::DockWidget *dw, MouseEvent *ev)
751{
752 // Here we implement "auto-hide". If there's a overlayed dock widget, we hide it if some other
753 // dock widget is clicked.
754
755 // Don't be sending mouse events around if a popup is open, they are sensitive
756 if (Platform::instance()->hasActivePopup())
757 return false;
758
759 Core::MainWindow *mainWindow = dw->mainWindow();
760 if (!mainWindow) // Only docked widgets are interesting
761 return false;
762
763 if (Core::DockWidget *overlayedDockWidget = mainWindow->overlayedDockWidget()) {
764 ev->ignore();
765 Platform::instance()->sendEvent(overlayedDockWidget->d->group()->view(), ev);
766
767 if (ev->isAccepted()) {
768 // The Frame accepted it. It means the user is resizing it. We allow for 4px outside for
769 // better resize.
770 return true; // don't propagate the event further
771 }
772 if (dw != overlayedDockWidget) {
773 // User clicked outside if the overlay, then we close the overlay.
774 mainWindow->clearSideBarOverlay();
775 return false;
776 }
777 }
778
779 return false;
780}
781
782bool DockRegistry::onExposeEvent(Core::Window::Ptr window)
783{
785 // This floating window was exposed
786 m_floatingWindows.removeOne(fw);
787 m_floatingWindows.append(fw);
788 }
789
790 return false;
791}
792
793void DockRegistry::addSideBarGrouping(const DockWidget::List &dws)
794{
795 m_sideBarGroupings->addGrouping(dws);
796}
797
798void DockRegistry::removeSideBarGrouping(const DockWidget::List &dws)
799{
800 m_sideBarGroupings->removeGrouping(dws);
801}
802
803DockWidget::List DockRegistry::sideBarGroupingFor(DockWidget *dw) const
804{
805 return m_sideBarGroupings->groupingFor(dw);
806}
807
808void SideBarGroupings::addGrouping(const DockWidget::List &dws)
809{
810 if (dws.size() < 2) {
811 // Simplification: A single dock widget is not considered to be grouped.
812 return;
813 }
814
815 m_groupings.push_back(dws);
816}
817
818void SideBarGroupings::removeGrouping(const DockWidget::List &dws)
819{
820 m_groupings.removeAll(dws);
821}
822
823DockWidget::List SideBarGroupings::groupingFor(DockWidget *dw) const
824{
825 return const_cast<SideBarGroupings *>(this)->groupingByRef(dw);
826}
827
828void SideBarGroupings::removeFromGroupings(DockWidget *dw)
829{
830 while (true) {
831 auto &grouping = groupingByRef(dw);
832 if (grouping.isEmpty())
833 return;
834 grouping.removeAll(dw);
835 }
836}
837
838DockWidget::List &SideBarGroupings::groupingByRef(DockWidget *dw)
839{
840 static DockWidget::List empty;
841
842 for (auto &grouping : m_groupings) {
843 if (grouping.contains(dw))
844 return grouping;
845 }
846
847 return empty;
848}
Application-wide config to tune certain behaviours of the framework.
static Config & self()
returns the singleton Config instance
Definition Config.cpp:87
View * view() const
Returns the view associated with this controller, if any.
The DockWidget base-class. DockWidget and Core::DockWidget are only split in two so we can share some...
MainWindow * mainWindow() const
Returns the main window this dock widget is in. nullptr if it's not inside a main window Also returns...
QString uniqueName() const
the dock widget's unique name.
Vector< QString > affinities() const
Returns the affinity name. Empty by default.
KDDockWidgets::LayoutSaverOptions layoutSaverOptions() const
returns the per-dockwidget options which will affect LayoutSaver These are the options which were pas...
void forceClose()
Like QWidget::close() but the hosted widget won't be asked if we should close.
bool allDockWidgetsHave(DockWidgetOption) const
Returns whether all dock widgets have the specified option set.
bool beingDeleted() const
Returns whether a deleteLater has already been issued.
The widget (QWidget or QQuickItem) which holds a layout of dock widgets.
Definition Layout.h:57
Vector< Core::Group * > groups() const
Returns this list of Group objects contained in this layout.
Definition Layout.cpp:256
static Layout * fromLayoutingHost(LayoutingHost *)
Definition Layout.cpp:399
The interface that MainWindow views should implement.
The MainWindow base-class. MainWindow and MainWindowBase are only split in two so we can share some c...
void clearSideBarOverlay(bool deleteFrame=true)
closes any overlayed dock widget. The sidebar still displays them as button.
QString uniqueName() const
Returns the unique name that was passed via constructor. Used internally by the save/restore mechanis...
Core::DockWidget * overlayedDockWidget() const
returns the dock widget which is currently overlayed. nullptr if none. This is only relevant when usi...
virtual void onMainWindowDestroyed(Core::MainWindow *)
Called when a main window is created. Overridden by flutter, so it can destroy the window.
virtual void onFloatingWindowDestroyed(Core::FloatingWindow *)
Called when a floating window is created. Overridden by flutter, so it can destroy the window.
static Platform * instance()
Returns the platform singleton.
void removeGlobalEventFilter(EventFilterInterface *)
Removes a global event filter.
virtual void runDelayed(int ms, Core::DelayedCall *c)=0
virtual void sendEvent(View *, Event *) const =0
Sends the specified event to the specified view.
void installGlobalEventFilter(EventFilterInterface *)
Installs a global event filter Events will be forwarded to the specified EventFilterInterface.
virtual void onFloatingWindowCreated(Core::FloatingWindow *)
Called when a floating window is created. Overridden by flutter, so it can create a window.
virtual void onMainWindowCreated(Core::MainWindow *)
Called when a main window is created. Overridden by flutter, so it can create a window Used by tests ...
virtual std::shared_ptr< View > rootView() const =0
Returns the top-level gui element which this view is inside It's the root view of the window.
virtual bool is(ViewType) const
Returns whether the view is of the specified type Virtual so it can be overridden by ViewWrapper....
virtual std::shared_ptr< Core::Window > window() const =0
Returns the window this view is inside For the Qt frontend, this wraps a QWindow. Like QWidget::windo...
virtual void raise()=0
virtual std::shared_ptr< View > asWrapper()=0
Returns this view, but as a wrapper.
bool affinitiesMatch(const Vector< QString > &affinities1, const Vector< QString > &affinities2) const
@ CreateIfNotFound
Creates the dock widget via the user's widget factory in case it doesn't exist.
Q_INVOKABLE void clear(const Vector< QString > &affinities={})
Closes all dock widgets, and destroys all FloatingWindows This is called before restoring a layout.
Core::FloatingWindow * floatingWindowForHandle(std::shared_ptr< Core::Window > windowHandle) const
returns the FloatingWindow with handle windowHandle
Core::MainWindow * mainWindowForHandle(std::shared_ptr< Core::Window > windowHandle) const
returns the MainWindow with handle windowHandle
Vector< Core::DockWidget * > dockWidgets(const Vector< QString > &names)
overload returning only the ones with the specified names
void unregisterFloatingWindow(Core::FloatingWindow *)
Q_INVOKABLE KDDockWidgets::Core::DockWidget * dockByName(const QString &, KDDockWidgets::DockRegistry::DockByNameFlags={}) const
void registerMainWindow(Core::MainWindow *)
Vector< QString > dockWidgetNames() const
Returns a list of all known dock widget unique names.
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...
Vector< Core::MainWindowViewInterface * > mainDockingAreas() const
returns all MainWindow instances Like mainwindows(), but with better suited for QtQuick and better te...
Vector< Core::FloatingWindow * > floatingWindows(bool includeBeingDeleted=false, bool honourSkipped=false) const
returns all FloatingWindow instances. Not necessarily all floating dock widgets, As there might be Do...
Vector< std::shared_ptr< Core::Window > > floatingQWindows() const
overload that returns list of QWindow. This is more friendly for supporting both QtWidgets and QtQuic...
Q_INVOKABLE KDDockWidgets::Core::DockWidget * focusedDockWidget() const
Q_INVOKABLE bool containsMainWindow(const QString &uniqueName) const
void unregisterGroup(Core::Group *)
Vector< Core::Group * > groups() const
returns a list of all Frame instances
void unregisterDockWidget(Core::DockWidget *)
Core::Group * groupInMDIResize() const
Returns the Group which is being resized in a MDI layout. nullptr if none.
Q_INVOKABLE KDDockWidgets::Core::MainWindow * mainWindowByName(const QString &) const
static DockRegistry * self()
Q_INVOKABLE bool hasFloatingWindows() const
returns whether if there's at least one floating window
void ensureAllFloatingWidgetsAreMorphed()
Ensures that all floating DockWidgets have a FloatingWindow as a window.
Q_INVOKABLE bool containsDockWidget(const QString &uniqueName) const
void unregisterLayout(Core::Layout *)
SideBarLocation sideBarLocationForDockWidget(const Core::DockWidget *) const
Returns whether the specified dock widget is in a side bar, and which. SideBarLocation::None is retur...
void registerGroup(Core::Group *)
Vector< Core::Layout * > layouts() const
returns the list of Layout instances
void unregisterMainWindow(Core::MainWindow *)
Vector< Core::MainWindow * > mainWindows(const Vector< QString > &names)
overload returning only the ones with the specified names
bool isEmpty(bool excludeBeingDeleted=false) const
returns true if there's 0 dockwidgets, 0 main windows
Vector< Core::MainWindow * > mainWindowsWithAffinity(const Vector< QString > &affinities) const
Returns all main windows which match at least one of the affinities.
Core::SideBar * sideBarForDockWidget(const Core::DockWidget *) const
Overload that returns the SideBar itself.
Vector< Core::DockWidget * > closedDockwidgets(bool honourSkipped) const
returns all closed DockWidget instances
bool itemIsInMainWindow(const Core::Item *) const
Returns whether the item is in a main window. Nesting is honoured. (MDIArea inside DropArea inside Ma...
void registerFloatingWindow(Core::FloatingWindow *)
Vector< QString > mainWindowsNames() const
Returns a list of all known main window unique names.
Vector< Core::DockWidget * > dockwidgets() const
returns all DockWidget instances
void registerDockWidget(Core::DockWidget *)
Vector< Core::MainWindow * > mainwindows() const
returns all MainWindow instances
Vector< std::shared_ptr< Core::Window > > topLevels(bool excludeFloatingDocks=false) const
Returns the list with all visiblye top-level parents of our FloatingWindow and MainWindow instances.
void checkSanityAll(bool dumpDebug=false)
Calls Layout::checkSanity() on all layouts.
Core::Layout * layoutForItem(const Core::Item *) const
Returns the Layout where the specified item is in.
void registerLayout(Core::Layout *)
The DockWidget controller that's shared between QtWidgets and QtQuick frontends.
A MultiSplitter with support for drop indicators when hovering over.
The MainWindow base-class that's shared between QtWidgets and QtQuick stack.
Class to abstract QAction, so code still works with QtQuick and Flutter.
SideBarLocation
Each main window supports 4 sidebars.
Definition utils.h:161
bool isEmpty() const const

© 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