Skip to content

Commit 3a97055

Browse files
committed
fix: should also update geometry when tips type changed
目前在 tips 控件的类型(单行/多行)变化时,若原本控件内存储的文案没有 变化,则不一定会重新计算界面宽度.此提交新增了类型变化的检查. PMS: BUG-335551 Log:
1 parent f9a1e97 commit 3a97055

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

plugins/dde-dock/bluetooth/bluetoothitem.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff 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

plugins/dde-dock/widgets/tipswidget.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@ TipsWidget::TipsWidget(QWidget *parent)
1919

2020
void 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

5156
void 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;

0 commit comments

Comments
 (0)