KDDockWidgets API Documentation 2.0
Loading...
Searching...
No Matches
qtwidgets/views/TitleBar.h
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#ifndef KD_TITLEBAR_QTWIDGETS_H
13#define KD_TITLEBAR_QTWIDGETS_H
14
15#pragma once
16
17#include "View.h"
18#include "kddockwidgets/core/views/TitleBarViewInterface.h"
19
20#include <QToolButton>
21
22QT_BEGIN_NAMESPACE
23class QHBoxLayout;
24class QLabel;
25QT_END_NAMESPACE
26
27
28class TestQtWidgets;
29
31
32class DOCKS_EXPORT TitleBar : public View<QWidget>,
34{
35 Q_OBJECT
36public:
39 explicit TitleBar(Core::TitleBar *controller, Core::View *parent = nullptr);
40
44 explicit TitleBar(QWidget *parent = nullptr);
45
46 ~TitleBar() override;
47
49 Core::TitleBar *titleBar() const;
50
51#ifdef DOCKS_DEVELOPER_MODE
52 // The following are needed for the unit-tests
53 bool isCloseButtonVisible() const override;
54 bool isCloseButtonEnabled() const override;
55 bool isFloatButtonVisible() const override;
56#endif
57
58Q_SIGNALS:
60
61protected:
62 void init() override;
63 void paintEvent(QPaintEvent *) override;
64 void mouseDoubleClickEvent(QMouseEvent *) override;
65 QSize sizeHint() const override;
66 void focusInEvent(QFocusEvent *) override;
67
69 int buttonAreaWidth() const;
70 QRect iconRect() const;
71 void updateMargins();
72
73 void updateMaximizeButton(bool visible, bool enabled, TitleBarButtonType);
74 void updateAutoHideButton(bool visible, bool enabled, TitleBarButtonType);
75 void updateMinimizeButton(bool visible, bool enabled);
76
77 virtual bool hasCustomLayout() const
78 {
79 return false;
80 }
81
83 QAbstractButton *m_closeButton = nullptr;
84 QAbstractButton *m_floatButton = nullptr;
85 QAbstractButton *m_maximizeButton = nullptr;
86 QAbstractButton *m_minimizeButton = nullptr;
87 QAbstractButton *m_autoHideButton = nullptr;
88 QLabel *m_dockWidgetIcon = nullptr;
89
90private:
91 friend class ::TestQtWidgets;
92 // Private class just to hide KDBindings usage
93 class Private;
94 Private *const d;
95};
96
100class Button : public QToolButton
101{
103public:
109
110 ~Button() override;
111
112protected:
114
115 bool event(QEvent *ev) override;
116 QSize sizeHint() const override;
117 void paintEvent(QPaintEvent *) override;
118
119 bool m_inEventHandler = false;
120};
121
122}
123
124#endif
The interface that TitleBar views should implement.
Button widget to be used in the TitleBar. These are the KDDockWidget default buttons....
void paintEvent(QPaintEvent *) override
TitleBarButtonType
describes a type of button you can have in the title bar
Q_OBJECTQ_OBJECT
QObject * parent() const const
void setSizePolicy(QSizePolicy)

© 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