KDDockWidgets API Documentation 1.7
Loading...
Searching...
No Matches
MainWindowBase.h
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
20#ifndef KD_MAINWINDOW_BASE_H
21#define KD_MAINWINDOW_BASE_H
22
23#include "docks_export.h"
24#include "KDDockWidgets.h"
25#include "QWidgetAdapter.h"
26#include "LayoutSaver.h"
27
28#include <QVector>
29#include <QMargins>
30
31class TestDocks;
32
33namespace KDDockWidgets {
34
35class DockWidgetBase;
36class Frame;
37class DropArea;
38class MDILayoutWidget;
39class MultiSplitter;
40class LayoutWidget;
41class DropAreaWithCentralFrame;
42class SideBar;
43
51#ifndef PYTHON_BINDINGS // Pyside bug: https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1327
52class DOCKS_EXPORT MainWindowBase : public QMainWindowOrQuick
53#else
54class DOCKS_EXPORT MainWindowBase : public QMainWindow
55#endif
56{
57 Q_OBJECT
58 Q_PROPERTY(QStringList affinities READ affinities CONSTANT)
59 Q_PROPERTY(QString uniqueName READ uniqueName CONSTANT)
60 Q_PROPERTY(KDDockWidgets::MainWindowOptions options READ options CONSTANT)
61 Q_PROPERTY(bool isMDI READ isMDI CONSTANT)
62 Q_PROPERTY(int overlayMargin READ overlayMargin WRITE setOverlayMargin NOTIFY overlayMarginChanged)
63public:
65 explicit MainWindowBase(const QString &uniqueName, MainWindowOptions options = MainWindowOption_HasCentralFrame,
66 WidgetType *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
67
68 ~MainWindowBase() override;
69
77 Q_INVOKABLE void addDockWidgetAsTab(KDDockWidgets::DockWidgetBase *dockwidget);
78
88 Q_INVOKABLE void addDockWidget(KDDockWidgets::DockWidgetBase *dockWidget,
89 KDDockWidgets::Location location,
90 KDDockWidgets::DockWidgetBase *relativeTo = nullptr,
91 KDDockWidgets::InitialOption initialOption = {});
92
105 Q_INVOKABLE void setPersistentCentralWidget(KDDockWidgets::QWidgetOrQuick *widget);
106 QWidgetOrQuick *persistentCentralWidget() const;
107
113 QString uniqueName() const;
114
115
117 MainWindowOptions options() const;
118
121 DropAreaWithCentralFrame *dropArea() const;
122
125 MultiSplitter *multiSplitter() const;
126
129 LayoutWidget *layoutWidget() const;
130
133 MDILayoutWidget *mdiLayoutWidget() const;
134
151 void setAffinities(const QStringList &names);
152
156 QStringList affinities() const;
157
164 Q_INVOKABLE void layoutEqually();
165
169 Q_INVOKABLE void layoutParentContainerEqually(KDDockWidgets::DockWidgetBase *dockWidget);
170
177 Q_INVOKABLE void moveToSideBar(KDDockWidgets::DockWidgetBase *);
178
180 Q_INVOKABLE void moveToSideBar(KDDockWidgets::DockWidgetBase *, KDDockWidgets::SideBarLocation);
181
183 Q_INVOKABLE void restoreFromSideBar(KDDockWidgets::DockWidgetBase *);
184
186 Q_INVOKABLE void overlayOnSideBar(KDDockWidgets::DockWidgetBase *);
187
189 Q_INVOKABLE void toggleOverlayOnSideBar(KDDockWidgets::DockWidgetBase *);
190
192 Q_INVOKABLE void clearSideBarOverlay(bool deleteFrame = true);
193
195 Q_INVOKABLE KDDockWidgets::SideBar *
196 sideBarForDockWidget(const KDDockWidgets::DockWidgetBase *) const;
197
199 Q_INVOKABLE bool sideBarIsVisible(KDDockWidgets::SideBarLocation) const;
200
203 DockWidgetBase *overlayedDockWidget() const;
204
206 bool anySideBarIsVisible() const;
207
210 bool isMDI() const;
211
217 Q_INVOKABLE bool closeDockWidgets(bool force = false);
218
224 QRect windowGeometry() const;
225
227 int overlayMargin() const;
228
231 void setOverlayMargin(int margin);
232
233protected:
234#ifdef KDDOCKWIDGETS_QTWIDGETS
235 void onCloseEvent(QCloseEvent *);
236#else
237 // QtQuick uses a different base class. This will be fixed in the wip/2.0 branch.
238 void onCloseEvent(QCloseEvent *) override;
239#endif
240
241 void setUniqueName(const QString &uniqueName);
242 void onResized(QResizeEvent *); // Because QtQuick doesn't have resizeEvent()
243 virtual QMargins centerWidgetMargins() const = 0;
244 virtual SideBar *sideBar(SideBarLocation) const = 0;
246 {
247 return {};
248 }
249
250Q_SIGNALS:
252
257
259
260private:
261 class Private;
262 Private *const d;
263
264 friend class ::TestDocks;
265 friend class LayoutSaver;
266 bool deserialize(const LayoutSaver::MainWindow &);
267 LayoutSaver::MainWindow serialize() const;
268};
269}
270
271#endif
File with KDDockWidgets namespace-level enums and methods.
Class to save and restore dockwidget layouts.
Abstraction for supporting both QtWidgets and QtQuick.
The DockWidget base-class. DockWidget and DockWidgetBase are only split in two so we can share some c...
LayoutSaver allows to save or restore layouts.
Definition LayoutSaver.h:55
The MainWindow base-class. MainWindow and MainWindowBase are only split in two so we can share some c...
virtual SideBar * sideBar(SideBarLocation) const =0
virtual QMargins centerWidgetMargins() const =0
void frameCountChanged(int)
emitted when the number of docked frames changes Note that we're using the "Frame" nomenculature inst...
virtual QRect centralAreaGeometry() const
SideBarLocation
Each main window supports 4 sidebars.
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