KDDockWidgets API Documentation 1.7
Loading...
Searching...
No Matches
MainWindowInstantiator.cpp
Go to the documentation of this file.
1/*
2 This file is part of KDDockWidgets.
3
4 SPDX-FileCopyrightText: 2019-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 "MainWindowInstantiator_p.h"
13#include "MainWindowQuick_p.h"
14#include "MainWindowMDI.h"
15
16#include "DockWidgetInstantiator_p.h"
17
18#include "../DockRegistry_p.h"
19
20using namespace KDDockWidgets;
21
22MainWindowInstantiator::MainWindowInstantiator()
23 : QQuickItem()
24{
25}
26
27QString MainWindowInstantiator::uniqueName() const
28{
29 return m_uniqueName;
30}
31
32void MainWindowInstantiator::setUniqueName(const QString &name)
33{
34 if (name != m_uniqueName) {
35 m_uniqueName = name;
36 Q_EMIT uniqueNameChanged();
37 }
38}
39
40MainWindowOptions MainWindowInstantiator::options() const
41{
42 return m_options;
43}
44
45void MainWindowInstantiator::setOptions(MainWindowOptions options)
46{
47 if (m_options != options) {
48 m_options = options;
49 Q_EMIT optionsChanged();
50 }
51}
52
53QStringList MainWindowInstantiator::affinities() const
54{
55 return m_mainWindow ? m_mainWindow->affinities() : QStringList();
56}
57
58bool MainWindowInstantiator::isMDI() const
59{
60 return m_mainWindow && m_mainWindow->isMDI();
61}
62
63void MainWindowInstantiator::addDockWidget(DockWidgetBase *dockWidget, Location location,
64 DockWidgetBase *relativeTo, QSize initialSize,
66{
67 if (!m_mainWindow) {
68 qWarning() << Q_FUNC_INFO << "No MainWindow created yet";
69 return;
70 }
71
72 m_mainWindow->addDockWidget(dockWidget, location, relativeTo, { option, initialSize });
73}
74
75void MainWindowInstantiator::addDockWidget(DockWidgetInstantiator *dockWidget, Location location,
76 DockWidgetInstantiator *relativeTo, QSize initialSize,
78{
79 addDockWidget(dockWidget ? dockWidget->dockWidget() : nullptr, location,
80 relativeTo ? relativeTo->dockWidget() : nullptr, initialSize, option);
81}
82
83void MainWindowInstantiator::layoutEqually()
84{
85 if (m_mainWindow)
86 m_mainWindow->layoutEqually();
87}
88
89void MainWindowInstantiator::layoutParentContainerEqually(DockWidgetBase *dw)
90{
91 if (m_mainWindow)
92 m_mainWindow->layoutParentContainerEqually(dw);
93}
94
95void MainWindowInstantiator::moveToSideBar(DockWidgetBase *dw)
96{
97 if (m_mainWindow)
98 m_mainWindow->moveToSideBar(dw);
99}
100
101void MainWindowInstantiator::moveToSideBar(DockWidgetBase *dw, SideBarLocation loc)
102{
103 if (m_mainWindow)
104 m_mainWindow->moveToSideBar(dw, loc);
105}
106
107void MainWindowInstantiator::restoreFromSideBar(DockWidgetBase *dw)
108{
109 if (m_mainWindow)
110 m_mainWindow->restoreFromSideBar(dw);
111}
112
113void MainWindowInstantiator::overlayOnSideBar(DockWidgetBase *dw)
114{
115 if (m_mainWindow)
116 m_mainWindow->overlayOnSideBar(dw);
117}
118
119void MainWindowInstantiator::toggleOverlayOnSideBar(DockWidgetBase *dw)
120{
121 if (m_mainWindow)
122 m_mainWindow->toggleOverlayOnSideBar(dw);
123}
124
125void MainWindowInstantiator::clearSideBarOverlay(bool deleteFrame)
126{
127 if (m_mainWindow)
128 m_mainWindow->clearSideBarOverlay(deleteFrame);
129}
130
131SideBar *MainWindowInstantiator::sideBarForDockWidget(const DockWidgetBase *dw) const
132{
133 return m_mainWindow ? m_mainWindow->sideBarForDockWidget(dw) : nullptr;
134}
135
136bool MainWindowInstantiator::sideBarIsVisible(SideBarLocation loc) const
137{
138 return m_mainWindow && m_mainWindow->sideBarIsVisible(loc);
139}
140
141bool MainWindowInstantiator::closeDockWidgets(bool force)
142{
143 return m_mainWindow && m_mainWindow->closeDockWidgets(force);
144}
145
146void MainWindowInstantiator::classBegin()
147{
148 // Nothing interesting to do here.
149}
150
151void MainWindowInstantiator::componentComplete()
152{
153 if (m_uniqueName.isEmpty()) {
154 qWarning() << Q_FUNC_INFO
155 << "Each DockWidget need an unique name. Set the uniqueName property.";
156 return;
157 }
158
159 if (DockRegistry::self()->containsMainWindow(m_uniqueName)) {
160 // MainWindow already exists
161 return;
162 }
163
164 if (m_uniqueName.isEmpty()) {
165 qWarning() << Q_FUNC_INFO << "Name can't be empty";
166 return;
167 }
168
169 if (m_mainWindow) {
170 qWarning() << Q_FUNC_INFO << "Main window is already initialized";
171 return;
172 }
173
174 const auto mainWindowOptions = MainWindowOptions(m_options);
175
176 if (mainWindowOptions & MainWindowOption_MDI)
177 m_mainWindow = new MainWindowMDI(m_uniqueName, this);
178 else
179 m_mainWindow = new MainWindowQuick(m_uniqueName, mainWindowOptions, this);
180}
MainWindow sub-class which uses MDI as a layout.
The DockWidget base-class. DockWidget and DockWidgetBase are only split in two so we can share some c...
MainWindow sub-class which uses MDI as a layout.
@ MainWindowOption_MDI
‍Makes the MainWindow always have a central frame, for tabbing documents
SideBarLocation
Each main window supports 4 sidebars.

© 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