DtkWidget 5.6.0.2
DTK Widget module
dtitlebar.h
1// SPDX-FileCopyrightText: 2017 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DTITLEBAR_H
6#define DTITLEBAR_H
7
8#include <dtkwidget_global.h>
9#include <DObject>
10#include <DGuiApplicationHelper>
11
12#include <QFrame>
13#include <QMenu>
14
15DGUI_USE_NAMESPACE
16DWIDGET_BEGIN_NAMESPACE
17
18class DTitlebarPrivate;
19class LIBDTKWIDGETSHARED_EXPORT DTitlebar : public QFrame, public DTK_CORE_NAMESPACE::DObject
20{
21 Q_OBJECT
22 Q_PROPERTY(bool blurBackground READ blurBackground WRITE setBlurBackground)
23
24public:
25 explicit DTitlebar(QWidget *parent = Q_NULLPTR);
26
27#ifndef QT_NO_MENU
28 QMenu *menu() const;
29 void setMenu(QMenu *menu);
30#endif
31
32 QWidget *customWidget() const;
33 void setCustomWidget(QWidget *, bool fixCenterPos = false);
34
35 void addWidget(QWidget *w, Qt::Alignment alignment = Qt::Alignment());
36 void removeWidget(QWidget *w);
37
38 int buttonAreaWidth() const;
39 bool separatorVisible() const;
40
41 bool autoHideOnFullscreen() const;
42 void setAutoHideOnFullscreen(bool autohide);
43
44 virtual void setVisible(bool visible) Q_DECL_OVERRIDE;
45 void setEmbedMode(bool embed);
46
47 bool menuIsVisible() const;
48 void setMenuVisible(bool visible);
49
50 bool menuIsDisabled() const;
51 void setMenuDisabled(bool disabled);
52
53 bool quitMenuIsDisabled() const;
54 void setQuitMenuDisabled(bool disabled);
55 void setQuitMenuVisible(bool visible);
56
57 bool switchThemeMenuIsVisible() const;
58 void setSwitchThemeMenuVisible(bool visible);
59
60 void setDisableFlags(Qt::WindowFlags flags);
61 Qt::WindowFlags disableFlags() const;
62
63 void setSplitScreenEnabled(bool enabled);
64 bool splitScreenIsEnabled() const;
65
66 virtual QSize sizeHint() const override;
67 virtual QSize minimumSizeHint() const override;
68
69 bool blurBackground() const;
70 void setFullScreenButtonVisible(bool enabled);
71
72Q_SIGNALS:
73 void optionClicked();
74 void doubleClicked();
75 void mousePressed(Qt::MouseButtons buttons);
76 void mouseMoving(Qt::MouseButton button);
77
78#ifdef DTK_TITLE_DRAG_WINDOW
79 void mousePosPressed(Qt::MouseButtons buttons, QPoint pos);
80 void mousePosMoving(Qt::MouseButton button, QPoint pos);
81#endif
82
83public Q_SLOTS:
84 void setFixedHeight(int h);
85 void setBackgroundTransparent(bool transparent);
86 void setSeparatorVisible(bool visible);
87 void setTitle(const QString &title);
88 void setIcon(const QIcon &icon);
90 void toggleWindowState();
91
92 void setBlurBackground(bool blurBackground);
93
94private Q_SLOTS:
95#ifndef QT_NO_MENU
96 void showMenu();
97#endif
98
99protected:
100 bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE;
101 bool event(QEvent *e) override;
102 void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
103 void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
104 void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
105 void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
106 void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
107 void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
108
109private:
110 D_DECLARE_PRIVATE(DTitlebar)
111 D_PRIVATE_SLOT(void _q_toggleWindowState())
112 D_PRIVATE_SLOT(void _q_showMinimized())
113 D_PRIVATE_SLOT(void _q_onTopWindowMotifHintsChanged(quint32))
114
115#ifndef QT_NO_MENU
116 D_PRIVATE_SLOT(void _q_addDefaultMenuItems())
117 D_PRIVATE_SLOT(void _q_helpActionTriggered())
118 D_PRIVATE_SLOT(void _q_feedbackActionTriggerd())
119 D_PRIVATE_SLOT(void _q_aboutActionTriggered())
120 D_PRIVATE_SLOT(void _q_quitActionTriggered())
121 D_PRIVATE_SLOT(void _q_switchThemeActionTriggered(QAction*))
122#endif
123};
124
125DWIDGET_END_NAMESPACE
126
127#endif // DTITLEBAR_H
The DTitlebar class is an universal title bar on the top of windows.
Definition: dtitlebar.h:20
typedef Alignment
typedef MouseButtons
typedef WindowFlags