KDDockWidgets API Documentation 2.0
Loading...
Searching...
No Matches
core/MainWindow.h
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
12
20#ifndef KD_MAINWINDOW_BASE_H
21#define KD_MAINWINDOW_BASE_H
22
23#include "kddockwidgets/docks_export.h"
24#include "kddockwidgets/KDDockWidgets.h"
25#include "kddockwidgets/LayoutSaver.h"
26#include "kddockwidgets/core/Controller.h"
27
28class TestDocks;
29
30namespace KDDockWidgets {
31
32namespace QtWidgets {
33class MainWindow;
34}
35
36namespace QtQuick {
37class MainWindow;
38}
39
40namespace flutter {
41class MainWindow;
42}
43
44namespace Core {
45
46class MainWindowViewInterface;
47class MDILayout;
48class DropArea;
49class Group;
50class Layout;
51class SideBar;
52class DockWidget;
53
61class DOCKS_EXPORT MainWindow : public Controller
62{
63 Q_OBJECT
64public:
66
67 explicit MainWindow(View *view, const QString &uniqueName, MainWindowOptions options);
68
69 ~MainWindow() override;
70
80
92 KDDockWidgets::Core::DockWidget *relativeTo = nullptr,
93 KDDockWidgets::InitialOption initialOption = {});
94
107 void setPersistentCentralView(std::shared_ptr<View> widget);
108 std::shared_ptr<View> persistentCentralView() const;
109
111 MainWindowOptions options() const;
112
131 void setAffinities(const Vector<QString> &names);
132
137
145
150
158
162
165
168
171
173 void clearSideBarOverlay(bool deleteFrame = true);
174
178
181
185
188
191 bool isMDI() const;
192
198 bool closeDockWidgets(bool force = false);
199
201 int overlayMargin() const;
202
205 void setOverlayMargin(int margin);
206
208 void setContentsMargins(int l, int t, int r, int b);
209
212
213 // Internal public API:
214
218
222
225 Layout *layout() const;
226
230
235
236
238 Margins centerWidgetMargins() const;
239
241 void init(const QString &name);
242
243protected:
244 void setUniqueName(const QString &uniqueName);
246
247private:
248 class Private;
249 Private *const d;
250
254
256 friend class ::TestDocks;
258 bool deserialize(const LayoutSaver::MainWindow &);
259 LayoutSaver::MainWindow serialize() const;
260};
261}
262}
263
264#endif
The DockWidget base-class. DockWidget and Core::DockWidget are only split in two so we can share some...
The widget (QWidget or QQuickItem) which holds a layout of dock widgets.
Definition Layout.h:57
The MDILayout class implements a layout suitable for MDI style docking. Where dock widgets are free t...
The interface that MainWindow views should implement.
The MainWindow base-class. MainWindow and MainWindowBase are only split in two so we can share some c...
bool sideBarIsVisible(KDDockWidgets::SideBarLocation location) const
Returns whether the specified sidebar is visible.
void setAffinities(const Vector< QString > &names)
Sets the affinities names. Dock widgets can only dock into main windows of the same affinity.
void clearSideBarOverlay(bool deleteFrame=true)
closes any overlayed dock widget. The sidebar still displays them as button.
QString uniqueName() const
Returns the unique name that was passed via constructor. Used internally by the save/restore mechanis...
void setOverlayMargin(int margin)
Sets the margin used by overlay docks. Does not modify currently overlayed docks.
void addDockWidgetAsTab(KDDockWidgets::Core::DockWidget *dockwidget)
Docks a DockWidget into the central group, tabbed.
void overlayOnSideBar(KDDockWidgets::Core::DockWidget *dw)
Shows the dock widget overlayed on top of the main window, placed next to the sidebar.
void moveToSideBar(KDDockWidgets::Core::DockWidget *dw, KDDockWidgets::SideBarLocation location)
overload that allows to specify which sidebar to use, instead of using heuristics.
std::shared_ptr< View > persistentCentralView() const
KDDockWidgets::Core::SideBar * sideBarForDockWidget(const KDDockWidgets::Core::DockWidget *dw) const
Returns the sidebar this dockwidget is in. nullptr if not in any.
void toggleOverlayOnSideBar(KDDockWidgets::Core::DockWidget *dw)
Shows or hides an overlay. It's assumed the dock widget is already in a side-bar.
void layoutParentContainerEqually(KDDockWidgets::Core::DockWidget *dockWidget)
like layoutEqually() but starts with the container that has dockWidget. While layoutEqually() starts ...
Margins centerWidgetMargins() const
bool anySideBarIsVisible() const
Returns whether any side bar is visible.
void addDockWidget(KDDockWidgets::Core::DockWidget *dockWidget, KDDockWidgets::Location location, KDDockWidgets::Core::DockWidget *relativeTo=nullptr, KDDockWidgets::InitialOption initialOption={})
Docks a DockWidget into this main window.
MainWindow(View *view, const QString &uniqueName, MainWindowOptions options)
int overlayMargin() const
Returns the margin used by overlay docks. Default: 1.
void setContentsMargins(int l, int t, int r, int b)
Sets the content's margins.
void setPersistentCentralView(std::shared_ptr< View > widget)
Sets a persistent central widget. It can't be detached.
MDILayout * mdiLayout() const
void layoutEqually()
layouts all the widgets so they have an equal size within their parent container
DropArea * multiSplitter() const
MainWindowOptions options() const
Returns the main window options that were passed via constructor.
Core::DockWidget * overlayedDockWidget() const
returns the dock widget which is currently overlayed. nullptr if none. This is only relevant when usi...
void moveToSideBar(KDDockWidgets::Core::DockWidget *dw)
Moves the dock widget into one of the MainWindow's sidebar. Means the dock widget is removed from the...
bool closeDockWidgets(bool force=false)
Closes all dock widgets which are docked into this main window This is convenience to calling DockWid...
void init(const QString &name)
bool isMDI() const
Returns whether this main window is using an MDI layout. In other words, returns true if MainWindowOp...
Vector< QString > affinities() const
Returns the list of affinity names. Empty by default.
void restoreFromSideBar(KDDockWidgets::Core::DockWidget *dw)
Removes the dock widget from the sidebar and docks it into the main window again.
Core::SideBar * sideBar(SideBarLocation location) const
Returns the side bar at the specified location.
void setUniqueName(const QString &uniqueName)
Vector< MainWindow * > List
LayoutSaver allows to save or restore layouts.
Definition LayoutSaver.h:56
A docking area for dock widgets Named MainWindow as it's the QtWidgets/QMainWindow counterpart....
The QMainwindow sub-class that the application should use to be able to dock KDDockWidget DockWidget ...
Class to abstract QAction, so code still works with QtQuick and Flutter.
SideBarLocation
Each main window supports 4 sidebars.
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