From 2beafd4cf10f8912158448d4012fbbca9b3863de Mon Sep 17 00:00:00 2001 From: Jokul Date: Sun, 19 Jul 2026 12:09:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=89=8D=E7=AB=AF=20tooltip=20?= =?UTF-8?q?=E4=B8=8E=E5=BC=B9=E6=A1=86=E6=96=B0=E5=A2=9E=20IPv6=20?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package/networkview.qml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/package/networkview.qml b/package/networkview.qml index 2fedf5d..3b64fad 100644 --- a/package/networkview.qml +++ b/package/networkview.qml @@ -31,6 +31,8 @@ AppletItem { readonly property string activeInterface: applet ? (applet.activeInterface || "") : "" // 活动接口的 IPv4 地址,由 C++ 后端 detectIpAddress 持续更新 readonly property string ipAddress: applet ? (applet.ipAddress || "") : "" + // 活动接口的 IPv6 全球地址,由 C++ 后端 detectIpAddress 持续更新 + readonly property string ipv6Address: applet ? (applet.ipv6Address || "") : "" readonly property var networkInterfaces: applet ? (applet.networkInterfaces || []) : [] readonly property var interfaceStats: applet ? (applet.interfaceStats || []) : [] @@ -180,12 +182,14 @@ AppletItem { } } - // 悬停提示:网卡名 + IP 地址一行展示 - // PanelToolTip 不支持 contentItem 覆盖和文本对齐,用默认左对齐 text 属性 + // 悬停提示:网卡名 + IPv4 单行,IPv6 在第二行(仅有 IPv6 时追加) + // 设计原因:IPv6 地址较长,单行容纳不下;无 IPv6 时保持单行与原视觉一致 PanelToolTip { id: toolTip text: root.ready - ? (root.activeInterface + " · " + qsTr("IP地址:") + (root.ipAddress || qsTr("无"))) + ? (root.activeInterface + + " · IPv4:" + (root.ipAddress || qsTr("无")) + + (root.ipv6Address ? "\nIPv6:" + root.ipv6Address : "")) : qsTr("未检测到网络接口") toolTipX: DockPanelPositioner.x toolTipY: DockPanelPositioner.y @@ -268,7 +272,8 @@ AppletItem { Rectangle { Layout.alignment: Qt.AlignHCenter Layout.preferredWidth: 180 - Layout.preferredHeight: 40 + // 有 IPv6 时增高以容纳第三行;无 IPv6 时保持原 40px + Layout.preferredHeight: root.ipv6Address ? 54 : 40 color: root.cardBackground radius: 8 border.width: 1 @@ -287,12 +292,21 @@ AppletItem { } Text { - text: root.ipAddress ? qsTr("IP地址:") + root.ipAddress : "" + text: root.ipAddress ? qsTr("IPv4:") + root.ipAddress : "" font.pixelSize: 13 color: root.secondaryText visible: root.ipAddress !== "" Layout.alignment: Qt.AlignHCenter } + + // IPv6 全球地址行,无 IPv6 时隐藏不占位 + Text { + text: root.ipv6Address ? qsTr("IPv6:") + root.ipv6Address : "" + font.pixelSize: 13 + color: root.secondaryText + visible: root.ipv6Address !== "" + Layout.alignment: Qt.AlignHCenter + } } } }