feat: 前端 tooltip 与弹框新增 IPv6 地址显示

This commit is contained in:
2026-07-19 12:09:04 +08:00
parent f7281a5f0c
commit 2beafd4cf1
+19 -5
View File
@@ -31,6 +31,8 @@ AppletItem {
readonly property string activeInterface: applet ? (applet.activeInterface || "") : "" readonly property string activeInterface: applet ? (applet.activeInterface || "") : ""
// 活动接口的 IPv4 地址,由 C++ 后端 detectIpAddress 持续更新 // 活动接口的 IPv4 地址,由 C++ 后端 detectIpAddress 持续更新
readonly property string ipAddress: applet ? (applet.ipAddress || "") : "" 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 networkInterfaces: applet ? (applet.networkInterfaces || []) : []
readonly property var interfaceStats: applet ? (applet.interfaceStats || []) : [] readonly property var interfaceStats: applet ? (applet.interfaceStats || []) : []
@@ -180,12 +182,14 @@ AppletItem {
} }
} }
// 悬停提示:网卡名 + IP 地址一行展示 // 悬停提示:网卡名 + IPv4 单行,IPv6 在第二行(仅有 IPv6 时追加)
// PanelToolTip 不支持 contentItem 覆盖和文本对齐,用默认左对齐 text 属性 // 设计原因:IPv6 地址较长,单行容纳不下;无 IPv6 时保持单行与原视觉一致
PanelToolTip { PanelToolTip {
id: toolTip id: toolTip
text: root.ready text: root.ready
? (root.activeInterface + " · " + qsTr("IP地址:") + (root.ipAddress || qsTr("无"))) ? (root.activeInterface
+ " · IPv4" + (root.ipAddress || qsTr("无"))
+ (root.ipv6Address ? "\nIPv6" + root.ipv6Address : ""))
: qsTr("未检测到网络接口") : qsTr("未检测到网络接口")
toolTipX: DockPanelPositioner.x toolTipX: DockPanelPositioner.x
toolTipY: DockPanelPositioner.y toolTipY: DockPanelPositioner.y
@@ -268,7 +272,8 @@ AppletItem {
Rectangle { Rectangle {
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: 180 Layout.preferredWidth: 180
Layout.preferredHeight: 40 // 有 IPv6 时增高以容纳第三行;无 IPv6 时保持原 40px
Layout.preferredHeight: root.ipv6Address ? 54 : 40
color: root.cardBackground color: root.cardBackground
radius: 8 radius: 8
border.width: 1 border.width: 1
@@ -287,12 +292,21 @@ AppletItem {
} }
Text { Text {
text: root.ipAddress ? qsTr("IP地址") + root.ipAddress : "" text: root.ipAddress ? qsTr("IPv4") + root.ipAddress : ""
font.pixelSize: 13 font.pixelSize: 13
color: root.secondaryText color: root.secondaryText
visible: root.ipAddress !== "" visible: root.ipAddress !== ""
Layout.alignment: Qt.AlignHCenter 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
}
} }
} }
} }