KDDockWidgets API Documentation 2.0
Loading...
Searching...
No Matches
Controller.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 "Controller.h"
13#include "Controller_p.h"
14#include "Platform.h"
15#include "DelayedCall_p.h"
16#include "View.h"
17#include "Config.h"
18#include "View_p.h"
19#include "Logging_p.h"
20#include "DragController_p.h"
21#include "core/Utils_p.h"
22
23using namespace KDDockWidgets;
24using namespace KDDockWidgets::Core;
25
27 : d(new Private(type, view))
28{
29}
30
32{
33 d->aboutToBeDeleted.emit();
34
35 m_inDtor = true;
36 if (d->m_view && !d->m_view->inDtor())
37 d->m_view->d->free();
38
39 delete d;
40}
41
43{
44 return d->m_type;
45}
46
48{
49 return int(d->m_type) & int(t);
50}
51
53{
54 return m_inDtor;
55}
56
58{
59 return d->m_view;
60}
61
63{
64 return d->m_view && d->m_view->isVisible();
65}
66
68{
69 if (d->m_view)
70 d->m_view->setVisible(is);
71}
72
73Rect Controller::rect() const
74{
75 if (d->m_view)
76 return d->m_view->rect();
77
78 return {};
79}
80
81Point Controller::mapToGlobal(Point localPt) const
82{
83 return d->m_view->mapToGlobal(localPt);
84}
85
87{
88 return d->m_view->height();
89}
90
92{
93 return d->m_view->width();
94}
95
96Size Controller::size() const
97{
98 return d->m_view->size();
99}
100
102{
103 return d->m_view->geometry();
104}
105
106Point Controller::pos() const
107{
108 return d->m_view->geometry().topLeft();
109}
110
111int Controller::x() const
112{
113 return d->m_view->x();
114}
115
116int Controller::y() const
117{
118 return d->m_view->y();
119}
120
122{
123 return view() && view()->close();
124}
125
126std::shared_ptr<View> Controller::window() const
127{
128 return view()->rootView();
129}
130
132{
133 view()->show();
134}
135
137{
138 setParentView_impl(parent);
139 d->parentViewChanged.emit(parent);
140}
141
143{
144 if (auto v = view()) {
145 v->setParent(parent);
146 } else {
147 KDDW_ERROR("No view()");
148 }
149}
150
152{
153#ifdef KDDW_FRONTEND_QT
154 if (!usesQTBUG83030Workaround()) {
156 return;
157 }
158#endif
159
160 // Path for Flutter and QTBUG-83030:
161 Platform::instance()->runDelayed(0, new DelayedDelete(this));
162}
163
164Controller::Private *Controller::dptr() const
165{
166 return d;
167}
168
170{
171 if (auto v = view())
172 return v->isFixedHeight();
173
174 return false;
175}
176
178{
179 if (auto v = view())
180 return v->isFixedWidth();
181
182 return false;
183}
Application-wide config to tune certain behaviours of the framework.
void setParentView(View *parent)
View * view() const
Returns the view associated with this controller, if any.
ViewType type() const
Returns the type of this controller.
virtual void setParentView_impl(View *parent)
Controller(ViewType type, View *)
bool is(ViewType) const
Returns whether this controller is of the specified type.
Controller::Private * dptr() const
Point mapToGlobal(Point) const
std::shared_ptr< View > window() const
static Platform * instance()
Returns the platform singleton.
virtual void runDelayed(int ms, Core::DelayedCall *c)=0
virtual void show()=0
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 close()=0
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.
void deleteLater()

© 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