Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions plugins/dde-dock/bluetooth/bluetoothitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,6 @@ void BluetoothItem::refreshTips()
}

m_tipsLabel->setText(tipsText);
QFontMetrics metrics(m_tipsLabel->font());
int textWidth = metrics.boundingRect(m_tipsLabel->text()).width();
m_tipsLabel->setMinimumWidth(textWidth);
m_quickPanel->setDescription(description);
}

Expand Down
10 changes: 10 additions & 0 deletions plugins/dde-dock/widgets/tipswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@

void TipsWidget::setText(const QString &text)
{
bool typeChanged = m_type != TipsWidget::SingleLine;
m_type = TipsWidget::SingleLine;
// 如果传递的是富文本,获取富文本中的纯文本内容进行显示
QTextDocument document;
document.setHtml(text);
// 同时去掉两边的空白信息,例如qBittorrent的提示
QString newText = document.toPlainText().simplified();
if (m_text == newText) {
if (typeChanged) {
updateGeometry();
update();
}
return;
}

Expand All @@ -48,10 +53,15 @@
#endif
}

void TipsWidget::setTextList(const QStringList &textList)

Check warning on line 56 in plugins/dde-dock/widgets/tipswidget.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'setTextList' is never used.
{
bool typeChanged = m_type != TipsWidget::MultiLine;
m_type = TipsWidget::MultiLine;
if (textList == m_textList) {
if (typeChanged) {
updateGeometry();
update();
}
return;
}
m_textList = textList;
Expand Down