DtkWidget
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
15
16DWIDGET_BEGIN_NAMESPACE
17
18DGUI_USE_NAMESPACE
19
20class DSidebarHelper;
21class DTitlebarSettings;
22class DTitlebarPrivate;
23class LIBDTKWIDGETSHARED_EXPORT DTitlebar : public QFrame, public DTK_CORE_NAMESPACE::DObject
24{
25 Q_OBJECT
26 Q_PROPERTY(bool blurBackground READ blurBackground WRITE setBlurBackground)
27
28public:
29 explicit DTitlebar(QWidget *parent = Q_NULLPTR);
30
31#ifndef QT_NO_MENU
32 QMenu *menu() const;
33 void setMenu(QMenu *menu);
34#endif
35
36 QWidget *customWidget() const;
37 void setCustomWidget(QWidget *, bool fixCenterPos = false);
38
39 void setSidebarHelper(DSidebarHelper *helper);
40
41 void addWidget(QWidget *w, Qt::Alignment alignment = Qt::Alignment());
42 void removeWidget(QWidget *w);
43
44 int buttonAreaWidth() const;
45 bool separatorVisible() const;
46
47 bool autoHideOnFullscreen() const;
48 void setAutoHideOnFullscreen(bool autohide);
49
50 virtual void setVisible(bool visible) Q_DECL_OVERRIDE;
51 void setEmbedMode(bool embed);
52
53 bool menuIsVisible() const;
54 void setMenuVisible(bool visible);
55
56 bool menuIsDisabled() const;
57 void setMenuDisabled(bool disabled);
58
59 bool quitMenuIsDisabled() const;
60 void setQuitMenuDisabled(bool disabled);
61 void setQuitMenuVisible(bool visible);
62
63 bool switchThemeMenuIsVisible() const;
64 void setSwitchThemeMenuVisible(bool visible);
65
66 void setDisableFlags(Qt::WindowFlags flags);
67 Qt::WindowFlags disableFlags() const;
68
69 void setSplitScreenEnabled(bool enabled);
70 bool splitScreenIsEnabled() const;
71
72 virtual QSize sizeHint() const override;
73 virtual QSize minimumSizeHint() const override;
74
75 bool blurBackground() const;
76 void setFullScreenButtonVisible(bool enabled);
77
78 DTitlebarSettings *settings();
79
80Q_SIGNALS:
81 void optionClicked();
82 void doubleClicked();
83 void mousePressed(Qt::MouseButtons buttons);
84 void mouseMoving(Qt::MouseButton button);
85
86#ifdef DTK_TITLE_DRAG_WINDOW
87 void mousePosPressed(Qt::MouseButtons buttons, QPoint pos);
88 void mousePosMoving(Qt::MouseButton button, QPoint pos);
89#endif
90
91public Q_SLOTS:
92 void setFixedHeight(int h);
93 void setBackgroundTransparent(bool transparent);
94 void setSeparatorVisible(bool visible);
95 void setTitle(const QString &title);
96 void setIcon(const QIcon &icon);
98 void toggleWindowState();
99
100 void setBlurBackground(bool blurBackground);
101
102private Q_SLOTS:
103#ifndef QT_NO_MENU
104 void showMenu();
105#endif
106
107protected:
108 bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE;
109 bool event(QEvent *e) override;
110 void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
111 void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
112 void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
113 void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
114 void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
115 void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
116
117private:
118 D_DECLARE_PRIVATE(DTitlebar)
119 D_PRIVATE_SLOT(void _q_toggleWindowState())
120 D_PRIVATE_SLOT(void _q_showMinimized())
121 D_PRIVATE_SLOT(void _q_onTopWindowMotifHintsChanged(quint32))
122
123#ifndef QT_NO_MENU
124 D_PRIVATE_SLOT(void _q_addDefaultMenuItems())
125 D_PRIVATE_SLOT(void _q_helpActionTriggered())
126 D_PRIVATE_SLOT(void _q_feedbackActionTriggered())
127 D_PRIVATE_SLOT(void _q_aboutActionTriggered())
128 D_PRIVATE_SLOT(void _q_quitActionTriggered())
129 D_PRIVATE_SLOT(void _q_switchThemeActionTriggered(QAction*))
130 D_PRIVATE_SLOT(void _q_toolBarActionTriggered())
131#endif
132};
133
134DWIDGET_END_NAMESPACE
135
136#endif // DTITLEBAR_H
Definition dmainwindow_p.h:20
Definition dtitlebarsettings.h:49
Dtitlebar是Dtk程序通用的标题栏组件,用于实现标题栏的高度定制化
Definition dtitlebar.h:24