Skip to content

Commit 278fb90

Browse files
yixinsharkdeepin-bot[bot]
authored andcommitted
fix: plugin tooltip window size can adapt to content changes
as title Log: as title Pms: BUG-290591
1 parent 6e4aa2f commit 278fb90

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

plugins/dde-dock/widgets/tipswidget.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ void TipsWidget::setText(const QString &text)
2424
QTextDocument document;
2525
document.setHtml(text);
2626
// 同时去掉两边的空白信息,例如qBittorrent的提示
27-
m_text = document.toPlainText().simplified();
27+
QString newText = document.toPlainText().simplified();
28+
if (m_text == newText) {
29+
return;
30+
}
31+
32+
m_text = newText;
2833

2934
#if 0 //测试时可以使用下面的语句
3035
// FIXME:藏语字体绘制会有异常,设置高度时需要使用fontMetrics().boundingRect()去获取整体的边界矩形的高度,
@@ -33,6 +38,9 @@ void TipsWidget::setText(const QString &text)
3338
#endif
3439

3540
setFixedSize(fontMetrics().horizontalAdvance(m_text), fontMetrics().boundingRect(m_text).height());
41+
if (parentWidget()) {
42+
parentWidget()->adjustSize();
43+
}
3644

3745
update();
3846

@@ -47,6 +55,9 @@ void TipsWidget::setText(const QString &text)
4755
void TipsWidget::setTextList(const QStringList &textList)
4856
{
4957
m_type = TipsWidget::MultiLine;
58+
if (textList == m_textList) {
59+
return;
60+
}
5061
m_textList = textList;
5162

5263
int width = 0;
@@ -57,6 +68,9 @@ void TipsWidget::setTextList(const QStringList &textList)
5768
}
5869

5970
setFixedSize(width, height);
71+
if (parentWidget()) {
72+
parentWidget()->adjustSize();
73+
}
6074

6175
update();
6276
}

0 commit comments

Comments
 (0)