core: fixup elision on gpu data

This commit is contained in:
Vaxry 2024-10-13 16:54:23 +01:00
parent 1562ce6415
commit a2028419fc
3 changed files with 33 additions and 21 deletions

View file

@ -159,13 +159,20 @@ ApplicationWindow {
wrapMode: Text.NoWrap wrapMode: Text.NoWrap
} }
Text { Repeater {
text: hsi.getGPUInfo() model: hsi.getGPUInfoCount()
Layout.maximumWidth: _width - 120
color: system.windowText Text {
elide: Text.ElideRight required property int index
textFormat: Text.PlainText
wrapMode: Text.NoWrap text: "GPU: " + hsi.getGPUInfo(index)
Layout.maximumWidth: _width - 120
color: system.windowText
elide: Text.ElideRight
textFormat: Text.PlainText
wrapMode: Text.NoWrap
}
} }
Text { Text {

View file

@ -14,16 +14,16 @@ class CSystemInternals : public QObject {
; ;
} }
QString systemLogoName, systemName = "Linux", systemURL = "https://kernel.org/", systemKernel = "unknown"; QString systemLogoName, systemName = "Linux", systemURL = "https://kernel.org/", systemKernel = "unknown";
QString hyprlandVersion, hyprlandVersionLong; QString hyprlandVersion, hyprlandVersionLong;
QString cpuInfo = "missing dependency: lscpu"; QString cpuInfo = "missing dependency: lscpu";
QString gpuInfo = "GPU: missing dependency: lspci"; std::vector<QString> gpuInfo = {"missing dependency: lspci"};
QString ramInfo = "?"; QString ramInfo = "?";
QString hlSystemInfo = "[error]", hlSystemVersion = "[error]"; QString hlSystemInfo = "[error]", hlSystemVersion = "[error]";
Q_INVOKABLE bool hasSystemLogoName() { Q_INVOKABLE bool hasSystemLogoName() {
return systemLogoName.size() > 0; return systemLogoName.size() > 0;
} }
@ -59,8 +59,14 @@ class CSystemInternals : public QObject {
return cpuInfo; return cpuInfo;
} }
Q_INVOKABLE QString getGPUInfo() { Q_INVOKABLE int getGPUInfoCount() {
return gpuInfo; return gpuInfo.size();
}
Q_INVOKABLE QString getGPUInfo(int idx) {
if (idx >= gpuInfo.size())
return "[error]";
return gpuInfo.at(idx);
} }
Q_INVOKABLE QString getRAMInfo() { Q_INVOKABLE QString getRAMInfo() {

View file

@ -105,16 +105,15 @@ static void getSystemInfo(CSystemInternals* hsi) {
{ {
const auto DATA = execAndGet("lspci -vnn | grep VGA"); const auto DATA = execAndGet("lspci -vnn | grep VGA");
if (DATA.contains("VGA")) { if (DATA.contains("VGA")) {
CVarList data(DATA, 0, '\n'); CVarList data(DATA, 0, '\n');
std::string gpuInfo; hsi->gpuInfo.clear();
for (auto& line : data) { for (auto& line : data) {
if (!line.contains("VGA")) if (!line.contains("VGA"))
continue; continue;
gpuInfo += std::format("GPU: {}\n", line.substr(line.find(":", line.find("VGA")) + 1)); hsi->gpuInfo.emplace_back(std::format("{}", line.substr(line.find(":", line.find("VGA")) + 2)).c_str());
} }
hsi->gpuInfo = gpuInfo.substr(0, gpuInfo.length() - 1).c_str();
} else { } else {
hsi->gpuInfo = "No GPUs found"; hsi->gpuInfo = {"No GPUs found"};
} }
} }