KDDockWidgets API Documentation  1.5
MainWindowBase.h
Go to the documentation of this file.
1 /*
2  This file is part of KDDockWidgets.
3 
4  SPDX-FileCopyrightText: 2019-2022 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 
31 class TestDocks;
32 
33 namespace KDDockWidgets {
34 
35 class DockWidgetBase;
36 class Frame;
37 class DropArea;
38 class MDILayoutWidget;
39 class MultiSplitter;
40 class LayoutWidget;
41 class DropAreaWithCentralFrame;
42 class SideBar;
43 
51 #ifndef PYTHON_BINDINGS //Pyside bug: https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1327
52 class DOCKS_EXPORT MainWindowBase : public QMainWindowOrQuick
53 #else
54 class 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 public:
64  explicit MainWindowBase(const QString &uniqueName, MainWindowOptions options = MainWindowOption_HasCentralFrame,
65  WidgetType *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
66 
67  ~MainWindowBase() override;
68 
76  Q_INVOKABLE void addDockWidgetAsTab(KDDockWidgets::DockWidgetBase *dockwidget);
77 
87  Q_INVOKABLE void addDockWidget(KDDockWidgets::DockWidgetBase *dockWidget,
88  KDDockWidgets::Location location,
89  KDDockWidgets::DockWidgetBase *relativeTo = nullptr,
90  KDDockWidgets::InitialOption initialOption = {});
91 
104  Q_INVOKABLE void setPersistentCentralWidget(KDDockWidgets::QWidgetOrQuick *widget);
105  QWidgetOrQuick *persistentCentralWidget() const;
106 
112  QString uniqueName() const;
113 
114 
116  MainWindowOptions options() const;
117 
120  DropAreaWithCentralFrame *dropArea() const;
121 
124  MultiSplitter *multiSplitter() const;
125 
128  LayoutWidget *layoutWidget() const;
129 
132  MDILayoutWidget *mdiLayoutWidget() const;
133 
150  void setAffinities(const QStringList &names);
151 
155  QStringList affinities() const;
156 
163  Q_INVOKABLE void layoutEqually();
164 
168  Q_INVOKABLE void layoutParentContainerEqually(KDDockWidgets::DockWidgetBase *dockWidget);
169 
176  Q_INVOKABLE void moveToSideBar(KDDockWidgets::DockWidgetBase *);
177 
179  Q_INVOKABLE void moveToSideBar(KDDockWidgets::DockWidgetBase *, KDDockWidgets::SideBarLocation);
180 
182  Q_INVOKABLE void restoreFromSideBar(KDDockWidgets::DockWidgetBase *);
183 
185  Q_INVOKABLE void overlayOnSideBar(KDDockWidgets::DockWidgetBase *);
186 
188  Q_INVOKABLE void toggleOverlayOnSideBar(KDDockWidgets::DockWidgetBase *);
189 
191  Q_INVOKABLE void clearSideBarOverlay(bool deleteFrame = true);
192 
194  Q_INVOKABLE KDDockWidgets::SideBar *
195  sideBarForDockWidget(const KDDockWidgets::DockWidgetBase *) const;
196 
198  Q_INVOKABLE bool sideBarIsVisible(KDDockWidgets::SideBarLocation) const;
199 
202  DockWidgetBase *overlayedDockWidget() const;
203 
205  bool anySideBarIsVisible() const;
206 
209  bool isMDI() const;
210 
216  Q_INVOKABLE bool closeDockWidgets(bool force = false);
217 
223  QRect windowGeometry() const;
224 
225 protected:
226  void setUniqueName(const QString &uniqueName);
227  void onResized(QResizeEvent *); // Because QtQuick doesn't have resizeEvent()
228  virtual QMargins centerWidgetMargins() const = 0;
229  virtual SideBar *sideBar(SideBarLocation) const = 0;
230  virtual QRect centralAreaGeometry() const
231  {
232  return {};
233  }
234 
235 Q_SIGNALS:
237 
241  void frameCountChanged(int);
242 
243 private:
244  class Private;
245  Private *const d;
246 
247  friend class ::TestDocks;
248  friend class LayoutSaver;
249  bool deserialize(const LayoutSaver::MainWindow &);
250  LayoutSaver::MainWindow serialize() const;
251 };
252 }
253 
254 #endif
QMainWindow
LayoutSaver.h
Class to save and restore dockwidget layouts.
KDDockWidgets::MainWindowBase::frameCountChanged
void frameCountChanged(int)
emitted when the number of docked frames changes Note that we're using the "Frame" nomenculature inst...
KDDockWidgets::MainWindowBase::centerWidgetMargins
virtual QMargins centerWidgetMargins() const =0
QRect
KDDockWidgets.h
File with KDDockWidgets namespace-level enums and methods.
KDDockWidgets::InitialOption
Struct describing the preferred dock widget size and visibility when adding it to a layout.
Definition: KDDockWidgets.h:105
QWidget
KDDockWidgets::Location
Location
Definition: KDDockWidgets.h:45
KDDockWidgets::MainWindowBase::centralAreaGeometry
virtual QRect centralAreaGeometry() const
Definition: MainWindowBase.h:230
QWidgetAdapter.h
Abstraction for supporting both QtWidgets and QtQuick.
KDDockWidgets::MainWindowBase::sideBar
virtual SideBar * sideBar(SideBarLocation) const =0
Qt::WindowFlags
typedef WindowFlags
KDDockWidgets::LayoutSaver
LayoutSaver allows to save or restore layouts.
Definition: LayoutSaver.h:55
QString
KDDockWidgets::MainWindowBase::uniqueNameChanged
void uniqueNameChanged()
KDDockWidgets::MainWindowBase::List
QVector< MainWindowBase * > List
Definition: MainWindowBase.h:63
QMargins
KDDockWidgets::SideBarLocation
SideBarLocation
Each main window supports 4 sidebars.
Definition: KDDockWidgets.h:211
QResizeEvent
KDDockWidgets::DockWidgetBase
The DockWidget base-class. DockWidget and DockWidgetBase are only split in two so we can share some c...
Definition: DockWidgetBase.h:61
KDDockWidgets
Definition: Config.cpp:36
KDDockWidgets::MainWindowBase
The MainWindow base-class. MainWindow and MainWindowBase are only split in two so we can share some c...
Definition: MainWindowBase.h:56
QVector
QStringList
KDDockWidgets::MainWindowOption_HasCentralFrame
@ MainWindowOption_HasCentralFrame
No option set
Definition: KDDockWidgets.h:57

© 2019-2022 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 Mon Mar 7 2022 02:01:20 for KDDockWidgets API Documentation by doxygen 1.8.20