Skip to content

Commit 99303a4

Browse files
committed
fix: improve system detection and install routing
1 parent 5ca6d70 commit 99303a4

2 files changed

Lines changed: 54 additions & 3 deletions

File tree

src/backend/system/systeminfoprovider.cpp

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,30 @@ QString simplifiedDesktopName(const QString &desktop) {
2929
return trimmed;
3030
}
3131

32+
[[maybe_unused]] QString virtualizationLabel(const QString &value) {
33+
const QString lowered = value.trimmed().toLower();
34+
if (lowered.isEmpty() || lowered == QStringLiteral("none")) {
35+
return {};
36+
}
37+
if (lowered == QStringLiteral("kvm") || lowered == QStringLiteral("qemu")) {
38+
return QStringLiteral("KVM/QEMU");
39+
}
40+
if (lowered == QStringLiteral("vmware")) {
41+
return QStringLiteral("VMware");
42+
}
43+
if (lowered == QStringLiteral("oracle") ||
44+
lowered == QStringLiteral("virtualbox")) {
45+
return QStringLiteral("VirtualBox");
46+
}
47+
if (lowered == QStringLiteral("microsoft")) {
48+
return QStringLiteral("Hyper-V");
49+
}
50+
if (lowered == QStringLiteral("parallels")) {
51+
return QStringLiteral("Parallels");
52+
}
53+
return value.trimmed();
54+
}
55+
3256
QString valueFromOsRelease(const QString &key) {
3357
QFile file(QStringLiteral("/etc/os-release"));
3458
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
@@ -103,6 +127,7 @@ QString SystemInfoProvider::detectKernelVersion() const {
103127
}
104128

105129
QString SystemInfoProvider::detectCpuModel() const {
130+
QString virtualizationType;
106131
#if defined(Q_OS_LINUX)
107132
CommandRunner runner;
108133
const auto lscpuResult = runner.run(QStringLiteral("lscpu"));
@@ -146,6 +171,21 @@ QString SystemInfoProvider::detectCpuModel() const {
146171
}
147172
}
148173
}
174+
175+
const auto virtResult =
176+
runner.run(QStringLiteral("systemd-detect-virt"), {QStringLiteral("--quiet"), QStringLiteral("--vm")});
177+
if (virtResult.success()) {
178+
const auto virtName = runner.run(QStringLiteral("systemd-detect-virt"));
179+
if (virtName.success()) {
180+
virtualizationType = virtualizationLabel(virtName.stdout.trimmed());
181+
}
182+
}
183+
184+
if (virtualizationType.isEmpty()) {
185+
const QString productName =
186+
valueFromOsRelease(QStringLiteral("VIRTUALIZATION"));
187+
virtualizationType = virtualizationLabel(productName);
188+
}
149189
#elif defined(Q_OS_MACOS)
150190
CommandRunner runner;
151191
const auto result =
@@ -160,7 +200,14 @@ QString SystemInfoProvider::detectCpuModel() const {
160200
#endif
161201

162202
const QString architecture = QSysInfo::currentCpuArchitecture();
163-
return architecture.isEmpty() ? QStringLiteral("Unknown CPU") : architecture;
203+
if (!virtualizationType.isEmpty()) {
204+
return architecture.isEmpty()
205+
? QStringLiteral("%1 Virtual CPU").arg(virtualizationType)
206+
: QStringLiteral("%1 Virtual CPU (%2)")
207+
.arg(virtualizationType, architecture);
208+
}
209+
return architecture.isEmpty() ? QStringLiteral("Unknown CPU")
210+
: QStringLiteral("CPU (%1)").arg(architecture);
164211
}
165212

166213
QString SystemInfoProvider::detectDesktopEnvironment() const {

src/qml/pages/MonitorPage.qml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,14 @@ Item {
6464
if (page.gpuTelemetryAvailable)
6565
return gpuMonitor.utilizationPercent + "%";
6666
if (page.gpuHardwarePresent)
67-
return qsTr("Unsupported");
67+
return qsTr("Not exposed");
6868
return qsTr("Unavailable");
6969
}
7070

71+
function gpuMetricFallbackText() {
72+
return page.gpuHardwarePresent ? qsTr("Not exposed") : qsTr("Unavailable");
73+
}
74+
7175
function gpuSummaryText() {
7276
if (page.gpuTelemetryAvailable)
7377
return qsTr("GPU telemetry active");
@@ -385,7 +389,7 @@ Item {
385389
title: qsTr("VRAM Usage")
386390
subtitle: qsTr("Real-time monitoring")
387391
valueText: page.gpuMemoryAvailable ? page.formatMemoryUsage(gpuMonitor.memoryUsedMiB, gpuMonitor.memoryTotalMiB)
388-
: (page.gpuHardwarePresent ? qsTr("Unsupported") : qsTr("Unavailable"))
392+
: page.gpuMetricFallbackText()
389393
markerText: "V"
390394
markerColor: "#d84ef0"
391395
progress: page.progressValue(page.gpuMemoryAvailable ? gpuMonitor.memoryUsagePercent : 0)

0 commit comments

Comments
 (0)