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,8 +159,13 @@ ApplicationWindow {
wrapMode: Text.NoWrap
}
Repeater {
model: hsi.getGPUInfoCount()
Text {
text: hsi.getGPUInfo()
required property int index
text: "GPU: " + hsi.getGPUInfo(index)
Layout.maximumWidth: _width - 120
color: system.windowText
elide: Text.ElideRight
@ -168,6 +173,8 @@ ApplicationWindow {
wrapMode: Text.NoWrap
}
}
Text {
text: "Memory: " + hsi.getRAMInfo()
Layout.maximumWidth: _width - 120

View File

@ -18,7 +18,7 @@ class CSystemInternals : public QObject {
QString hyprlandVersion, hyprlandVersionLong;
QString cpuInfo = "missing dependency: lscpu";
QString gpuInfo = "GPU: missing dependency: lspci";
std::vector<QString> gpuInfo = {"missing dependency: lspci"};
QString ramInfo = "?";
QString hlSystemInfo = "[error]", hlSystemVersion = "[error]";
@ -59,8 +59,14 @@ class CSystemInternals : public QObject {
return cpuInfo;
}
Q_INVOKABLE QString getGPUInfo() {
return gpuInfo;
Q_INVOKABLE int getGPUInfoCount() {
return gpuInfo.size();
}
Q_INVOKABLE QString getGPUInfo(int idx) {
if (idx >= gpuInfo.size())
return "[error]";
return gpuInfo.at(idx);
}
Q_INVOKABLE QString getRAMInfo() {

View File

@ -106,15 +106,14 @@ static void getSystemInfo(CSystemInternals* hsi) {
const auto DATA = execAndGet("lspci -vnn | grep VGA");
if (DATA.contains("VGA")) {
CVarList data(DATA, 0, '\n');
std::string gpuInfo;
hsi->gpuInfo.clear();
for (auto& line : data) {
if (!line.contains("VGA"))
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 {
hsi->gpuInfo = "No GPUs found";
hsi->gpuInfo = {"No GPUs found"};
}
}