KDDockWidgets API Documentation  1.5
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  {
76  Option_None = 0,
77  Option_NotClosable = 1,
78  Option_NotDockable = 2,
79  Option_DeleteOnClose = 4
80  };
81  Q_DECLARE_FLAGS(Options, Option)
82  Q_ENUM(Options);
83 
85  enum class LayoutSaverOption
86  {
87  None = 0,
88  Skip = 1,
89  };
90  Q_DECLARE_FLAGS(LayoutSaverOptions, LayoutSaverOption)
91 
92  enum class IconPlace
93  {
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 
266 
270  int tabIndex() const;
271 
280  void setIcon(const QIcon &icon, IconPlaces places = IconPlace::All);
281 
289  QIcon icon(IconPlace place = IconPlace::TitleBar) const;
290 
295  Q_INVOKABLE void forceClose();
296 
303  TitleBar *titleBar() const;
304 
309  Q_INVOKABLE bool isOpen() const;
310 
328  void setAffinities(const QStringList &);
329 
332  void setAffinityName(const QString &name);
333 
337  QStringList affinities() const;
338 
340  Q_INVOKABLE void show();
341 
349  Q_INVOKABLE void raise();
350 
361  bool isMainWindow() const;
362 
370  bool isInMainWindow() const;
371 
374  MainWindowBase *mainWindow() const;
375 
380  bool isFocused() const;
381 
391  Q_INVOKABLE void moveToSideBar();
392 
397  bool isOverlayed() const;
398 
403  SideBarLocation sideBarLocation() const;
404 
407  bool isInSideBar() const;
408 
413  bool hasPreviousDockedLocation() const;
414 
417  QSize lastOverlayedSize() const;
418 
419 
423  static DockWidgetBase *byName(const QString &uniqueName);
424 
426  bool skipsRestore() const;
427 
435  void setFloatingGeometry(QRect geo);
436 
441  void setUserType(int userType);
442  int userType() const;
443 
446  void setMDIPosition(QPoint pos);
448  void setMDISize(QSize size);
451  void setMDIZ(int z);
452 
455  bool isPersistentCentralDockWidget() const;
456 
457 Q_SIGNALS:
458 #ifdef KDDOCKWIDGETS_QTWIDGETS
459  void parentChanged();
462 #endif
463 
465  void shown();
466 
468  void hidden();
469 
471  void iconChanged();
472 
475  void titleChanged(const QString &title);
476 
479 
482  void optionsChanged(KDDockWidgets::DockWidgetBase::Options);
483 
486  void isFocusedChanged(bool);
487 
490  void isOverlayedChanged(bool);
491 
493  void isFloatingChanged(bool);
494 
498 
505  void windowActiveAboutToChange(bool activated);
506 
509 
512 
513 protected:
514  void onParentChanged();
515  void onShown(bool spontaneous);
516  void onHidden(bool spontaneous);
517 
518 #ifndef PYTHON_BINDINGS //Pyside bug: https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1327
519  void onCloseEvent(QCloseEvent *e) override;
520  bool onResize(QSize newSize) override;
521 #endif
522 
523 #if defined(DOCKS_DEVELOPER_MODE)
524 public:
525 #else
526 private:
527 #endif
528  Q_DISABLE_COPY(DockWidgetBase)
529  friend class MultiSplitter;
530  friend class LayoutWidget;
531  friend class MDILayoutWidget;
532  friend class Frame;
533  friend class DropArea;
534  friend class ::TestDocks;
535  friend class StateDragging;
536  friend class KDDockWidgets::TabWidget;
537  friend class KDDockWidgets::TitleBar;
538  friend class KDDockWidgets::DragController;
539  friend class KDDockWidgets::DockRegistry;
540  friend class KDDockWidgets::LayoutSaver;
542  friend class KDDockWidgets::FrameQuick;
544 
549  static DockWidgetBase *deserialize(const std::shared_ptr<LayoutSaver::DockWidget> &);
550 
551 
552  class Private;
553  Private *const d;
554 
555  Private *dptr() const;
556 };
557 
558 }
559 Q_DECLARE_METATYPE(KDDockWidgets::Location)
560 
561 #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:105
QWidget
KDDockWidgets::Location
Location
Definition: KDDockWidgets.h:45
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:86
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:211
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: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< 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:75
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 Mon Mar 7 2022 02:01:20 for KDDockWidgets API Documentation by doxygen 1.8.20