DtkWidget 5.6.0.2
DTK Widget module
darrowrectangle.h
1// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DARROWRECTANGLE_H
6#define DARROWRECTANGLE_H
7
8#include <QDesktopWidget>
9#include <QWidget>
10#include <QLabel>
11#include <QTextLine>
12#include <QHBoxLayout>
13#include <QVBoxLayout>
14#include <QPainter>
15#include <QTimer>
16#include <QDebug>
17
18#include <DObject>
19#include <dtkwidget_global.h>
20#include <DThemeManager>
21#include <dgraphicsgloweffect.h>
22#include <DBlurEffectWidget>
23
24DWIDGET_BEGIN_NAMESPACE
25
26class DPlatformWindowHandle;
27class DArrowRectanglePrivate;
28class LIBDTKWIDGETSHARED_EXPORT DArrowRectangle : public QWidget, public DTK_CORE_NAMESPACE::DObject
29{
30 Q_OBJECT
31 Q_DISABLE_COPY(DArrowRectangle)
32 D_DECLARE_PRIVATE(DArrowRectangle)
33
34public:
35
36 enum ArrowDirection {
37 ArrowLeft,
38 ArrowRight,
39 ArrowTop,
40 ArrowBottom
41 };
42
43 enum FloatMode {
44 FloatWindow,
45 FloatWidget,
46 };
47
48 explicit DArrowRectangle(ArrowDirection direction, QWidget *parent = nullptr);
49 explicit DArrowRectangle(ArrowDirection direction, FloatMode floatMode, QWidget *parent = nullptr);
50 ~DArrowRectangle() override;
51
52 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
53 Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor)
54 Q_PROPERTY(int borderWidth READ borderWidth WRITE setBorderWidth)
55 Q_PROPERTY(int radius READ radius WRITE setRadius)
56 Q_PROPERTY(int arrowWidth READ arrowWidth WRITE setArrowWidth)
57 Q_PROPERTY(int arrowHeight READ arrowHeight WRITE setArrowHeight)
58 Q_PROPERTY(int arrowX READ arrowX WRITE setArrowX)
59 Q_PROPERTY(int arrowY READ arrowY WRITE setArrowY)
60 Q_PROPERTY(int margin READ margin WRITE setMargin)
61 Q_PROPERTY(ArrowDirection arrowDirection READ arrowDirection WRITE setArrowDirection)
62 Q_PROPERTY(qreal shadowXOffset READ shadowXOffset WRITE setShadowXOffset)
63 Q_PROPERTY(qreal shadowYOffset READ shadowYOffset WRITE setShadowYOffset)
64 Q_PROPERTY(qreal shadowBlurRadius READ shadowBlurRadius WRITE setShadowBlurRadius)
65
66 int radius() const;
67 bool radiusForceEnabled() const;
68 int arrowHeight() const;
69 int arrowWidth() const;
70 int arrowX() const;
71 int arrowY() const;
72 int margin() const;
73 int borderWidth() const;
74 QColor borderColor() const;
75 QColor backgroundColor() const;
76 ArrowDirection arrowDirection() const;
77
78 void setRadius(int value);
79 void setRadiusForceEnable(bool enable);
80 void setArrowHeight(int value);
81 void setArrowWidth(int value);
82 void setArrowX(int value);
83 void setArrowY(int value);
84 void setMargin(int value);
85 void setBorderWidth(int borderWidth);
86 void setBorderColor(const QColor &borderColor);
87 void setBackgroundColor(const QColor &backgroundColor);
88 void setBackgroundColor(DBlurEffectWidget::MaskColorType type);
89 void setArrowDirection(ArrowDirection value);
90 void setWidth(int value);
91 void setHeight(int value);
92
93 virtual void show(int x, int y);
94
95 void setContent(QWidget *content);
96 QWidget *getContent() const;
97 void resizeWithContent();
98 void move(int x, int y);
99 QSize getFixedSize();
100
101 qreal shadowXOffset() const;
102 qreal shadowYOffset() const;
103 qreal shadowBlurRadius() const;
104
105 void setShadowBlurRadius(const qreal &shadowBlurRadius);
106 void setShadowXOffset(const qreal &shadowXOffset);
107 void setShadowYOffset(const qreal &shadowYOffset);
108
109 void setLeftRightRadius(bool enable);
110 void setRadiusArrowStyleEnable(bool enable);
111
112Q_SIGNALS:
113 void windowDeactivate() const;
114
115protected:
116 void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
117 void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
118 bool event(QEvent *e) Q_DECL_OVERRIDE;
119};
120
121DWIDGET_END_NAMESPACE
122
123#endif // DARROWRECTANGLE_H
124
DArrowRectangle 提供了可以在四个边中的任意一个边显示箭头的矩形控件.
Definition: darrowrectangle.h:29