KDDockWidgets API Documentation 1.7
Loading...
Searching...
No Matches
DockWidgetBase.h
Go to the documentation of this file.
1/*
2 This file is part of KDDockWidgets.
3
4 SPDX-FileCopyrightText: 2019-2023 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
32class TestDocks;
33
34namespace KDDockWidgets {
35
36class Frame;
37class FloatingWindow;
38class DragController;
39class DockRegistry;
40class LayoutSaver;
41class TabWidget;
42class TitleBar;
43class MainWindowBase;
44class StateDragging;
45class FrameQuick;
46class DockWidgetQuick;
47class LayoutWidget;
48
56#ifndef PYTHON_BINDINGS // Pyside bug: https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1327
57class DOCKS_EXPORT DockWidgetBase : public QWidgetAdapter
58#else
59class 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)
70public:
72
74 enum Option {
75 Option_None = 0,
76 Option_NotClosable = 1,
77 Option_NotDockable = 2,
78 Option_DeleteOnClose = 4,
79 Option_MDINestable = 8
82 };
83 Q_DECLARE_FLAGS(Options, Option)
84 Q_ENUM(Options)
85
86
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,
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
469 void setFloatingWindowFlags(FloatingWindowFlags);
470 KDDockWidgets::FloatingWindowFlags floatingWindowFlags() const;
471
472Q_SIGNALS:
473#ifdef KDDOCKWIDGETS_QTWIDGETS
477#endif
478
480 void shown();
481
483 void hidden();
484
487
490 void titleChanged(const QString &title);
491
494
497 void optionsChanged(KDDockWidgets::DockWidgetBase::Options);
498
502
506
509
513
520 void windowActiveAboutToChange(bool activated);
521
524
527
528protected:
529 void onParentChanged();
530 void onShown(bool spontaneous);
531 void onHidden(bool spontaneous);
532
533#ifndef PYTHON_BINDINGS // Pyside bug: https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1327
534 void onCloseEvent(QCloseEvent *e) override;
535 bool onResize(QSize newSize) override;
536#endif
537
538#if defined(DOCKS_DEVELOPER_MODE)
539public:
540#else
541private:
542#endif
543 Q_DISABLE_COPY(DockWidgetBase)
544 friend class MultiSplitter;
545 friend class LayoutWidget;
546 friend class MDILayoutWidget;
547 friend class FloatingWindow;
548 friend class Frame;
549 friend class DropArea;
550 friend class ::TestDocks;
551 friend class StateDragging;
552 friend class KDDockWidgets::TabWidget;
553 friend class KDDockWidgets::TitleBar;
554 friend class KDDockWidgets::DragController;
555 friend class KDDockWidgets::DockRegistry;
558 friend class KDDockWidgets::FrameQuick;
560
565 static DockWidgetBase *deserialize(const std::shared_ptr<LayoutSaver::DockWidget> &);
566
567
568 class Private;
569 Private *const d;
570
571 Private *dptr() const;
572};
573
574}
575Q_DECLARE_METATYPE(KDDockWidgets::Location)
576Q_DECLARE_METATYPE(KDDockWidgets::DockWidgetBase::List)
577
578#endif
File with KDDockWidgets namespace-level enums and methods.
Class to save and restore dockwidget layouts.
Abstraction for supporting both QtWidgets and QtQuick.
The DockWidget base-class. DockWidget and DockWidgetBase are only split in two so we can share some c...
void widgetChanged(KDDockWidgets::QWidgetOrQuick *)
emitted when the hosted widget changed
void optionsChanged(KDDockWidgets::DockWidgetBase::Options)
emitted when the options change
void parentChanged()
signal emitted when the parent changed QtQuick already has QQuickItem::parentChanged(),...
void aboutToDeleteOnClose()
Emitted when this dock widget is about to be deleted due to Option_DeleteOnClose.
void shown()
signal emitted when the DockWidget is shown. As in QEvent::Show.
void isFocusedChanged(bool)
emitted when isFocused changes
void windowActiveAboutToChange(bool activated)
Emitted when the top-level window this dock widget is in is activated or deactivated This is convenie...
void isFloatingChanged(bool)
emitted when isFloating changes
LayoutSaverOption
Options which will affect LayoutSaver save/restore.
void isOverlayedChanged(bool)
emitted when isOverlayed changes
void hidden()
signal emitted when the DockWidget is hidden. As in QEvent::Hide.
void actualTitleBarChanged()
Emitted when the title bar that serves this dock widget changes.
Option
DockWidget options to pass at construction time.
void removedFromSideBar()
emitted when this dock widget is removed from a side-bar. Only relevant for the auto-hide/sidebar fea...
void titleChanged(const QString &title)
signal emitted when the title changed
void iconChanged()
signal emitted when the icon changed
Represents a dock widget.
Represents a dock widget.
Definition DockWidget.h:38
LayoutSaver allows to save or restore layouts.
Definition LayoutSaver.h:55
The MainWindow base-class. MainWindow and MainWindowBase are only split in two so we can share some c...
QWidget QWidgetOrQuick
SideBarLocation
Each main window supports 4 sidebars.
@ None
Don't show any drop indicators while dragging.
Struct describing the preferred dock widget size and visibility when adding it to a layout.

© 2019-2023 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 Wed Nov 1 2023 00:02:31 for KDDockWidgets API Documentation by doxygen 1.9.8