KDDockWidgets API Documentation 2.1
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 const KDDockWidgets::InitialOption &initialOption = {});
94
95 // dev mode only for now, as it still has bugs.
96 // We need to be able to dock to relativeTo=hidden dock
116 KDDockWidgets::Location location, const KDDockWidgets::InitialOption &initialOption = {});
129 void setPersistentCentralView(std::shared_ptr<View> widget);
130 std::shared_ptr<View> persistentCentralView() const;
131
133 MainWindowOptions options() const;
134
153 void setAffinities(const Vector<QString> &names);
154
159
167
172
180
184
187
190
193
195 void clearSideBarOverlay(bool deleteGroup = true);
196
200
203
207
210
213 bool isMDI() const;
214
220 bool closeDockWidgets(bool force = false);
221
223 int overlayMargin() const;
224
227 void setOverlayMargin(int margin);
228
230 void setContentsMargins(int l, int t, int r, int b);
231
234
235 // Internal public API:
236
240
244
247 Layout *layout() const;
248
252
257
258
260 Margins centerWidgetMargins() const;
261
263 void init(const QString &name);
264
265protected:
266 void setUniqueName(const QString &uniqueName);
268
269private:
270 class Private;
271 Private *const d;
272
276
278 friend class ::TestDocks;
280 bool deserialize(const LayoutSaver::MainWindow &);
281 LayoutSaver::MainWindow serialize() const;
282};
283}
284}
285
286#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.
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.
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
void clearSideBarOverlay(bool deleteGroup=true)
closes any overlayed dock widget. The sidebar still displays them as button.
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 addDockWidgetToSide(KDDockWidgets::Core::DockWidget *dockWidget, KDDockWidgets::Location location, const KDDockWidgets::InitialOption &initialOption={})
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 addDockWidget(KDDockWidgets::Core::DockWidget *dockWidget, KDDockWidgets::Location location, KDDockWidgets::Core::DockWidget *relativeTo=nullptr, const KDDockWidgets::InitialOption &initialOption={})
Docks a DockWidget into this main window.
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