瀏覽代碼

fixed buttons default and reset in kcm

Malte Veerman 10 年之前
父節點
當前提交
64c6c14573
共有 3 個文件被更改,包括 24 次插入9 次删除
  1. 2 2
      kcm/src/fancontrolkcm.cpp
  2. 21 6
      lib/src/loader.cpp
  3. 1 1
      lib/src/loader.h

+ 2 - 2
kcm/src/fancontrolkcm.cpp

@@ -81,8 +81,8 @@ void FancontrolKCM::load()
 
 void FancontrolKCM::defaults() 
 {
-    m_base->systemdCommunicator()->setServiceEnabled(false);
-    m_base->systemdCommunicator()->setServiceActive(false);        
+    setManualControl(false);
+    setNeedsSave(true);
 }
 
 void FancontrolKCM::setManualControl(bool manualControl)

+ 21 - 6
lib/src/loader.cpp

@@ -77,6 +77,7 @@ void Loader::parseHwmons()
 
 bool Loader::load(const QUrl &url)
 {
+    qDebug() << "loading";
     QString fileName;
     if (url.isEmpty())
     {
@@ -93,14 +94,13 @@ bool Loader::load(const QUrl &url)
     
     QTextStream stream;
     QFile file(fileName);
+    QString fileContent;
 
     if (file.open(QFile::ReadOnly | QFile::Text))
     {
         stream.setDevice(&file);
-        m_configFile = stream.readAll();
-        emit configFileChanged();
+        fileContent = stream.readAll();
     }
-
     else if (file.exists())
     {
         KAuth::Action action("fancontrol.gui.helper.action");
@@ -117,8 +117,7 @@ bool Loader::load(const QUrl &url)
         }
         else
         {
-            m_configFile = reply->data()["content"].toString();
-            emit configFileChanged();
+            fileContent = reply->data()["content"].toString();
         }
     }
     else
@@ -129,13 +128,15 @@ bool Loader::load(const QUrl &url)
 
     foreach (Hwmon *hwmon, m_hwmons)
     {
+        disconnect(hwmon, SIGNAL(configUpdateNeeded()), this, SLOT(createConfigFile()));
         foreach (QObject *pwmFan, hwmon->pwmFans())
         {
             qobject_cast<PwmFan *>(pwmFan)->reset();
         }
+        connect(hwmon, SIGNAL(configUpdateNeeded()), this, SLOT(createConfigFile()));
     }
 
-    stream.setString(&m_configFile);
+    stream.setString(&fileContent);
     QStringList lines;
     do
     {
@@ -318,6 +319,9 @@ bool Loader::load(const QUrl &url)
     m_configUrl = url;
     emit configUrlChanged();
     
+    m_configFile = fileContent;
+    emit configFileChanged();
+    
     success();
     return true;
 }
@@ -550,6 +554,17 @@ QList< QObject* > Loader::allTemps() const
     return list;
 }
 
+void Loader::setError (const QString &error)
+{
+    if (error != m_error) 
+    {
+        m_error = error;
+        emit errorChanged();
+        
+    }
+    qDebug() << error;
+}
+
 int Loader::getHwmonNumber(const QString &str)
 {
     if (str.isEmpty())

+ 1 - 1
lib/src/loader.h

@@ -77,7 +77,7 @@ protected slots:
 
 protected:
     
-    void setError(const QString &error) { if (error != m_error) { m_error = error; emit errorChanged(); } }
+    void setError(const QString &error);
     void success() { setError("Success"); }
     
     int m_interval;