KDDockWidgets API Documentation 2.1
Loading...
Searching...
No Matches
qtquick/views/TitleBar.cpp
Go to the documentation of this file.
1/*
2 This file is part of KDDockWidgets.
3
4 SPDX-FileCopyrightText: 2019 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#include "TitleBar.h"
13
14#include "core/DragController_p.h"
15
16#include "kddockwidgets/core/Group.h"
17#include "kddockwidgets/core/FloatingWindow.h"
18#include "kddockwidgets/core/TitleBar.h"
19
20#include "core/Logging_p.h"
21#include "core/WindowBeingDragged_p.h"
22#include "core/Utils_p.h"
23#include "core/TitleBar_p.h"
24
25using namespace KDDockWidgets;
26using namespace KDDockWidgets::QtQuick;
27
28
29TitleBar::TitleBar(Core::TitleBar *controller, QQuickItem *parent)
30 : View(controller, Core::ViewType::TitleBar, parent)
31 , Core::TitleBarViewInterface(controller)
32{
34}
35
39
41{
42 // QML interface signals
43 m_titleBar->dptr()->titleChanged.connect([this] { titleChanged(); });
44 m_titleBar->dptr()->iconChanged.connect([this] { iconChanged(); });
45 m_titleBar->dptr()->isFocusedChanged.connect([this] { isFocusedChanged(); });
46
47 // close button visibility not supported for QtQuick yet
48 m_titleBar->dptr()->closeButtonChanged.connect([this](bool /*visible*/, bool enabled) { closeButtonEnabledChanged(enabled); });
49
50 m_titleBar->dptr()->floatButtonVisibleChanged.connect([this](bool visible) { floatButtonVisibleChanged(visible); });
51 m_titleBar->dptr()->floatButtonToolTipChanged.connect([this](const QString &text) { floatButtonToolTipChanged(text); });
52 m_titleBar->dptr()->numDockWidgetsChanged.connect([this] { numDockWidgetsChanged(); });
53 m_titleBar->dptr()->maximizeButtonChanged.connect([this](bool visible) { maximizeButtonVisibleChanged(visible); });
54 m_titleBar->dptr()->minimizeButtonChanged.connect([this](bool visible) { minimizeButtonVisibleChanged(visible); });
55}
56
58{
60 if (ev->type() == QEvent::MouseButtonPress) {
61 // Core::TitleBar will forward focus to the correct group
63 }
64 }
65
66 return QtQuick::View::event(ev);
67}
68
69#ifdef DOCKS_DEVELOPER_MODE
70
71bool TitleBar::isCloseButtonEnabled() const
72{
73 if (QQuickItem *button = closeButton())
74 return button->isEnabled();
75 return false;
76}
77
78bool TitleBar::isCloseButtonVisible() const
79{
80 if (QQuickItem *button = closeButton())
81 return button->isVisible();
82
83 return true;
84}
85
86bool TitleBar::isFloatButtonVisible() const
87{
88 if (QQuickItem *button = floatButton())
89 return button->isVisible();
90
91 return true;
92}
93
94#endif
95
96QQuickItem *TitleBar::titleBarQmlItem() const
97{
98 return m_titleBarQmlItem;
99}
100
102{
103 if (m_titleBarQmlItem)
104 return m_titleBarQmlItem->property("mouseAreaForTests").value<QQuickItem *>();
105
106 return nullptr;
107}
108
109void TitleBar::setTitleBarQmlItem(QQuickItem *item)
110{
111 if (item != m_titleBarQmlItem) {
112 m_titleBarQmlItem = item;
113 Q_EMIT titleBarQmlItemChanged();
114 }
115}
116
117QQuickItem *TitleBar::floatButton() const
118{
119 return m_titleBarQmlItem ? m_titleBarQmlItem->property("floatButton").value<QQuickItem *>()
120 : nullptr;
121}
122
123QQuickItem *TitleBar::closeButton() const
124{
125 return m_titleBarQmlItem ? m_titleBarQmlItem->property("closeButton").value<QQuickItem *>()
126 : nullptr;
127}
128
130{
131 return m_titleBar->isFocused();
132}
133
135{
137}
138
143
148
153
155{
157}
158
163
165{
166 return m_titleBar->hasIcon();
167}
168
170{
171 return m_titleBar->title();
172}
173
178
183
188
193
198
203
208
213
218
220{
221 return m_titleBar->isFloating();
222}
223
225{
228}
static Config & self()
returns the singleton Config instance
Definition Config.cpp:88
bool isFocused() const
returns whether any of the DockWidgets this TitleBar controls has a child focus Not to be confused wi...
bool supportsMinimizeButton() const
returns whether this title bar supports a minimize button
TitleBarButtonType maximizeButtonType() const
void focus(Qt::FocusReason reason)
bool isFloating() const
Returns true if this title-bar is the title bar of a floating window.
bool hasIcon() const
returns whether this title bar has an icon
virtual bool is(ViewType) const
Returns whether the view is of the specified type Virtual so it can be overridden by ViewWrapper....
Q_INVOKABLE void toggleMaximized()
These 2 are the same, both just toggle window maximization.
void floatButtonToolTipChanged(const QString &)
Q_INVOKABLE bool isMaximized() const override
void numDockWidgetsChanged()
Emitted when the number of dock widgets under this titlebar changes.
TitleBar(Core::TitleBar *controller, QQuickItem *parent=nullptr)
Qt::WindowFlags flags() const override
Class to abstract QAction, so code still works with QtQuick and Flutter.
MouseButtonPress
QEvent::Type type() const const
MouseFocusReason

© 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