fix: 任务栏蓝牙图标tips信息显示异常

tips文案间隔设置错误

Log: 修复任务栏蓝牙图标tips信息显示异常的问题
Bug: https://pms.uniontech.com/bug-view-120873.html
Influence: tips文案
Change-Id: I82d9e9928cc38a2dfa441ffad52b422957387fbb
This commit is contained in:
Zhang Qipeng 2022-04-18 18:20:58 +08:00 committed by zhangqipeng
parent 7b625b1ab7
commit 001ab4c907

View File

@ -46,11 +46,11 @@ void TipsWidget::setTextList(const QStringList &textList)
int width = 0;
int height = 0;
for (QString text : m_textList) {
width = qMax(width, fontMetrics().width(text) + 20);
width = qMax(width, fontMetrics().width(text));
height += fontMetrics().boundingRect(text).height();
}
setFixedSize(width, height);
setFixedSize(width + 20, height);
update();
}
@ -75,16 +75,18 @@ void TipsWidget::paintEvent(QPaintEvent *event)
}
break;
case MultiLine: {
int y = 0;
if (m_textList.size() != 1)
int x = rect().x();
int y = rect().y();
if (m_textList.size() != 1) {
x += 10;
option.setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
}
for (QString text : m_textList) {
int lineHeight = fontMetrics().boundingRect(text).height();
painter.drawText(QRect(0, y, rect().width(), lineHeight), text, option);
painter.drawText(QRect(x, y, rect().width(), lineHeight), text, option);
y += lineHeight;
}
}
break;
} break;
}
}