fix: 无 IP 地址时接口名位置与有 IP 时保持一致

去掉接口信息区外层 Item 包装和 anchors.centerIn,直接用 ColumnLayout
内容自然撑高、顶部对齐。无论有无 IP 地址,接口名行始终在顶部同一
垂直位置,切换网卡时不再跳动
This commit is contained in:
2026-08-08 21:19:48 +08:00
parent 28829c2ab7
commit 8129730d43
+21 -28
View File
@@ -134,40 +134,34 @@ Control {
// ==================== 分区1:接口信息 ==================== // ==================== 分区1:接口信息 ====================
// 三行对称结构:行1 接口名(居中),行2 IPv4 地址行,行3 IPv6 地址行 // 三行对称结构:行1 接口名(居中),行2 IPv4 地址行,行3 IPv6 地址行
// 地址行用固定宽度标签 + 地址 + 复制图标,两行结构对称不会错位 // 地址行用固定宽度标签 + 地址 + 复制图标,两行结构对称不会错位
// 外层 Item 固定高度 + 内层 ColumnLayout anchors.centerIn: // 直接用 ColumnLayout 内容自然撑高、顶部对齐:
// 无 IP 地址时内容在区域内垂直居中,避免单行内容贴顶导致网卡名偏上 // 无论有无 IP 地址,接口名行始终在顶部同一垂直位置,切换网卡不跳动
Item { ColumnLayout {
id: ifaceCol
Layout.fillWidth: true Layout.fillWidth: true
// preferredHeight 40 为无 IP 时的最小高度;有 IP/IPv6 时内容自然撑高 spacing: 4
Layout.preferredHeight: Math.max(40, ifaceCol.implicitHeight)
visible: popup.ready visible: popup.ready
ColumnLayout { // 行1:类型图标 + 接口名(居中)
id: ifaceCol RowLayout {
anchors.centerIn: parent Layout.alignment: Qt.AlignHCenter
width: parent.width
spacing: 4 spacing: 4
// 行1:类型图标 + 接口名(居中) // 网卡类型图标:与设置窗口列表图标一致,次要色不抢速度区焦点
RowLayout { Text {
Layout.alignment: Qt.AlignHCenter text: common.interfaceIcon(popup.activeInterface)
spacing: 4 font.pixelSize: Math.round(12 * popup.fontScale)
color: popup.tertiaryText
// 网卡类型图标:与设置窗口列表图标一致,次要色不抢速度区焦点
Text {
text: common.interfaceIcon(popup.activeInterface)
font.pixelSize: Math.round(12 * popup.fontScale)
color: popup.tertiaryText
}
// 接口名:跟随用户 textColor(primaryText),Spec 5.1 节要求
Text {
text: popup.activeInterface
font.pixelSize: Math.round(13 * popup.fontScale)
color: popup.primaryText
}
} }
// 接口名:跟随用户 textColor(primaryText),Spec 5.1 节要求
Text {
text: popup.activeInterface
font.pixelSize: Math.round(13 * popup.fontScale)
color: popup.primaryText
}
}
// 行2:IPv4 标签 + 地址 + 复制图标 // 行2:IPv4 标签 + 地址 + 复制图标
// 与行3 结构对称:标签固定宽度左对齐,地址左对齐,复制图标在右 // 与行3 结构对称:标签固定宽度左对齐,地址左对齐,复制图标在右
RowLayout { RowLayout {
@@ -289,7 +283,6 @@ Control {
} }
} }
} }
}
} }
// 分隔线1 // 分隔线1