KDDockWidgets API Documentation 1.7
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-2023 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#include "DockWidgetBase.h"
14#include "private/MDILayoutWidget_p.h"
15#include "private/DropAreaWithCentralFrame_p.h"
16
17#ifdef KDDOCKWIDGETS_QTWIDGETS
18#include "DockWidget.h"
19#include <QVBoxLayout>
20#else
21#include "DockWidgetQuick.h"
22#endif
23
24#include <QGuiApplication>
25#include <QCloseEvent>
26
27using namespace KDDockWidgets;
28
29class MDIArea::Private
30{
31public:
32 Private(QWidgetOrQuick *parent)
33 : layoutWidget(new MDILayoutWidget(parent))
34 {
35 }
36
37 ~Private()
38 {
39 delete layoutWidget;
40 }
41
42 MDILayoutWidget *const layoutWidget;
43};
44
46 : QWidgetAdapter(parent)
47 , d(new Private(this))
48{
49#ifdef KDDOCKWIDGETS_QTWIDGETS
50 auto vlay = new QVBoxLayout(this);
51 vlay->setContentsMargins({});
52 vlay->addWidget(d->layoutWidget);
53#else
54 QWidgetAdapter::makeItemFillParent(d->layoutWidget);
55#endif
56}
57
59{
60 delete d;
61}
62
64{
66 // We' wrap it with a drop area, so we can drag other dock widgets over this one and dock
67 auto wrapperDW = new DockWidgetType(QStringLiteral("%1-mdiWrapper").arg(dw->uniqueName()));
68 auto dropAreaWrapper = new DropArea(wrapperDW, /*isMDIWrapper= */ true);
69 dropAreaWrapper->addDockWidget(dw, Location_OnBottom, nullptr);
70 wrapperDW->setWidget(dropAreaWrapper);
71
72 dw = wrapperDW;
73 }
74
75 d->layoutWidget->addDockWidget(dw, localPt, addingOption);
76}
77
79{
80 d->layoutWidget->moveDockWidget(dw, pos);
81}
82
84{
85 d->layoutWidget->resizeDockWidget(dw, size);
86}
87
89{
90 return d->layoutWidget->frames();
91}
92
94{
95 e->accept(); // Accepted by default (will close unless ignored)
96
97 const Frame::List frames = this->frames();
98 for (Frame *frame : frames) {
99 qApp->sendEvent(frame, e);
100 if (!e->isAccepted())
101 break; // Stop when the first frame prevents closing
102 }
103}
The DockWidget base-class that's shared between QtWidgets and QtQuick stack.
Represents a dock widget.
Represents a dock widget.
The DockWidget base-class. DockWidget and DockWidgetBase are only split in two so we can share some c...
KDDockWidgets::DockWidgetBase::Options options
void resizeDockWidget(DockWidgetBase *dw, QSize size)
Sets the size of dock widget dw to size.
Definition MDIArea.cpp:83
void onCloseEvent(QCloseEvent *) override
Forwards the close event to the MDI dock widgets, aborts closing if at least one dock widget doesn't ...
Definition MDIArea.cpp:93
MDIArea(QWidgetOrQuick *parent=nullptr)
Definition MDIArea.cpp:45
void moveDockWidget(DockWidgetBase *dw, QPoint pos)
Moves a dock widget dw to point pos.
Definition MDIArea.cpp:78
QList< Frame * > frames() const
Returns the list of frames in this MDI Area Each Frame object represents a 'window' emebedded in the ...
Definition MDIArea.cpp:88
void addDockWidget(DockWidgetBase *dw, QPoint localPt, InitialOption addingOption={})
docks the dock widgets into this MDI area, at the specified position
Definition MDIArea.cpp:63
@ Location_OnBottom
‍Right docking location
KDDockWidgets::DockWidget DockWidgetType
void accept()
bool isAccepted() const const
Struct describing the preferred dock widget size and visibility when adding it to a layout.

© 2019-2023 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 on Wed Nov 1 2023 00:02:31 for KDDockWidgets API Documentation by doxygen 1.9.8