File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff 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)
4755void 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}
You can’t perform that action at this time.
0 commit comments