KDDockWidgets API Documentation 2.1
Loading...
Searching...
No Matches
core/TitleBar.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#include "../core/Draggable_p.h"
16#include "kddockwidgets/docks_export.h"
17#include "DockWidget.h"
18
19namespace KDDockWidgets {
20namespace QtWidgets {
21class TitleBar;
22}
23}
24
25namespace KDDockWidgets::Core {
26
27class Group;
28class FloatingWindow;
29class TabBar;
30
31class DOCKS_EXPORT TitleBar : public Controller, public Draggable
32{
33 Q_OBJECT
34public:
36 explicit TitleBar(FloatingWindow *parent);
37
39 explicit TitleBar(Group *parent);
40
45 explicit TitleBar(Core::View *);
46
47 virtual ~TitleBar() override;
48
50 bool isMDI() const override;
51 std::unique_ptr<WindowBeingDragged> makeWindow() override;
52 bool isWindow() const override;
53 Core::DockWidget *singleDockWidget() const override final;
54
55 void setTitle(const QString &title);
56 QString title() const;
57
59 bool isFloating() const;
60
62 bool isStandalone() const;
63
66 DockWidget::List dockWidgets() const;
67
69 Icon icon() const;
70 void setIcon(const Icon &icon);
71
73 bool supportsFloatingButton() const;
74
76 bool supportsMaximizeButton() const;
77
79 bool supportsMinimizeButton() const;
80
82 bool supportsAutoHideButton() const;
83
84#ifdef DOCKS_TESTING_METHODS
86 bool isFloatButtonVisible() const;
87 bool isCloseButtonVisible() const;
88 bool isCloseButtonEnabled() const;
89#endif
90
92 bool hasIcon() const;
93
97 bool isFocused() const;
98
99 bool titleBarIsFocusable() const;
100
102 Core::Group *group() const;
103
105 FloatingWindow *floatingWindow() const;
106
110 MainWindow *mainWindow() const;
111
114 TabBar *tabBar() const;
115
118 void focus(Qt::FocusReason reason);
119
121 void updateButtons();
122 QString floatButtonToolTip() const;
123
124 bool onDoubleClicked();
125 void onCloseClicked();
126 void onFloatClicked();
127 void onMaximizeClicked();
128 void onMinimizeClicked();
129 void onAutoHideClicked();
130 void toggleMaximized();
131
132 // TODO: Refactor into a QHash<Button,State> ?
133 bool closeButtonEnabled() const;
134 void setCloseButtonVisible(bool);
135 bool floatButtonVisible() const;
136 bool maximizeButtonVisible() const;
137 void setCloseButtonEnabled(bool);
138 void setFloatButtonVisible(bool);
139
140 TitleBarButtonType maximizeButtonType() const;
141
143 void setUserHiddenButtons(TitleBarButtonTypes);
144 bool buttonIsUserHidden(TitleBarButtonType) const;
145
147 bool buttonIsUserHidden(TitleBarButtonType, bool enabled) const;
148
152 void setHideDisabledButtons(TitleBarButtonTypes);
153 bool buttonHidesIfDisabled(TitleBarButtonType) const;
154
155 class Private;
156 Private *dptr() const;
157
158protected:
159 bool isOverlayed() const;
160
161private:
162 friend class ::TestDocks;
163 friend class Core::Group;
165
166 void updateAutoHideButton();
167 void updateMaximizeButton();
168
169 void updateFloatButton();
170 void updateCloseButton();
171 bool supportsFloatUnfloat() const;
172 void setFloatButtonToolTip(const QString &);
173 void init();
174
175 Private *const d;
176
177 Point m_pressPos;
178 QString m_title;
179 Icon m_icon;
180
181 Core::Group *const m_group;
182 FloatingWindow *const m_floatingWindow;
183 const bool m_supportsAutoHide;
184 const bool m_isStandalone;
185 bool m_closeButtonEnabled = true;
186 bool m_closeButtonVisible = true;
187 bool m_floatButtonVisible = true;
188 bool m_maximizeButtonVisible = false;
189 TitleBarButtonType m_maximizeButtonType = TitleBarButtonType::Maximize;
190 QString m_floatButtonToolTip;
191};
192
193}
The DockWidget base-class. DockWidget and Core::DockWidget are only split in two so we can share some...
The MainWindow base-class. MainWindow and MainWindowBase are only split in two so we can share some c...
Class to abstract QAction, so code still works with QtQuick and Flutter.
TitleBarButtonType
describes a type of button you can have in the title bar
FocusReason
Represents a dock widget.

© 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