feat: 添加GPU切换模式检测和主副显标识

- C++后端:GpuInfo添加isPrimary字段,读取boot_vga判断主副显
- C++后端:detectGpuMode()检测PRIME/Bumblebee/Solo/Hybrid模式
- C++后端:新增gpuMode和gpuPrimary属性
- QML前端:卡片显示绿色主显标签(boot_vga=1的GPU)
- QML前端:弹窗显示GPU模式标签(PRIME等)和帮助图标
- 帮助图标悬停显示模式说明文字
- 翻译更新:主显/主顯 + 四种模式的中文说明
This commit is contained in:
2026-07-14 00:19:56 +08:00
parent 403ae8a69b
commit d5a2c380ab
5 changed files with 216 additions and 6 deletions
+90 -6
View File
@@ -23,6 +23,7 @@ AppletItem {
readonly property string gpuSummary: applet ? (applet.gpuSummary || qsTr("No GPU detected")) : qsTr("No GPU detected")
readonly property string deviceInfo: applet ? (applet.deviceInfo || qsTr("Unknown")) : qsTr("Unknown")
readonly property string currentDriver: applet ? (applet.currentDriver || qsTr("Unknown")) : qsTr("Unknown")
readonly property string gpuMode: applet ? (applet.gpuMode || "") : ""
property Palette basePalette: DockPalette.iconTextPalette
readonly property color primaryText: Qt.rgba(basePalette.r, basePalette.g, basePalette.b, 0.9)
@@ -189,6 +190,65 @@ AppletItem {
Layout.fillWidth: true
elide: Text.ElideRight
}
// GPU 模式标签
Rectangle {
visible: root.gpuMode.length > 0
width: modeText.implicitWidth + 16
height: 20
color: root.accentBlueLight
radius: 10
Text {
id: modeText
anchors.centerIn: parent
text: root.gpuMode
font.pixelSize: 11
font.bold: true
color: root.accentBlue
}
}
// 帮助图标
Item {
visible: root.gpuMode.length > 0
width: 16
height: 16
Rectangle {
anchors.fill: parent
radius: width / 2
color: helpHover.hovered ? root.accentBlue : root.tertiaryText
}
Text {
anchors.centerIn: parent
text: "?"
font.pixelSize: 10
font.bold: true
color: "white"
}
HoverHandler {
id: helpHover
}
ToolTip {
visible: helpHover.hovered
delay: 200
text: {
if (root.gpuMode === "PRIME")
return qsTr("PRIME mode: the integrated GPU handles display, the discrete GPU renders on demand. 3D apps use PRIME Render Offload to invoke the discrete GPU.")
if (root.gpuMode === "Bumblebee")
return qsTr("Bumblebee mode: a legacy dual-GPU solution, now deprecated.")
if (root.gpuMode === "Solo")
return qsTr("Solo mode: only one GPU detected.")
if (root.gpuMode === "Hybrid")
return qsTr("Hybrid mode: dual GPU detected, but no known switching solution found.")
return ""
}
}
}
}
// GPU 列表区域
@@ -220,6 +280,7 @@ AppletItem {
border.color: root.cardBorder
property string statsLine: root.applet && root.applet.gpuStats ? (root.applet.gpuStats[index] || "") : ""
property bool isPrimaryGpu: root.applet && root.applet.gpuPrimary ? (root.applet.gpuPrimary[index] === "true") : false
property string tempStr: {
var parts = statsLine.split("|")
var temp = parts[0]
@@ -300,13 +361,36 @@ AppletItem {
spacing: 4
Layout.fillWidth: true
Text {
text: parseGpuName(modelData)
font.pixelSize: 13
font.bold: true
color: root.primaryText
RowLayout {
spacing: 6
Layout.fillWidth: true
elide: Text.ElideRight
Text {
text: parseGpuName(modelData)
font.pixelSize: 13
font.bold: true
color: root.primaryText
Layout.fillWidth: true
elide: Text.ElideRight
}
// 主/副显标识
Rectangle {
visible: gpuCard.isPrimaryGpu
width: badgeText.implicitWidth + 12
height: 16
color: Qt.rgba(22/255, 163/255, 74/255, 0.15)
radius: 8
Text {
id: badgeText
anchors.centerIn: parent
text: qsTr("Primary")
font.pixelSize: 10
font.bold: true
color: Qt.rgba(22/255, 163/255, 74/255, 1)
}
}
}
Text {