mirror of
https://github.com/hyprwm/hyprsysteminfo.git
synced 2024-12-25 19:49:48 +01:00
core: fixup elision on gpu data
This commit is contained in:
parent
1562ce6415
commit
a2028419fc
3 changed files with 33 additions and 21 deletions
21
qml/main.qml
21
qml/main.qml
|
@ -159,13 +159,20 @@ ApplicationWindow {
|
|||
wrapMode: Text.NoWrap
|
||||
}
|
||||
|
||||
Text {
|
||||
text: hsi.getGPUInfo()
|
||||
Layout.maximumWidth: _width - 120
|
||||
color: system.windowText
|
||||
elide: Text.ElideRight
|
||||
textFormat: Text.PlainText
|
||||
wrapMode: Text.NoWrap
|
||||
Repeater {
|
||||
model: hsi.getGPUInfoCount()
|
||||
|
||||
Text {
|
||||
required property int index
|
||||
|
||||
text: "GPU: " + hsi.getGPUInfo(index)
|
||||
Layout.maximumWidth: _width - 120
|
||||
color: system.windowText
|
||||
elide: Text.ElideRight
|
||||
textFormat: Text.PlainText
|
||||
wrapMode: Text.NoWrap
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Text {
|
||||
|
|
|
@ -14,16 +14,16 @@ class CSystemInternals : public QObject {
|
|||
;
|
||||
}
|
||||
|
||||
QString systemLogoName, systemName = "Linux", systemURL = "https://kernel.org/", systemKernel = "unknown";
|
||||
QString hyprlandVersion, hyprlandVersionLong;
|
||||
QString systemLogoName, systemName = "Linux", systemURL = "https://kernel.org/", systemKernel = "unknown";
|
||||
QString hyprlandVersion, hyprlandVersionLong;
|
||||
|
||||
QString cpuInfo = "missing dependency: lscpu";
|
||||
QString gpuInfo = "GPU: missing dependency: lspci";
|
||||
QString ramInfo = "?";
|
||||
QString cpuInfo = "missing dependency: lscpu";
|
||||
std::vector<QString> gpuInfo = {"missing dependency: lspci"};
|
||||
QString ramInfo = "?";
|
||||
|
||||
QString hlSystemInfo = "[error]", hlSystemVersion = "[error]";
|
||||
QString hlSystemInfo = "[error]", hlSystemVersion = "[error]";
|
||||
|
||||
Q_INVOKABLE bool hasSystemLogoName() {
|
||||
Q_INVOKABLE bool hasSystemLogoName() {
|
||||
return systemLogoName.size() > 0;
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
|
|
@ -105,16 +105,15 @@ 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;
|
||||
CVarList data(DATA, 0, '\n');
|
||||
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"};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue