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
28
29class DOCKS_EXPORT TitleBar : public View<QWidget>,
31{
32 Q_OBJECT
33public:
36 explicit TitleBar(Core::TitleBar *controller, Core::View *parent = nullptr);
37
41 explicit TitleBar(QWidget *parent = nullptr);
42
43 ~TitleBar() override;
44
46 Core::TitleBar *titleBar() const;
47
48#ifdef DOCKS_DEVELOPER_MODE
49 // The following are needed for the unit-tests
50 bool isCloseButtonVisible() const override;
51 bool isCloseButtonEnabled() const override;
52 bool isFloatButtonVisible() const override;
53#endif
54
55Q_SIGNALS:
57
58protected:
59 void init() override final;
60 void paintEvent(QPaintEvent *) override;
61 void mouseDoubleClickEvent(QMouseEvent *) override;
62 QSize sizeHint() const override;
63 void focusInEvent(QFocusEvent *) override;
64
65 friend class KDDockWidgets::Core::TitleBar;
66 int buttonAreaWidth() const;
67 QRect iconRect() const;
68 void updateMargins();
69
70 void updateMaximizeButton(bool visible, bool enabled, TitleBarButtonType);
71 void updateAutoHideButton(bool visible, bool enabled, TitleBarButtonType);
72 void updateMinimizeButton(bool visible, bool enabled);
73
74 virtual bool hasCustomLayout() const
75 {
76 return false;
77 }
78
80 QAbstractButton *m_closeButton = nullptr;
81 QAbstractButton *m_floatButton = nullptr;
82 QAbstractButton *m_maximizeButton = nullptr;
83 QAbstractButton *m_minimizeButton = nullptr;
84 QAbstractButton *m_autoHideButton = nullptr;
85 QLabel *m_dockWidgetIcon = nullptr;
86
87private:
88 // Private class just to hide KDBindings usage
89 class Private;
90 Private *const d;
91};
92
96class Button : public QToolButton
97{
99public:
105
106 ~Button() override;
107
108protected:
109 QSize sizeHint() const override;
110 void paintEvent(QPaintEvent *) override;
111};
112
113}
114
115#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
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
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