KDDockWidgets API Documentation  1.6
DockWidgetBase.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 
19 #ifndef KD_DOCKWIDGET_BASE_H
20 #define KD_DOCKWIDGET_BASE_H
21 
22 #include "docks_export.h"
23 #include "KDDockWidgets.h"
24 #include "QWidgetAdapter.h"
25 #include "LayoutSaver.h"
26 
27 #include <QVector>
28 #include <memory>
29 
30 // clazy:excludeall=ctor-missing-parent-argument
31 
32 class TestDocks;
33 
34 namespace KDDockWidgets {
35 
36 class Frame;
37 class FloatingWindow;
38 class DragController;
39 class DockRegistry;
40 class LayoutSaver;
41 class TabWidget;
42 class TitleBar;
43 class MainWindowBase;
44 class StateDragging;
45 class FrameQuick;
46 class DockWidgetQuick;
47 class LayoutWidget;
48 
56 #ifndef PYTHON_BINDINGS // Pyside bug: https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1327
57 class DOCKS_EXPORT DockWidgetBase : public QWidgetAdapter
58 #else
59 class DOCKS_EXPORT DockWidgetBase : public QWidget
60 #endif
61 {
62  Q_OBJECT
63  Q_PROPERTY(bool isFocused READ isFocused NOTIFY isFocusedChanged)
64  Q_PROPERTY(bool isFloating READ isFloating WRITE setFloating NOTIFY isFloatingChanged)
65  Q_PROPERTY(QString uniqueName READ uniqueName CONSTANT)
66  Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
67  Q_PROPERTY(QObject *widget READ widget NOTIFY widgetChanged)
68  Q_PROPERTY(KDDockWidgets::DockWidgetBase::Options options READ options WRITE setOptions NOTIFY
69  optionsChanged)
70 public:
72 
74  enum Option {
75  Option_None = 0,
76  Option_NotClosable = 1,
77  Option_NotDockable = 2,
78  Option_DeleteOnClose = 4,
79  Option_MDINestable = 8
80  };
83  Q_DECLARE_FLAGS(Options, Option)
84  Q_ENUM(Options);
85 
87  enum class LayoutSaverOption {
88  None = 0,
89  Skip = 1,
90  };
91  Q_DECLARE_FLAGS(LayoutSaverOptions, LayoutSaverOption)
92 
93  enum class IconPlace {
94  TitleBar = 1,
95  TabBar = 2,
96  ToggleAction = 4,
97  All = ToggleAction | TitleBar | TabBar
98  };
99  Q_ENUM(IconPlace)
100  Q_DECLARE_FLAGS(IconPlaces, IconPlace)
101 
102 
111  explicit DockWidgetBase(const QString &uniqueName,
112  Options options = KDDockWidgets::DockWidgetBase::Options(),
113  LayoutSaverOptions layoutSaverOptions = KDDockWidgets::DockWidgetBase::LayoutSaverOptions());
114 
116  ~DockWidgetBase() override;
117 
126  Q_INVOKABLE void addDockWidgetAsTab(KDDockWidgets::DockWidgetBase *other,
127  KDDockWidgets::InitialOption initialOption = {});
128 
141  Q_INVOKABLE void
142  addDockWidgetToContainingWindow(KDDockWidgets::DockWidgetBase *other,
143  KDDockWidgets::Location location,
144  KDDockWidgets::DockWidgetBase *relativeTo = nullptr,
145  KDDockWidgets::InitialOption initialOption = {});
146 
156  virtual void setWidget(QWidgetOrQuick *widget);
157 
161  QWidgetOrQuick *widget() const;
162 
170  bool isFloating() const;
171 
178  bool setFloating(bool floats);
179 
184  Q_INVOKABLE QAction *toggleAction() const;
185 
190  Q_INVOKABLE QAction *floatAction() const;
191 
196  QString uniqueName() const;
197 
203  QString title() const;
204 
210  void setTitle(const QString &title);
211 
222  QRect frameGeometry() const;
223 
228  Options options() const;
229 
232  KDDockWidgets::DockWidgetBase::LayoutSaverOptions layoutSaverOptions() const;
233 
241  void setOptions(Options);
242 
251  bool isTabbed() const;
252 
259  bool isCurrentTab() const;
260 
264  Q_INVOKABLE void setAsCurrentTab();
265 
271  int tabIndex() const;
272 
276  int currentTabIndex() const;
277 
286  void setIcon(const QIcon &icon, IconPlaces places = IconPlace::All);
287 
295  QIcon icon(IconPlace place = IconPlace::TitleBar) const;
296 
301  Q_INVOKABLE void forceClose();
302 
309  TitleBar *titleBar() const;
310 
315  Q_INVOKABLE bool isOpen() const;
316 
334  void setAffinities(const QStringList &);
335 
338  void setAffinityName(const QString &name);
339 
343  QStringList affinities() const;
344 
346  Q_INVOKABLE void show();
347 
355  Q_INVOKABLE void raise();
356 
367  bool isMainWindow() const;
368 
376  bool isInMainWindow() const;
377 
380  MainWindowBase *mainWindow() const;
381 
386  bool isFocused() const;
387 
397  Q_INVOKABLE void moveToSideBar();
398 
403  bool isOverlayed() const;
404 
409  SideBarLocation sideBarLocation() const;
410 
413  bool isInSideBar() const;
414 
419  bool hasPreviousDockedLocation() const;
420 
423  QSize lastOverlayedSize() const;
424 
425 
429  static DockWidgetBase *byName(const QString &uniqueName);
430 
432  bool skipsRestore() const;
433 
441  void setFloatingGeometry(QRect geo);
442 
447  void setUserType(int userType);
448  int userType() const;
449 
452  void setMDIPosition(QPoint pos);
454  void setMDISize(QSize size);
457  void setMDIZ(int z);
458 
461  bool isPersistentCentralDockWidget() const;
462 
463 Q_SIGNALS:
464 #ifdef KDDOCKWIDGETS_QTWIDGETS
465  void parentChanged();
468 #endif
469 
471  void shown();
472 
474  void hidden();
475 
477  void iconChanged();
478 
481  void titleChanged(const QString &title);
482 
485 
488  void optionsChanged(KDDockWidgets::DockWidgetBase::Options);
489 
492  void isFocusedChanged(bool);
493 
496  void isOverlayedChanged(bool);
497 
499  void isFloatingChanged(bool);
500 
504 
511  void windowActiveAboutToChange(bool activated);
512 
515 
518 
519 protected:
520  void onParentChanged();
521  void onShown(bool spontaneous);
522  void onHidden(bool spontaneous);
523 
524 #ifndef PYTHON_BINDINGS // Pyside bug: https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1327
525  void onCloseEvent(QCloseEvent *e) override;
526  bool onResize(QSize newSize) override;
527 #endif
528 
529 #if defined(DOCKS_DEVELOPER_MODE)
530 public:
531 #else
532 private:
533 #endif
534  Q_DISABLE_COPY(DockWidgetBase)
535  friend class MultiSplitter;
536  friend class LayoutWidget;
537  friend class MDILayoutWidget;
538  friend class FloatingWindow;
539  friend class Frame;
540  friend class DropArea;
541  friend class ::TestDocks;
542  friend class StateDragging;
543  friend class KDDockWidgets::TabWidget;
544  friend class KDDockWidgets::TitleBar;
545  friend class KDDockWidgets::DragController;
546  friend class KDDockWidgets::DockRegistry;
547  friend class KDDockWidgets::LayoutSaver;
549  friend class KDDockWidgets::FrameQuick;
551 
556  static DockWidgetBase *deserialize(const std::shared_ptr<LayoutSaver::DockWidget> &);
557 
558 
559  class Private;
560  Private *const d;
561 
562  Private *dptr() const;
563 };
564 
565 }
566 Q_DECLARE_METATYPE(KDDockWidgets::Location)
567 
568 #endif
KDDockWidgets::DockWidgetBase::optionsChanged
void optionsChanged(KDDockWidgets::DockWidgetBase::Options)
emitted when the options change
KDDockWidgets::DockWidgetBase::aboutToDeleteOnClose
void aboutToDeleteOnClose()
Emitted when this dock widget is about to be deleted due to Option_DeleteOnClose.
LayoutSaver.h
Class to save and restore dockwidget layouts.
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::DockWidgetBase::iconChanged
void iconChanged()
signal emitted when the icon changed
KDDockWidgets::DockWidgetBase::widgetChanged
void widgetChanged(KDDockWidgets::QWidgetOrQuick *)
emitted when the hosted widget changed
QSize
KDDockWidgets::DockWidgetQuick
Represents a dock widget.
Definition: DockWidgetQuick.h:40
KDDockWidgets::DropIndicatorType::Classic
@ Classic
The default.
QWidgetAdapter.h
Abstraction for supporting both QtWidgets and QtQuick.
KDDockWidgets::DockWidgetBase::isFloatingChanged
void isFloatingChanged(bool)
emitted when isFloating changes
KDDockWidgets::DockWidgetBase::titleChanged
void titleChanged(const QString &title)
signal emitted when the title changed
KDDockWidgets::LayoutSaver
LayoutSaver allows to save or restore layouts.
Definition: LayoutSaver.h:55
QCloseEvent
QObject
KDDockWidgets::DockWidget
Represents a dock widget.
Definition: DockWidget.h:38
KDDockWidgets::DockWidgetBase::List
QVector< DockWidgetBase * > List
Definition: DockWidgetBase.h:71
QString
KDDockWidgets::DockWidgetBase::LayoutSaverOption
LayoutSaverOption
Options which will affect LayoutSaver save/restore.
Definition: DockWidgetBase.h:87
KDDockWidgets::DockWidgetBase::IconPlace
IconPlace
Definition: DockWidgetBase.h:93
KDDockWidgets::DockWidgetBase::isFocusedChanged
void isFocusedChanged(bool)
emitted when isFocused changes
KDDockWidgets::DockWidgetBase::actualTitleBarChanged
void actualTitleBarChanged()
Emitted when the title bar that serves this dock widget changes.
QIcon
KDDockWidgets::SideBarLocation
SideBarLocation
Each main window supports 4 sidebars.
Definition: KDDockWidgets.h:208
KDDockWidgets::DockWidgetBase::removedFromSideBar
void removedFromSideBar()
emitted when this dock widget is removed from a side-bar. Only relevant for the auto-hide/sidebar fea...
KDDockWidgets::QWidgetOrQuick
QWidget QWidgetOrQuick
Definition: QWidgetAdapter.h:45
KDDockWidgets::DockWidgetBase
The DockWidget base-class. DockWidget and DockWidgetBase are only split in two so we can share some c...
Definition: DockWidgetBase.h:61
QAction
KDDockWidgets::DockWidgetBase::hidden
void hidden()
signal emitted when the DockWidget is hidden. As in QEvent::Hide.
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< DockWidgetBase * >
KDDockWidgets::DockWidgetBase::shown
void shown()
signal emitted when the DockWidget is shown. As in QEvent::Show.
KDDockWidgets::DockWidgetBase::Option
Option
DockWidget options to pass at construction time.
Definition: DockWidgetBase.h:74
KDDockWidgets::DockWidgetBase::windowActiveAboutToChange
void windowActiveAboutToChange(bool activated)
Emitted when the top-level window this dock widget is in is activated or deactivated This is convenie...
QPoint
QStringList
KDDockWidgets::DockWidgetBase::isOverlayedChanged
void isOverlayedChanged(bool)
emitted when isOverlayed changes

© 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:27 for KDDockWidgets API Documentation by doxygen 1.8.20