KDDockWidgets API Documentation  1.6
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  Q_PROPERTY(int overlayMargin READ overlayMargin WRITE setOverlayMargin NOTIFY overlayMarginChanged)
63 public:
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 
233 protected:
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;
245  virtual QRect centralAreaGeometry() const
246  {
247  return {};
248  }
249 
250 Q_SIGNALS:
252 
256  void frameCountChanged(int);
257 
259 
260 private:
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
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:101
QWidget
KDDockWidgets::Location
Location
Definition: KDDockWidgets.h:44
KDDockWidgets::MainWindowBase::centralAreaGeometry
virtual QRect centralAreaGeometry() const
Definition: MainWindowBase.h:245
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
QCloseEvent
QString
KDDockWidgets::MainWindowBase::uniqueNameChanged
void uniqueNameChanged()
KDDockWidgets::MainWindowBase::List
QVector< MainWindowBase * > List
Definition: MainWindowBase.h:64
KDDockWidgets::MainWindowBase::overlayMarginChanged
void overlayMarginChanged(int)
QMargins
KDDockWidgets::SideBarLocation
SideBarLocation
Each main window supports 4 sidebars.
Definition: KDDockWidgets.h:208
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:37
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:55

© 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 Thu Sep 15 2022 00:16:29 for KDDockWidgets API Documentation by doxygen 1.8.20