DtkWidget 5.6.0.2
DTK Widget module
dmainwindow.h
1// SPDX-FileCopyrightText: 2017 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DMAINWINDOW_H
6#define DMAINWINDOW_H
7
8#include <dtkwidget_global.h>
9#include <DFloatingMessage>
10#include <DObject>
11
12#include <QMainWindow>
13#include <QPainterPath>
14
15DWIDGET_BEGIN_NAMESPACE
16
17class DMainWindowPrivate;
18class DTitlebar;
19
20class LIBDTKWIDGETSHARED_EXPORT DMainWindow : public QMainWindow, public DTK_CORE_NAMESPACE::DObject
21{
22 Q_OBJECT
23
24 Q_PROPERTY(int windowRadius READ windowRadius WRITE setWindowRadius NOTIFY windowRadiusChanged)
25 Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth NOTIFY borderWidthChanged)
26 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor NOTIFY borderColorChanged)
27 Q_PROPERTY(int shadowRadius READ shadowRadius WRITE setShadowRadius NOTIFY shadowRadiusChanged)
28 Q_PROPERTY(QPoint shadowOffset READ shadowOffset WRITE setShadowOffset NOTIFY shadowOffsetChanged)
29 Q_PROPERTY(QColor shadowColor READ shadowColor WRITE setShadowColor NOTIFY shadowColorChanged)
30 Q_PROPERTY(QPainterPath clipPath READ clipPath WRITE setClipPath NOTIFY clipPathChanged)
31 Q_PROPERTY(QRegion frameMask READ frameMask WRITE setFrameMask NOTIFY frameMaskChanged)
32 Q_PROPERTY(QMargins frameMargins READ frameMargins NOTIFY frameMarginsChanged)
33 Q_PROPERTY(bool translucentBackground READ translucentBackground WRITE setTranslucentBackground NOTIFY translucentBackgroundChanged)
34 Q_PROPERTY(bool enableSystemResize READ enableSystemResize WRITE setEnableSystemResize NOTIFY enableSystemResizeChanged)
35 Q_PROPERTY(bool enableSystemMove READ enableSystemMove WRITE setEnableSystemMove NOTIFY enableSystemMoveChanged)
36 Q_PROPERTY(bool enableBlurWindow READ enableBlurWindow WRITE setEnableBlurWindow NOTIFY enableBlurWindowChanged)
37 Q_PROPERTY(bool autoInputMaskByClipPath READ autoInputMaskByClipPath WRITE setAutoInputMaskByClipPath NOTIFY autoInputMaskByClipPathChanged)
38 Q_PROPERTY(bool titlebarShadowEnabled READ titlebarShadowIsEnabled WRITE setTitlebarShadowEnabled)
39
40public:
41 explicit DMainWindow(QWidget *parent = 0);
42
43 DTitlebar *titlebar() const;
44
45 bool isDXcbWindow() const;
46
47 int windowRadius() const;
48
49 int borderWidth() const;
50 QColor borderColor() const;
51
52 int shadowRadius() const;
53 QPoint shadowOffset() const;
54 QColor shadowColor() const;
55
56 QPainterPath clipPath() const;
57 QRegion frameMask() const;
58 QMargins frameMargins() const;
59
60 bool translucentBackground() const;
61 bool enableSystemResize() const;
62 bool enableSystemMove() const;
63 bool enableBlurWindow() const;
64 bool autoInputMaskByClipPath() const;
65
66 bool titlebarShadowIsEnabled() const;
67
68public Q_SLOTS:
69 void setWindowRadius(int windowRadius);
70
71 void setBorderWidth(int borderWidth);
72 void setBorderColor(const QColor &borderColor);
73
74 void setShadowRadius(int shadowRadius);
75 void setShadowOffset(const QPoint &shadowOffset);
76 void setShadowColor(const QColor &shadowColor);
77
78 void setClipPath(const QPainterPath &clipPath);
79 void setFrameMask(const QRegion &frameMask);
80
81 void setTranslucentBackground(bool translucentBackground);
82 void setEnableSystemResize(bool enableSystemResize);
83 void setEnableSystemMove(bool enableSystemMove);
84 void setEnableBlurWindow(bool enableBlurWindow);
85 void setAutoInputMaskByClipPath(bool autoInputMaskByClipPath);
86
87 // TODO: remove it if there is an batter sulotion
88#ifdef Q_OS_MAC
89 void setWindowFlags(Qt::WindowFlags type);
90#endif
91
92 void sendMessage(const QIcon &icon, const QString &message);
93 void sendMessage(DFloatingMessage *message);
94
95 void setTitlebarShadowEnabled(bool titlebarShadowEnabled);
96
97Q_SIGNALS:
98 void windowRadiusChanged();
99 void borderWidthChanged();
100 void borderColorChanged();
101 void shadowRadiusChanged();
102 void shadowOffsetChanged();
103 void shadowColorChanged();
104 void clipPathChanged();
105 void frameMaskChanged();
106 void frameMarginsChanged();
107 void translucentBackgroundChanged();
108 void enableSystemResizeChanged();
109 void enableSystemMoveChanged();
110 void enableBlurWindowChanged();
111 void autoInputMaskByClipPathChanged();
112
113protected:
114 DMainWindow(DMainWindowPrivate &dd, QWidget *parent = 0);
115 void mouseMoveEvent(QMouseEvent *event) override;
116 void resizeEvent(QResizeEvent *event) override;
117 void changeEvent(QEvent *event) override;
118
119private:
120 D_DECLARE_PRIVATE(DMainWindow)
121};
122
123DWIDGET_END_NAMESPACE
124
125#endif // DMAINWINDOW_H
一个浮动消息的类.
Definition: dfloatingmessage.h:18
Definition: dmainwindow_p.h:21
The DMainWindow class provides a main application window.
Definition: dmainwindow.h:21
The DTitlebar class is an universal title bar on the top of windows.
Definition: dtitlebar.h:20
typedef WindowFlags