|
@@ -28,12 +28,11 @@
|
|
|
|
|
|
#define HWMON_PATH "/sys/class/hwmon"
|
|
|
|
|
|
-Loader::Loader(QObject *parent) : QObject(parent)
|
|
|
+Loader::Loader(QObject *parent) : QObject(parent),
|
|
|
+ m_interval(10),
|
|
|
+ m_configUrl(QUrl::fromLocalFile("/etc/fancontrol")),
|
|
|
+ m_error("Success")
|
|
|
{
|
|
|
- m_configUrl = QUrl::fromLocalFile("/etc/fancontrol");
|
|
|
- m_interval = 10;
|
|
|
- m_error = "Success";
|
|
|
-
|
|
|
parseHwmons();
|
|
|
|
|
|
m_timer.setSingleShot(false);
|
|
@@ -74,7 +73,7 @@ void Loader::parseHwmons()
|
|
|
emit allPwmFansChanged();
|
|
|
}
|
|
|
|
|
|
-void Loader::load(const QUrl &url)
|
|
|
+bool Loader::load(const QUrl &url)
|
|
|
{
|
|
|
QString fileName;
|
|
|
if (url.isEmpty())
|
|
@@ -82,20 +81,24 @@ void Loader::load(const QUrl &url)
|
|
|
qDebug() << "Given empty url. Fallback to " << m_configUrl;
|
|
|
fileName = m_configUrl.toLocalFile();
|
|
|
}
|
|
|
- else
|
|
|
+ else if (url.isLocalFile())
|
|
|
fileName = url.toLocalFile();
|
|
|
+ else
|
|
|
+ {
|
|
|
+ setError("Url is not a local file");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- QFile file(fileName);
|
|
|
QTextStream stream;
|
|
|
- QString string;
|
|
|
- QStringList lines;
|
|
|
+ QFile file(fileName);
|
|
|
|
|
|
if (file.open(QFile::ReadOnly | QFile::Text))
|
|
|
{
|
|
|
stream.setDevice(&file);
|
|
|
- m_error = "Success";
|
|
|
- emit errorChanged();
|
|
|
+ m_configFile = stream.readAll();
|
|
|
+ emit configFileChanged();
|
|
|
}
|
|
|
+
|
|
|
else if (file.exists())
|
|
|
{
|
|
|
KAuth::Action action("fancontrol.gui.helper.action");
|
|
@@ -107,25 +110,24 @@ void Loader::load(const QUrl &url)
|
|
|
KAuth::ExecuteJob *reply = action.execute();
|
|
|
if (!reply->exec())
|
|
|
{
|
|
|
- m_error = reply->errorString();
|
|
|
- emit errorChanged();
|
|
|
- return;
|
|
|
+ setError(reply->errorString());
|
|
|
+ return false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- m_error = "Success";
|
|
|
- emit errorChanged();
|
|
|
- string = reply->data()["content"].toString();
|
|
|
- stream.setString(&string);
|
|
|
+ m_configFile = reply->data()["content"].toString();
|
|
|
+ emit configFileChanged();
|
|
|
}
|
|
|
}
|
|
|
- m_configFile = stream.readAll();
|
|
|
- emit configFileChanged();
|
|
|
+ else
|
|
|
+ {
|
|
|
+ setError("File does not exist");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
m_configUrl = url;
|
|
|
emit configUrlChanged();
|
|
|
|
|
|
- stream.seek(0);
|
|
|
-
|
|
|
foreach (Hwmon *hwmon, m_hwmons)
|
|
|
{
|
|
|
foreach (QObject *pwmFan, hwmon->pwmFans())
|
|
@@ -133,7 +135,9 @@ void Loader::load(const QUrl &url)
|
|
|
qobject_cast<PwmFan *>(pwmFan)->reset();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ stream.setString(&m_configFile);
|
|
|
+ QStringList lines;
|
|
|
do
|
|
|
{
|
|
|
QString line(stream.readLine());
|
|
@@ -148,150 +152,197 @@ void Loader::load(const QUrl &url)
|
|
|
foreach (QString line, lines)
|
|
|
{
|
|
|
if (line.startsWith("INTERVAL="))
|
|
|
- {
|
|
|
- setInterval(line.remove("INTERVAL=").toInt());
|
|
|
- }
|
|
|
+ {
|
|
|
+ line.remove("INTERVAL=");
|
|
|
+ bool success;
|
|
|
+ int interval = line.toInt(&success);
|
|
|
+ if (success)
|
|
|
+ setInterval(interval, false);
|
|
|
+
|
|
|
+ else
|
|
|
+ {
|
|
|
+ setError("Unable to parse interval line");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
else if (line.startsWith("FCTEMPS="))
|
|
|
{
|
|
|
+ line.remove("FCTEMPS=");
|
|
|
QStringList fctemps = line.split(' ');
|
|
|
- if (!fctemps.isEmpty())
|
|
|
- fctemps.first().remove("FCTEMPS=");
|
|
|
foreach (QString fctemp, fctemps)
|
|
|
{
|
|
|
- QString pwm = fctemp.split('=').at(0);
|
|
|
- QString temp = fctemp.split('=').at(1);
|
|
|
- int pwmSensorIndex = getSensorNumber(pwm);
|
|
|
- int tempSensorIndex = getSensorNumber(temp);
|
|
|
- Hwmon *pwmHwmon = m_hwmons.value(getHwmonNumber(pwm), Q_NULLPTR);
|
|
|
-
|
|
|
- if (pwmHwmon)
|
|
|
- {
|
|
|
- Hwmon *tempHwmon = m_hwmons.value(getHwmonNumber(temp), Q_NULLPTR);
|
|
|
- PwmFan *pwmPointer = pwmHwmon->pwmFan(pwmSensorIndex);
|
|
|
- if (tempHwmon)
|
|
|
- {
|
|
|
- Temp *tempPointer = tempHwmon->temp(tempSensorIndex);
|
|
|
-
|
|
|
- if (pwmPointer)
|
|
|
- {
|
|
|
- pwmPointer->setTemp(tempPointer);
|
|
|
- pwmPointer->setMinPwm(0);
|
|
|
- }
|
|
|
- }
|
|
|
- else if (pwmPointer)
|
|
|
- pwmPointer->setTemp(Q_NULLPTR);
|
|
|
- }
|
|
|
+ QStringList nameValuePair = fctemp.split('=');
|
|
|
+ if (nameValuePair.size() == 2)
|
|
|
+ {
|
|
|
+ QString pwm = nameValuePair.at(0);
|
|
|
+ QString temp = nameValuePair.at(1);
|
|
|
+ int pwmSensorIndex = getSensorNumber(pwm);
|
|
|
+ int tempSensorIndex = getSensorNumber(temp);
|
|
|
+ Hwmon *pwmHwmon = m_hwmons.value(getHwmonNumber(pwm), Q_NULLPTR);
|
|
|
+
|
|
|
+ if (pwmHwmon)
|
|
|
+ {
|
|
|
+ Hwmon *tempHwmon = m_hwmons.value(getHwmonNumber(temp), Q_NULLPTR);
|
|
|
+ PwmFan *pwmPointer = pwmHwmon->pwmFan(pwmSensorIndex);
|
|
|
+ if (tempHwmon)
|
|
|
+ {
|
|
|
+ Temp *tempPointer = tempHwmon->temp(tempSensorIndex);
|
|
|
+
|
|
|
+ if (pwmPointer)
|
|
|
+ {
|
|
|
+ pwmPointer->setTemp(tempPointer);
|
|
|
+ pwmPointer->setMinPwm(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (pwmPointer)
|
|
|
+ pwmPointer->setTemp(Q_NULLPTR);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else if (line.startsWith("MINTEMP="))
|
|
|
{
|
|
|
+ line.remove("MINTEMP=");
|
|
|
QStringList mintemps = line.split(' ');
|
|
|
- if (!mintemps.isEmpty())
|
|
|
- mintemps.first().remove("MINTEMP=");
|
|
|
foreach (QString mintemp, mintemps)
|
|
|
{
|
|
|
- QString pwm = mintemp.split('=').at(0);
|
|
|
- int value = mintemp.split('=').at(1).toInt();
|
|
|
- int pwmHwmon = getHwmonNumber(pwm);
|
|
|
- int pwmSensor = getSensorNumber(pwm);
|
|
|
- PwmFan *pwmPointer = m_hwmons.value(pwmHwmon, Q_NULLPTR)->pwmFan(pwmSensor);
|
|
|
- if (pwmPointer)
|
|
|
- pwmPointer->setMinTemp(value);
|
|
|
+ QStringList nameValuePair = mintemp.split('=');
|
|
|
+ if (nameValuePair.size() == 2)
|
|
|
+ {
|
|
|
+ QString pwm = nameValuePair.at(0);
|
|
|
+ int value = nameValuePair.at(1).toInt();
|
|
|
+ int pwmHwmon = getHwmonNumber(pwm);
|
|
|
+ int pwmSensor = getSensorNumber(pwm);
|
|
|
+ PwmFan *pwmPointer = m_hwmons.value(pwmHwmon, Q_NULLPTR)->pwmFan(pwmSensor);
|
|
|
+ if (pwmPointer)
|
|
|
+ pwmPointer->setMinTemp(value);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else if (line.startsWith("MAXTEMP="))
|
|
|
{
|
|
|
+ line.remove("MAXTEMP=");
|
|
|
QStringList maxtemps = line.split(' ');
|
|
|
- if (!maxtemps.isEmpty())
|
|
|
- maxtemps.first().remove("MAXTEMP=");
|
|
|
foreach (QString maxtemp, maxtemps)
|
|
|
{
|
|
|
- QString pwm = maxtemp.split('=').at(0);
|
|
|
- int value = maxtemp.split('=').at(1).toInt();
|
|
|
- int pwmHwmon = getHwmonNumber(pwm);
|
|
|
- int pwmSensor = getSensorNumber(pwm);
|
|
|
- PwmFan *pwmPointer = m_hwmons.value(pwmHwmon, Q_NULLPTR)->pwmFan(pwmSensor);
|
|
|
- if (pwmPointer)
|
|
|
- pwmPointer->setMaxTemp(value);
|
|
|
+ QStringList nameValuePair = maxtemp.split('=');
|
|
|
+ if (nameValuePair.size() == 2)
|
|
|
+ {
|
|
|
+ QString pwm = nameValuePair.at(0);
|
|
|
+ int value = nameValuePair.at(1).toInt();
|
|
|
+ int pwmHwmon = getHwmonNumber(pwm);
|
|
|
+ int pwmSensor = getSensorNumber(pwm);
|
|
|
+ PwmFan *pwmPointer = m_hwmons.value(pwmHwmon, Q_NULLPTR)->pwmFan(pwmSensor);
|
|
|
+ if (pwmPointer)
|
|
|
+ pwmPointer->setMaxTemp(value);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else if (line.startsWith("MINSTART="))
|
|
|
{
|
|
|
+ line.remove("MINSTART=");
|
|
|
QStringList minstarts = line.split(' ');
|
|
|
- if (!minstarts.isEmpty())
|
|
|
- minstarts.first().remove("MINSTART=");
|
|
|
foreach (QString minstart, minstarts)
|
|
|
{
|
|
|
- QString pwm = minstart.split('=').at(0);
|
|
|
- int value = minstart.split('=').at(1).toInt();
|
|
|
- int pwmHwmon = getHwmonNumber(pwm);
|
|
|
- int pwmSensor = getSensorNumber(pwm);
|
|
|
- PwmFan *pwmPointer = m_hwmons.value(pwmHwmon, Q_NULLPTR)->pwmFan(pwmSensor);
|
|
|
- if (pwmPointer)
|
|
|
- pwmPointer->setMinStart(value);
|
|
|
+ QStringList nameValuePair = minstart.split('=');
|
|
|
+ if (nameValuePair.size() == 2)
|
|
|
+ {
|
|
|
+ QString pwm = nameValuePair.at(0);
|
|
|
+ int value = nameValuePair.at(1).toInt();
|
|
|
+ int pwmHwmon = getHwmonNumber(pwm);
|
|
|
+ int pwmSensor = getSensorNumber(pwm);
|
|
|
+ PwmFan *pwmPointer = m_hwmons.value(pwmHwmon, Q_NULLPTR)->pwmFan(pwmSensor);
|
|
|
+ if (pwmPointer)
|
|
|
+ pwmPointer->setMinStart(value);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else if (line.startsWith("MINSTOP="))
|
|
|
{
|
|
|
+ line.remove("MINSTOP=");
|
|
|
QStringList minstops = line.split(' ');
|
|
|
- if (!minstops.isEmpty())
|
|
|
- minstops.first().remove("MINSTOP=");
|
|
|
foreach (QString minstop, minstops)
|
|
|
{
|
|
|
- QString pwm = minstop.split('=').at(0);
|
|
|
- int value = minstop.split('=').at(1).toInt();
|
|
|
- int pwmHwmon = getHwmonNumber(pwm);
|
|
|
- int pwmSensor = getSensorNumber(pwm);
|
|
|
- PwmFan *pwmPointer = m_hwmons.value(pwmHwmon, Q_NULLPTR)->pwmFan(pwmSensor);
|
|
|
- if (pwmPointer)
|
|
|
- pwmPointer->setMinStop(value);
|
|
|
+ QStringList nameValuePair = minstop.split('=');
|
|
|
+ if (nameValuePair.size() == 2)
|
|
|
+ {
|
|
|
+ QString pwm = nameValuePair.at(0);
|
|
|
+ int value = nameValuePair.at(1).toInt();
|
|
|
+ int pwmHwmon = getHwmonNumber(pwm);
|
|
|
+ int pwmSensor = getSensorNumber(pwm);
|
|
|
+ PwmFan *pwmPointer = m_hwmons.value(pwmHwmon, Q_NULLPTR)->pwmFan(pwmSensor);
|
|
|
+ if (pwmPointer)
|
|
|
+ pwmPointer->setMinStop(value);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else if (line.startsWith("MINPWM="))
|
|
|
{
|
|
|
+ line.remove("MINPWM=");
|
|
|
QStringList minpwms = line.split(' ');
|
|
|
- if (!minpwms.isEmpty())
|
|
|
- minpwms.first().remove("MINPWM=");
|
|
|
foreach (QString minpwm, minpwms)
|
|
|
{
|
|
|
- QString pwm = minpwm.split('=').at(0);
|
|
|
- int value = minpwm.split('=').at(1).toInt();
|
|
|
- int pwmHwmon = getHwmonNumber(pwm);
|
|
|
- int pwmSensor = getSensorNumber(pwm);
|
|
|
- PwmFan *pwmPointer = m_hwmons.value(pwmHwmon, Q_NULLPTR)->pwmFan(pwmSensor);
|
|
|
- if (pwmPointer)
|
|
|
- pwmPointer->setMinPwm(value);
|
|
|
+ QStringList nameValuePair = minpwm.split('=');
|
|
|
+ if (nameValuePair.size() == 2)
|
|
|
+ {
|
|
|
+ QString pwm = nameValuePair.at(0);
|
|
|
+ int value = nameValuePair.at(1).toInt();
|
|
|
+ int pwmHwmon = getHwmonNumber(pwm);
|
|
|
+ int pwmSensor = getSensorNumber(pwm);
|
|
|
+ PwmFan *pwmPointer = m_hwmons.value(pwmHwmon, Q_NULLPTR)->pwmFan(pwmSensor);
|
|
|
+ if (pwmPointer)
|
|
|
+ pwmPointer->setMinPwm(value);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else if (line.startsWith("MAXPWM="))
|
|
|
{
|
|
|
+ line.remove("MAXPWM=");
|
|
|
QStringList maxpwms = line.split(' ');
|
|
|
- if (!maxpwms.isEmpty())
|
|
|
- maxpwms.first().remove("MAXPWM=");
|
|
|
foreach (QString maxpwm, maxpwms)
|
|
|
{
|
|
|
- QString pwm = maxpwm.split('=').at(0);
|
|
|
- int value = maxpwm.split('=').at(1).toInt();
|
|
|
- int pwmHwmon = getHwmonNumber(pwm);
|
|
|
- int pwmSensor = getSensorNumber(pwm);
|
|
|
- PwmFan *pwmPointer = m_hwmons.value(pwmHwmon, Q_NULLPTR)->pwmFan(pwmSensor);
|
|
|
- if (pwmPointer)
|
|
|
- pwmPointer->setMaxPwm(value);
|
|
|
+ QStringList nameValuePair = maxpwm.split('=');
|
|
|
+ if (nameValuePair.size() == 2)
|
|
|
+ {
|
|
|
+ QString pwm = nameValuePair.at(0);
|
|
|
+ int value = nameValuePair.at(1).toInt();
|
|
|
+ int pwmHwmon = getHwmonNumber(pwm);
|
|
|
+ int pwmSensor = getSensorNumber(pwm);
|
|
|
+ PwmFan *pwmPointer = m_hwmons.value(pwmHwmon, Q_NULLPTR)->pwmFan(pwmSensor);
|
|
|
+ if (pwmPointer)
|
|
|
+ pwmPointer->setMaxPwm(value);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ success();
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
-void Loader::save(const QUrl &url)
|
|
|
-{
|
|
|
- QString fileName = url.isEmpty() ? m_configUrl.toLocalFile() : url.toLocalFile();
|
|
|
+bool Loader::save(const QUrl &url)
|
|
|
+{
|
|
|
+ QString fileName;
|
|
|
+ if (url.isEmpty())
|
|
|
+ {
|
|
|
+ qDebug() << "Given empty url. Fallback to " << m_configUrl;
|
|
|
+ fileName = m_configUrl.toLocalFile();
|
|
|
+ }
|
|
|
+ else if (url.isLocalFile())
|
|
|
+ fileName = url.toLocalFile();
|
|
|
+
|
|
|
+ else
|
|
|
+ {
|
|
|
+ setError("Url is not a local file");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
QFile file(fileName);
|
|
|
|
|
|
if (file.open(QFile::WriteOnly | QFile::Text))
|
|
|
{
|
|
|
QTextStream stream(&file);
|
|
|
stream << m_configFile;
|
|
|
- qDebug() << m_configFile;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -308,10 +359,13 @@ void Loader::save(const QUrl &url)
|
|
|
|
|
|
if (!reply->exec())
|
|
|
{
|
|
|
- m_error = reply->errorString();
|
|
|
- emit errorChanged();
|
|
|
+ setError(reply->errorString());
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ success();
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
void Loader::createConfigFile()
|
|
@@ -334,102 +388,126 @@ void Loader::createConfigFile()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- m_configFile = "# This file was created by Fancontrol-GUI \n";
|
|
|
-
|
|
|
- m_configFile += "INTERVAL=" + QString::number(m_interval) + "\n";
|
|
|
-
|
|
|
- m_configFile += "DEVPATH=";
|
|
|
- foreach (Hwmon *hwmon, usedHwmons)
|
|
|
- {
|
|
|
- QString sanitizedPath = hwmon->path();
|
|
|
- sanitizedPath.remove(QRegExp("^/sys/"));
|
|
|
- sanitizedPath.remove(QRegExp("/hwmon/hwmon\\d\\s*$"));
|
|
|
- m_configFile += "hwmon" + QString::number(hwmon->index()) + "=" + sanitizedPath + " ";
|
|
|
- }
|
|
|
- m_configFile += "\n";
|
|
|
+ QString configFile = "# This file was created by Fancontrol-GUI \n";
|
|
|
|
|
|
- m_configFile += "DEVNAME=";
|
|
|
- foreach (Hwmon *hwmon, usedHwmons)
|
|
|
- {
|
|
|
- m_configFile += "hwmon" + QString::number(hwmon->index()) + "=" + hwmon->name().split('.').first() + " ";
|
|
|
- }
|
|
|
- m_configFile += "\n";
|
|
|
+ if (m_interval != 0)
|
|
|
+ configFile += "INTERVAL=" + QString::number(m_interval) + "\n";
|
|
|
|
|
|
- m_configFile += "FCTEMPS=";
|
|
|
- foreach (PwmFan *pwmFan, usedFans)
|
|
|
+ if (!usedHwmons.isEmpty())
|
|
|
{
|
|
|
- m_configFile += "hwmon" + QString::number(pwmFan->parent()->index()) + "/";
|
|
|
- m_configFile += "pwm" + QString::number(pwmFan->index()) + "=";
|
|
|
- m_configFile += "hwmon" + QString::number(pwmFan->temp()->parent()->index()) + "/";
|
|
|
- m_configFile += "temp" + QString::number(pwmFan->temp()->index()) + "_input ";
|
|
|
+ configFile += "DEVPATH=";
|
|
|
+ foreach (Hwmon *hwmon, usedHwmons)
|
|
|
+ {
|
|
|
+ QString sanitizedPath = hwmon->path();
|
|
|
+ sanitizedPath.remove(QRegExp("^/sys/"));
|
|
|
+ sanitizedPath.remove(QRegExp("/hwmon/hwmon\\d\\s*$"));
|
|
|
+ configFile += "hwmon" + QString::number(hwmon->index()) + "=" + sanitizedPath + " ";
|
|
|
+ }
|
|
|
+ configFile += "\n";
|
|
|
+
|
|
|
+ configFile += "DEVNAME=";
|
|
|
+ foreach (Hwmon *hwmon, usedHwmons)
|
|
|
+ {
|
|
|
+ configFile += "hwmon" + QString::number(hwmon->index()) + "=" + hwmon->name().split('.').first() + " ";
|
|
|
+ }
|
|
|
+ configFile += "\n";
|
|
|
+
|
|
|
+ if (!usedFans.isEmpty())
|
|
|
+ {
|
|
|
+ configFile += "FCTEMPS=";
|
|
|
+ foreach (PwmFan *pwmFan, usedFans)
|
|
|
+ {
|
|
|
+ configFile += "hwmon" + QString::number(pwmFan->parent()->index()) + "/";
|
|
|
+ configFile += "pwm" + QString::number(pwmFan->index()) + "=";
|
|
|
+ configFile += "hwmon" + QString::number(pwmFan->temp()->parent()->index()) + "/";
|
|
|
+ configFile += "temp" + QString::number(pwmFan->temp()->index()) + "_input ";
|
|
|
+ }
|
|
|
+ configFile += "\n";
|
|
|
+
|
|
|
+ configFile += "FCFANS=";
|
|
|
+ foreach (PwmFan *pwmFan, usedFans)
|
|
|
+ {
|
|
|
+ configFile += "hwmon" + QString::number(pwmFan->parent()->index()) + "/";
|
|
|
+ configFile += "pwm" + QString::number(pwmFan->index()) + "=";
|
|
|
+ configFile += "hwmon" + QString::number(pwmFan->parent()->index()) + "/";
|
|
|
+ configFile += "fan" + QString::number(pwmFan->index()) + "_input ";
|
|
|
+ }
|
|
|
+ configFile += "\n";
|
|
|
+
|
|
|
+ configFile += "MINTEMP=";
|
|
|
+ foreach (PwmFan *pwmFan, usedFans)
|
|
|
+ {
|
|
|
+ configFile += "hwmon" + QString::number(pwmFan->parent()->index()) + "/";
|
|
|
+ configFile += "pwm" + QString::number(pwmFan->index()) + "=";
|
|
|
+ configFile += QString::number(pwmFan->minTemp()) + " ";
|
|
|
+ }
|
|
|
+ configFile += "\n";
|
|
|
+
|
|
|
+ configFile += "MAXTEMP=";
|
|
|
+ foreach (PwmFan *pwmFan, usedFans)
|
|
|
+ {
|
|
|
+ configFile += "hwmon" + QString::number(pwmFan->parent()->index()) + "/";
|
|
|
+ configFile += "pwm" + QString::number(pwmFan->index()) + "=";
|
|
|
+ configFile += QString::number(pwmFan->maxTemp()) + " ";
|
|
|
+ }
|
|
|
+ configFile += "\n";
|
|
|
+
|
|
|
+ configFile += "MINSTART=";
|
|
|
+ foreach (PwmFan *pwmFan, usedFans)
|
|
|
+ {
|
|
|
+ configFile += "hwmon" + QString::number(pwmFan->parent()->index()) + "/";
|
|
|
+ configFile += "pwm" + QString::number(pwmFan->index()) + "=";
|
|
|
+ configFile += QString::number(pwmFan->minStart()) + " ";
|
|
|
+ }
|
|
|
+ configFile += "\n";
|
|
|
+
|
|
|
+ configFile += "MINSTOP=";
|
|
|
+ foreach (PwmFan *pwmFan, usedFans)
|
|
|
+ {
|
|
|
+ configFile += "hwmon" + QString::number(pwmFan->parent()->index()) + "/";
|
|
|
+ configFile += "pwm" + QString::number(pwmFan->index()) + "=";
|
|
|
+ configFile += QString::number(pwmFan->minStop()) + " ";
|
|
|
+ }
|
|
|
+ configFile += "\n";
|
|
|
+
|
|
|
+ configFile += "MINPWM=";
|
|
|
+ foreach (PwmFan *pwmFan, usedFans)
|
|
|
+ {
|
|
|
+ configFile += "hwmon" + QString::number(pwmFan->parent()->index()) + "/";
|
|
|
+ configFile += "pwm" + QString::number(pwmFan->index()) + "=";
|
|
|
+ configFile += QString::number(pwmFan->minPwm()) + " ";
|
|
|
+ }
|
|
|
+ configFile += "\n";
|
|
|
+
|
|
|
+ configFile += "MAXPWM=";
|
|
|
+ foreach (PwmFan *pwmFan, usedFans)
|
|
|
+ {
|
|
|
+ configFile += "hwmon" + QString::number(pwmFan->parent()->index()) + "/";
|
|
|
+ configFile += "pwm" + QString::number(pwmFan->index()) + "=";
|
|
|
+ configFile += QString::number(pwmFan->maxPwm()) + " ";
|
|
|
+ }
|
|
|
+ configFile += "\n";
|
|
|
+ }
|
|
|
}
|
|
|
- m_configFile += "\n";
|
|
|
|
|
|
- m_configFile += "FCFANS=";
|
|
|
- foreach (PwmFan *pwmFan, usedFans)
|
|
|
+ if (configFile != m_configFile)
|
|
|
{
|
|
|
- m_configFile += "hwmon" + QString::number(pwmFan->parent()->index()) + "/";
|
|
|
- m_configFile += "pwm" + QString::number(pwmFan->index()) + "=";
|
|
|
- m_configFile += "hwmon" + QString::number(pwmFan->parent()->index()) + "/";
|
|
|
- m_configFile += "fan" + QString::number(pwmFan->index()) + "_input ";
|
|
|
+ m_configFile = configFile;
|
|
|
+ emit configFileChanged();
|
|
|
}
|
|
|
- m_configFile += "\n";
|
|
|
-
|
|
|
- m_configFile += "MINTEMP=";
|
|
|
- foreach (PwmFan *pwmFan, usedFans)
|
|
|
- {
|
|
|
- m_configFile += "hwmon" + QString::number(pwmFan->parent()->index()) + "/";
|
|
|
- m_configFile += "pwm" + QString::number(pwmFan->index()) + "=";
|
|
|
- m_configFile += QString::number(pwmFan->minTemp()) + " ";
|
|
|
- }
|
|
|
- m_configFile += "\n";
|
|
|
-
|
|
|
- m_configFile += "MAXTEMP=";
|
|
|
- foreach (PwmFan *pwmFan, usedFans)
|
|
|
- {
|
|
|
- m_configFile += "hwmon" + QString::number(pwmFan->parent()->index()) + "/";
|
|
|
- m_configFile += "pwm" + QString::number(pwmFan->index()) + "=";
|
|
|
- m_configFile += QString::number(pwmFan->maxTemp()) + " ";
|
|
|
- }
|
|
|
- m_configFile += "\n";
|
|
|
-
|
|
|
- m_configFile += "MINSTART=";
|
|
|
- foreach (PwmFan *pwmFan, usedFans)
|
|
|
- {
|
|
|
- m_configFile += "hwmon" + QString::number(pwmFan->parent()->index()) + "/";
|
|
|
- m_configFile += "pwm" + QString::number(pwmFan->index()) + "=";
|
|
|
- m_configFile += QString::number(pwmFan->minStart()) + " ";
|
|
|
- }
|
|
|
- m_configFile += "\n";
|
|
|
-
|
|
|
- m_configFile += "MINSTOP=";
|
|
|
- foreach (PwmFan *pwmFan, usedFans)
|
|
|
- {
|
|
|
- m_configFile += "hwmon" + QString::number(pwmFan->parent()->index()) + "/";
|
|
|
- m_configFile += "pwm" + QString::number(pwmFan->index()) + "=";
|
|
|
- m_configFile += QString::number(pwmFan->minStop()) + " ";
|
|
|
- }
|
|
|
- m_configFile += "\n";
|
|
|
-
|
|
|
- m_configFile += "MINPWM=";
|
|
|
- foreach (PwmFan *pwmFan, usedFans)
|
|
|
- {
|
|
|
- m_configFile += "hwmon" + QString::number(pwmFan->parent()->index()) + "/";
|
|
|
- m_configFile += "pwm" + QString::number(pwmFan->index()) + "=";
|
|
|
- m_configFile += QString::number(pwmFan->minPwm()) + " ";
|
|
|
- }
|
|
|
- m_configFile += "\n";
|
|
|
+}
|
|
|
|
|
|
- m_configFile += "MAXPWM=";
|
|
|
- foreach (PwmFan *pwmFan, usedFans)
|
|
|
+void Loader::setInterval(int interval, bool writeNewConfig)
|
|
|
+{
|
|
|
+ if (interval != m_interval)
|
|
|
{
|
|
|
- m_configFile += "hwmon" + QString::number(pwmFan->parent()->index()) + "/";
|
|
|
- m_configFile += "pwm" + QString::number(pwmFan->index()) + "=";
|
|
|
- m_configFile += QString::number(pwmFan->maxPwm()) + " ";
|
|
|
+ m_interval = interval;
|
|
|
+ emit intervalChanged();
|
|
|
+ qDebug() << "Changed interval to" << interval;
|
|
|
+
|
|
|
+ if (writeNewConfig)
|
|
|
+ createConfigFile();
|
|
|
}
|
|
|
- m_configFile += "\n";
|
|
|
-
|
|
|
- emit configFileChanged();
|
|
|
}
|
|
|
|
|
|
void Loader::testFans()
|