File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -189,9 +189,6 @@ void BluetoothItem::refreshTips()
189189 }
190190
191191 m_tipsLabel->setText (tipsText);
192- QFontMetrics metrics (m_tipsLabel->font ());
193- int textWidth = metrics.boundingRect (m_tipsLabel->text ()).width ();
194- m_tipsLabel->setMinimumWidth (textWidth);
195192 m_quickPanel->setDescription (description);
196193}
197194
Original file line number Diff line number Diff line change @@ -19,13 +19,18 @@ TipsWidget::TipsWidget(QWidget *parent)
1919
2020void TipsWidget::setText (const QString &text)
2121{
22+ bool typeChanged = m_type != TipsWidget::SingleLine;
2223 m_type = TipsWidget::SingleLine;
2324 // 如果传递的是富文本,获取富文本中的纯文本内容进行显示
2425 QTextDocument document;
2526 document.setHtml (text);
2627 // 同时去掉两边的空白信息,例如qBittorrent的提示
2728 QString newText = document.toPlainText ().simplified ();
2829 if (m_text == newText) {
30+ if (typeChanged) {
31+ updateGeometry ();
32+ update ();
33+ }
2934 return ;
3035 }
3136
@@ -50,8 +55,13 @@ void TipsWidget::setText(const QString &text)
5055
5156void TipsWidget::setTextList (const QStringList &textList)
5257{
58+ bool typeChanged = m_type != TipsWidget::MultiLine;
5359 m_type = TipsWidget::MultiLine;
5460 if (textList == m_textList) {
61+ if (typeChanged) {
62+ updateGeometry ();
63+ update ();
64+ }
5565 return ;
5666 }
5767 m_textList = textList;
You can’t perform that action at this time.
0 commit comments