DtkWidget
DTK Widget module
载入中...
搜索中...
未找到
dgraphicsgloweffect.h
1// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DGRAPHICSGLOWEFFECT_H
6#define DGRAPHICSGLOWEFFECT_H
7
8#include <QGraphicsDropShadowEffect>
9#include <QGraphicsEffect>
10#include <QPainter>
11
12#include <dtkwidget_global.h>
13
14DWIDGET_BEGIN_NAMESPACE
15
16class LIBDTKWIDGETSHARED_EXPORT DGraphicsGlowEffect : public QGraphicsEffect
17{
18 Q_OBJECT
19public:
20 explicit DGraphicsGlowEffect(QObject *parent = nullptr);
21
22 void draw(QPainter *painter);
23 QRectF boundingRectFor(const QRectF &rect) const;
24
25 inline void setOffset(qreal dx, qreal dy) {m_xOffset = dx; m_yOffset = dy;}
26
27 inline void setXOffset(qreal dx) {m_xOffset = dx;}
28 inline qreal xOffset() const {return m_xOffset;}
29
30 inline void setYOffset(qreal dy) {m_yOffset = dy;}
31 inline qreal yOffset() const {return m_yOffset;}
32
33 inline void setDistance(qreal distance) { m_distance = distance; updateBoundingRect(); }
34 inline qreal distance() const { return m_distance; }
35
36 inline void setBlurRadius(qreal blurRadius) { m_blurRadius = blurRadius; updateBoundingRect(); }
37 inline qreal blurRadius() const { return m_blurRadius; }
38
39 inline void setColor(const QColor &color) { m_color = color; }
40 inline QColor color() const { return m_color; }
41
42 // TODO: refactor with d-pointer;
43 inline qreal opacity() const { return m_opacity; }
44 inline void setOpacity(qreal opacity) { m_opacity = opacity; }
45
46private:
47 qreal m_opacity = 1.0;
48 qreal m_xOffset;
49 qreal m_yOffset;
50 qreal m_distance;
51 qreal m_blurRadius;
52 QColor m_color;
53};
54
55DWIDGET_END_NAMESPACE
56
57#endif // DGRAPHICSGLOWEFFECT_H
控件发散效果,同时也是Dtk默认的窗口特效.
Definition dgraphicsgloweffect.h:17