KDDockWidgets API Documentation 2.1
Loading...
Searching...
No Matches
MDIArea.cpp
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#include "MDIArea.h"
13
14#include "core/View_p.h"
15
17#include "kddockwidgets/core/views/DockWidgetViewInterface.h"
18#include "kddockwidgets/core/DockWidget.h"
19#include "kddockwidgets/core/MDILayout.h"
20#include "kddockwidgets/core/DropArea.h"
21
23#include "Config.h"
24
25#include <QVBoxLayout>
26
27using namespace KDDockWidgets;
28using namespace KDDockWidgets::Core;
29using namespace KDDockWidgets::QtWidgets;
30
31class MDIArea::Private
32{
33public:
34 explicit Private(View *parent)
35 : layout(new MDILayout(parent))
36 {
37 }
38
39 ~Private()
40 {
41 delete layout;
42 }
43
44 MDILayout *const layout;
45};
46
48 : QtWidgets::View<QWidget>(nullptr, ViewType::None, parent)
49 , d(new Private(this))
50{
51
52 auto vlay = new QVBoxLayout(this);
53 vlay->addWidget(View_qt::asQWidget(d->layout));
54
55 View::d->closeRequested.connect([this](QCloseEvent *ev) { d->layout->onCloseEvent(ev); });
56}
57
59{
60 delete d;
61}
62
64 const InitialOption &addingOption)
65{
66 if (!dw)
67 return;
68
70 // We' wrap it with a drop area, so we can drag other dock widgets over this one and dock
71 auto wrapperDW =
74 ->createDockWidget(QStringLiteral("%1-mdiWrapper").arg(dw->uniqueName()))
76
77 auto dropAreaWrapper = new DropArea(wrapperDW->view(), {}, /*isMDIWrapper= */ true);
78 dropAreaWrapper->addDockWidget(dw, Location_OnBottom, nullptr);
79 wrapperDW->setGuestView(dropAreaWrapper->view()->asWrapper());
80
81 dw = wrapperDW;
82 }
83
84 d->layout->addDockWidget(dw, localPt, addingOption);
85}
86
88{
89 d->layout->moveDockWidget(dw, pos);
90}
91
93{
94 d->layout->resizeDockWidget(dw, size);
95}
96
98 const InitialOption &addingOption)
99{
100 auto dw = dwView ? dwView->dockWidget() : nullptr;
101 addDockWidget(dw, localPt, addingOption);
102}
103
105{
106 auto dw = dwView ? dwView->dockWidget() : nullptr;
107 moveDockWidget(dw, pos);
108}
109
111{
112 auto dw = dwView ? dwView->dockWidget() : nullptr;
114}
115
117{
118 return d->layout->groups();
119}
Application-wide config to tune certain behaviours of the framework.
Core::ViewFactory * viewFactory() const
getter for the framework view factory
Definition Config.cpp:182
static Config & self()
returns the singleton Config instance
Definition Config.cpp:88
The interface that DockWidget views should implement.
The DockWidget base-class. DockWidget and Core::DockWidget are only split in two so we can share some...
QString uniqueName() const
the dock widget's unique name.
DockWidgetOptions options() const
Returns the dock widget's options which control behaviour.
The MDILayout class implements a layout suitable for MDI style docking. Where dock widgets are free t...
virtual View * createDockWidget(const QString &uniqueName, DockWidgetOptions options={}, LayoutSaverOptions layoutSaverOptions={}, Qt::WindowFlags windowFlags={}) const =0
Creates a dock widget. This is only used by MainWindow's persistent widget feature....
Core::DockWidget * asDockWidgetController() const
QVector< Core::Group * > groups() const
Returns the list of groups in this MDI Area Each Frame object represents a 'window' emebedded in the ...
Definition MDIArea.cpp:116
void resizeDockWidget(Core::DockWidget *dw, QSize size)
Sets the size of dock widget dw to size.
Definition MDIArea.cpp:92
void addDockWidget(Core::DockWidget *dw, QPoint localPt, const InitialOption &addingOption={})
docks the dock widgets into this MDI area, at the specified position
Definition MDIArea.cpp:63
void moveDockWidget(Core::DockWidget *dw, QPoint pos)
Moves a dock widget dw to point pos.
Definition MDIArea.cpp:87
MDIArea(QWidget *parent=nullptr)
Definition MDIArea.cpp:47
ViewType
Each View type also has a specific Controller associated with, except for ViewType::None.
Definition Controller.h:26
Class to abstract QAction, so code still works with QtQuick and Flutter.
@ Location_OnBottom
‍Right docking location
@ DockWidgetOption_MDINestable
QObject * parent() const const
A factory class for allowing the user to customize some internal widgets.
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