diff --git a/plugins/network/networkitem.cpp b/plugins/network/networkitem.cpp index 8db8e95af..1f97abd02 100644 --- a/plugins/network/networkitem.cpp +++ b/plugins/network/networkitem.cpp @@ -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: { diff --git a/widgets/tipswidget.cpp b/widgets/tipswidget.cpp index 86e6eacd5..41a23b7f4 100644 --- a/widgets/tipswidget.cpp +++ b/widgets/tipswidget.cpp @@ -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); }