fix(network): 同时连接有线网络和无线网络时,只显示了有线网络的IP

功能缺失,修改代码添加当有线网络和无线网络同时连接的时候,显示所有的网络IP

Log: 解决同时连接有线网络和无线网络时,只显示了有线网络的IP问题
Bug: https://pms.uniontech.com/zentao/bug-view-35197.html
This commit is contained in:
fengshaoxiong 2020-06-27 14:57:24 +08:00
parent 44af20205a
commit 356473fd53
2 changed files with 23 additions and 6 deletions

View File

@ -1140,6 +1140,7 @@ void NetworkItem::refreshTips()
break;
case Connected: {
QString strTips;
QStringList textList;
for (auto wirelessItem : m_connectedWirelessDevice) {
if (wirelessItem) {
auto info = wirelessItem->getActiveWirelessConnectionInfo();
@ -1149,6 +1150,8 @@ void NetworkItem::refreshTips()
if (!ipv4.contains("Address"))
break;
strTips = tr("Wireless connection: %1").arg(ipv4.value("Address").toString()) + '\n';
strTips.chop(1);
textList << strTips;
}
}
for (auto wiredItem : m_connectedWiredDevice) {
@ -1160,10 +1163,11 @@ void NetworkItem::refreshTips()
if (!ipv4.contains("Address"))
break;
strTips = tr("Wired connection: %1").arg(ipv4.value("Address").toString()) + '\n';
strTips.chop(1);
textList << strTips;
}
}
strTips.chop(1);
m_tipsWidget->setText(strTips);
m_tipsWidget->setTextList(textList);
}
break;
case Aconnected: {

View File

@ -82,11 +82,24 @@ void TipsWidget::paintEvent(QPaintEvent *event)
bool TipsWidget::event(QEvent *event)
{
if (event->type() == QEvent::FontChange) {
if (!m_text.trimmed().isEmpty()) {
setFixedSize(fontMetrics().width(m_text) + 6, fontMetrics().height());
update();
if (m_type == SingleLine) {
if (!m_text.trimmed().isEmpty()) {
setFixedSize(fontMetrics().width(m_text) + 6, fontMetrics().height());
update();
}
} else {
if (m_textList.size() > 0) {
int maxLength = 0;
setFixedHeight(fontMetrics().height() * m_textList.size());
for (QString text : m_textList) {
int fontLength = fontMetrics().width(text) + 6;
maxLength = qMax(maxLength,fontLength);
}
m_width = maxLength;
setFixedWidth(maxLength);
update();
}
}
}
return QFrame::event(event);
}