51 QString output =
m_executor->executeCommand(
"nmcli -t -f DEVICE,STATE,CONNECTION dev");
52 QStringList lines = output.split(
'\n');
54 for (
const QString &line : lines) {
55 if (line.startsWith(
"wlan")) {
56 QStringList parts = line.split(
':');
57 if (parts.size() >= 3) {
59 return (parts[1] ==
"connected") ?
"Connected" :
"Disconnected";
64 return "No interface detected";
75 QString tempStr =
m_executor->readFile(
"/sys/class/hwmon/hwmon0/temp1_input").trimmed();
78 double tempMillidegrees = tempStr.toDouble(&ok);
79 return ok ? QString(
"%1°C").arg(tempMillidegrees / 1000.0, 0,
'f', 1) :
"N/A";
90 "sh -c \"ip -4 addr show wlan0 | grep -oP '(?<=inet\\s)\\d+\\.\\d+\\.\\d+\\.\\d+'\"");
92 return output.trimmed().isEmpty() ?
"No IP address" : output.trimmed();
Definition of the SystemCommandExecutor class.
Definition of the SystemInfoProvider class.
Interface for executing system commands and reading files.
Class that executes system commands and reads files.
~SystemInfoProvider() override
Destructor for the SystemInfoProvider class.
QString getWifiStatus(QString &wifiName) const override
Gets the current WiFi status.
ISystemCommandExecutor * m_executor
QString getIpAddress() const override
Gets the current IP address of the WiFi interface.
SystemInfoProvider(ISystemCommandExecutor *executor=nullptr)
Constructor for the SystemInfoProvider class.
QString getTemperature() const override
Gets the current temperature in degrees Celsius.