forked from linuxdeepin/dtkwidget
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdtiplabel.cpp
More file actions
89 lines (70 loc) · 1.62 KB
/
dtiplabel.cpp
File metadata and controls
89 lines (70 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// SPDX-FileCopyrightText: 2011 - 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#include "dtiplabel.h"
#include "private/dtiplabel_p.h"
#include <DFontSizeManager>
DWIDGET_BEGIN_NAMESPACE
/*!
\class Dtk::Widget::DTipLabel
\inmodule dtkwidget
\brief DTipLabel一个重新实现的 QLabel.
\list
\li DTipLabel提供了将 DTipLabel 显示在指定位置的函数
\li DTipLabel提供了改变字体颜色的函数
\endlist
*/
/*!
\brief DTipLabel的构造函数
\a text 文本信息
\a parent 参数被发送到 QLabel 构造函数。
*/
DTipLabel::DTipLabel(const QString &text, QWidget *parent)
: DLabel(*new DTipLabelPrivate(this), parent)
{
setText(text);
D_D(DTipLabel);
d->init();
}
DTipLabel::~DTipLabel()
{
}
/*!
\brief DTipLabel::show显示在指定的位置上
\a pos 显示位置
*/
void DTipLabel::show(const QPoint &pos)
{
if (isWindow()) {
setWindowFlag(Qt::ToolTip);
}
move(pos);
QLabel::show();
}
/*!
\brief DTipLabel::setForegroundRole显示的字体颜色
\a color 字体颜色
*/
void DTipLabel::setForegroundRole(DPalette::ColorType color)
{
DLabel::setForegroundRole(color);
}
void DTipLabel::initPainter(QPainter *painter) const
{
DLabel::initPainter(painter);
}
void DTipLabel::paintEvent(QPaintEvent *event)
{
DLabel::paintEvent(event);
}
DTipLabelPrivate::DTipLabelPrivate(DTipLabel *q)
: DLabelPrivate(q)
{
color = DPalette::TextTips;
}
void DTipLabelPrivate::init()
{
Q_Q(DTipLabel);
DFontSizeManager::instance()->bind(q, DFontSizeManager::T7);
}
DWIDGET_END_NAMESPACE