KDDockWidgets API Documentation 2.1
Loading...
Searching...
No Matches
MainWindowMDIInstantiator.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
15#include "kddockwidgets/core/DockWidget.h"
16#include "kddockwidgets/core/MainWindow.h"
17#include "kddockwidgets/core/DockRegistry.h"
18#include "kddockwidgets/core/MDILayout.h"
19
21
22#include "Platform.h"
23
24using namespace KDDockWidgets;
25
29
31{
32 return m_uniqueName;
33}
34
36{
37 if (name != m_uniqueName) {
38 m_uniqueName = name;
39 Q_EMIT uniqueNameChanged();
40 }
41}
42
44{
45 return m_mainWindow ? m_mainWindow->affinities() : QVector<QString>();
46}
47
48void MainWindowMDIInstantiator::addDockWidget(QQuickItem *dockWidget, QPoint localPos,
49 const InitialOption &addingOption)
50{
51 if (!dockWidget || !m_mainWindow)
52 return;
53
55
56 m_mainWindow->mdiLayout()->addDockWidget(dw, localPos, addingOption);
57}
58
60{
61 return m_mainWindow && m_mainWindow->closeDockWidgets(force);
62}
63
65{
66 // Nothing interesting to do here.
67}
68
70{
71 if (m_uniqueName.isEmpty()) {
72 qWarning() << Q_FUNC_INFO
73 << "Each DockWidget need an unique name. Set the uniqueName property.";
74 return;
75 }
76
77 if (DockRegistry::self()->containsMainWindow(m_uniqueName)) {
78 // MainWindow already exists
79 return;
80 }
81
82 if (m_uniqueName.isEmpty()) {
83 qWarning() << Q_FUNC_INFO << "Name can't be empty";
84 return;
85 }
86
87 if (m_mainWindow) {
88 qWarning() << Q_FUNC_INFO << "Main window is already initialized";
89 return;
90 }
91
92 Core::View *view = new QtQuick::MainWindowMDI(m_uniqueName, this);
93 m_mainWindow = view->asMainWindowController();
94}
The DockWidget base-class. DockWidget and Core::DockWidget are only split in two so we can share some...
void addDockWidget(Core::DockWidget *dw, Point localPt, const InitialOption &addingOption={})
docks the dock widgets into this MDI area, at the specified position
MDILayout * mdiLayout() const
bool closeDockWidgets(bool force=false)
Closes all dock widgets which are docked into this main window This is convenience to calling DockWid...
Vector< QString > affinities() const
Returns the list of affinity names. Empty by default.
Core::MainWindow * asMainWindowController() const
static DockRegistry * self()
Q_INVOKABLE bool closeDockWidgets(bool force=false)
Q_INVOKABLE void addDockWidget(QQuickItem *dockWidget, QPoint localPos, const KDDockWidgets::InitialOption &addingOption={})
MainWindow sub-class which uses MDI as a layout.
static Core::DockWidget * dockWidgetForItem(QQuickItem *)
Class to abstract QAction, so code still works with QtQuick and Flutter.
bool isEmpty() const const
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