KDDockWidgets API Documentation 2.1
Loading...
Searching...
No Matches
core/FloatingWindow.h
Go to the documentation of this file.
1/*
2 This file is part of KDDockWidgets.
3
4 SPDX-FileCopyrightText: 2020 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#pragma once
13
14#include "Controller.h"
15
16#include "kddockwidgets/KDDockWidgets.h"
17#include "kddockwidgets/docks_export.h"
18#include "kddockwidgets/LayoutSaver.h"
19#include "Group.h"
20#include "kddockwidgets/QtCompat_p.h"
21#include "kddockwidgets/core/Draggable_p.h"
22
23QT_BEGIN_NAMESPACE
25QT_END_NAMESPACE
26
27namespace KDDockWidgets::Core {
28
29class DropArea;
30class Group;
31class Layout;
32class MainWindow;
33class TitleBar;
34
35class DOCKS_EXPORT FloatingWindow : public Controller, public Draggable
36{
37 Q_OBJECT
38public:
39 explicit FloatingWindow(
40 Rect suggestedGeometry, MainWindow *parent = nullptr,
41 FloatingWindowFlags requestedFlags = FloatingWindowFlag::FromGlobalConfig);
42 explicit FloatingWindow(Core::Group *group, Rect suggestedGeometry,
43 MainWindow *parent = nullptr);
44 virtual ~FloatingWindow() override;
45
46 bool deserialize(const LayoutSaver::FloatingWindow &);
47 LayoutSaver::FloatingWindow serialize() const;
48
49 // Draggable:
50 std::unique_ptr<WindowBeingDragged> makeWindow() override;
51 Core::DockWidget *singleDockWidget() const override final;
52 bool isWindow() const override;
53
54 Vector<DockWidget *> dockWidgets() const;
55 Core::Group::List groups() const;
56 DropArea *dropArea() const;
57
58 int userType() const;
59
62 bool isUtilityWindow() const;
63
64 static void ensureRectIsOnScreen(Rect &geometry);
65
66#ifdef KDDW_FRONTEND_QT_WINDOWS
67 void setLastHitTest(int hitTest)
68 {
69 m_lastHitTest = hitTest;
70 }
71#endif
78 {
79 return m_titleBar;
80 }
81
90 void setSuggestedGeometry(Rect suggestedRect,
91 SuggestedGeometryHints = SuggestedGeometryHint_None);
92
93 bool anyNonClosable() const;
94 bool anyNonDockable() const;
95
103 bool hasSingleGroup() const;
104
111 bool hasSingleDockWidget() const;
112
114 Core::Group *singleFrame() const;
115
119 bool beingDeleted() const;
120
124 void scheduleDeleteLater();
125
129 Core::DropArea *multiSplitter() const;
130
134 Layout *layout() const;
135
140 bool isInDragArea(Point globalPoint) const;
141
142 bool isMDI() const override;
143
145 void updateTitleAndIcon();
146 void updateTitleBarVisibility();
147
148 Vector<QString> affinities() const;
149
155 Rect dragRect() const;
156
158 bool allDockWidgetsHave(DockWidgetOption) const;
159
161 bool anyDockWidgetsHas(DockWidgetOption) const;
162
164 bool allDockWidgetsHave(LayoutSaverOption) const;
165
167 bool anyDockWidgetsHas(LayoutSaverOption) const;
168
170 void addDockWidget(DockWidget *, KDDockWidgets::Location location, DockWidget *relativeTo,
171 const InitialOption & = {});
172
176 MainWindow *mainWindow() const;
177
179 Margins contentMargins() const;
180
181 // The state reported by QWidget is not always the same as what the
182 // window manager thinks, due to the async nature. This method
183 // returns the last state reported by the window manager itself.
184 WindowState lastWindowManagerState() const;
185 void setLastWindowManagerState(WindowState);
186
192
194 bool supportsMinimizeButton() const;
195
197 bool supportsMaximizeButton() const;
198
199 void maybeCreateResizeHandler();
201 FloatingWindowFlags floatingWindowFlags() const;
202
203 void focus(Qt::FocusReason reason);
204
205 class Private;
206 Private *dptr() const;
207
208private:
209 Private *const d;
210
211protected:
213 WindowState m_lastWindowManagerState = WindowState::None;
214
215private:
217 Size maxSizeHint() const;
218 void onFrameCountChanged(int count);
219 void onVisibleFrameCountChanged(int count);
220 void onCloseEvent(CloseEvent *);
221 void updateSizeConstraints();
222
223 bool m_disableSetVisible = false;
224 bool m_deleteScheduled = false;
225 bool m_inDtor = false;
226 bool m_updatingTitleBarVisibility = false;
227 WindowState windowStateOverride() const;
228#ifdef KDDW_FRONTEND_QT_WINDOWS
229 QAbstractNativeEventFilter *m_nchittestFilter = nullptr;
230 int m_lastHitTest = 0;
231#endif
232};
233
234}
#define KDDW_DELETE_COPY_CTOR(NAME)
The DockWidget base-class. DockWidget and Core::DockWidget are only split in two so we can share some...
static Qt::WindowFlags s_windowFlagsOverride
Allows the user app to specify which window flags to use, instead of KDDWs default ones Bugs caused b...
Core::TitleBar * titleBar() const
Returns the title bar.
The widget (QWidget or QQuickItem) which holds a layout of dock widgets.
Definition Layout.h:57
The MainWindow base-class. MainWindow and MainWindowBase are only split in two so we can share some c...
DockWidgetOption
DockWidget options to pass at construction time.
LayoutSaverOption
Options which will affect LayoutSaver save/restore.
FocusReason
typedef WindowFlags
Struct describing the preferred dock widget size and visibility when adding it to a layout.

© 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 by doxygen 1.9.8