Ver Fonte

fixed asynchronous fan testing

Malte Veerman há 9 anos atrás
pai
commit
9421b9444f

+ 14 - 20
lib/src/pwmfan.cpp

@@ -256,34 +256,28 @@ bool PwmFan::test()
         return false;
     }
     KAuth::ExecuteJob *job = action.execute(KAuth::Action::AuthorizeOnlyMode);
-    connect(job, SIGNAL(statusChanged(int)), this, SLOT(handleTestAuthReply(int)));
+    connect(job, SIGNAL(result(KJob*)), this, SLOT(handleTestAuthReply(KJob*)));
     job->start();
     
     return true;
 }
 
-void PwmFan::handleTestAuthReply(int authStatus)
+void PwmFan::handleTestAuthReply(KJob *job)
 {
-    switch (authStatus)
+    if (job->error())
     {
-        case KAuth::Action::AuthorizedStatus:
-        {
-            setPwmMode(1);
-            setPwm(255);
-            
-            m_testStatus = FindingStop1;
-            emit testingChanged();
-            
-            QTimer::singleShot(500, this, SLOT(continueTest()));
-            qDebug() << "Start testing...";
-            break;
-        }
-        case KAuth::Action::ErrorStatus:
-        {
-            emit errorChanged("Test action error");
-            break;
-        }
+        emit errorChanged(QString("test error:" + job->errorString() + job->errorText()));
+        return;
     }
+       
+    setPwmMode(1);
+    setPwm(255);
+    
+    m_testStatus = FindingStop1;
+    emit testingChanged();
+    
+    QTimer::singleShot(500, this, SLOT(continueTest()));
+    qDebug() << "Start testing...";
 }
 
 void PwmFan::abortTest()

+ 1 - 1
lib/src/pwmfan.h

@@ -106,7 +106,7 @@ protected slots:
     void continueTest();
     void handleSetPwmResult(KJob *job);
     void handleSetPwmModeResult(KJob *job);
-    void handleTestAuthReply(int authStatus);
+    void handleTestAuthReply(KJob *job);
 
 
 private:

+ 8 - 1
package/contents/ui/PwmFan.qml

@@ -129,6 +129,7 @@ Rectangle {
             size: canvas.fontSize
             visible: canvas.contains(Coordinates.centerOf(this)) && fan.hasTemp && canvas.drawingEnabled
             fan: root.fan
+            unit: root.unit
         }
         PwmPoint {
             id: stopPoint
@@ -291,7 +292,13 @@ Rectangle {
                 text: i18n("Controlled by:")
                 checked: fan.hasTemp
                 Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
-                onCheckedChanged: fan.hasTemp = checked
+                onCheckedChanged: {
+                    fan.hasTemp = checked;
+                    if (checked) {
+                        fan.temp = loader.allTemps[tempBox.currentIndex];
+                    }
+                    canvas.requestPaint();
+                }
             }
             RowLayout {                  
                 ComboBox {

+ 9 - 1
package/contents/ui/StatusPoint.qml

@@ -33,6 +33,7 @@ Rectangle {
     readonly property real centerX: x + width / 2
     readonly property real centerY: y + height / 2
     property int size: 10
+    property int unit: 0 
     
     width: size
     height: size
@@ -67,12 +68,19 @@ Rectangle {
         x: parent.width
         y: - height
         width: Math.max(pwm.width, rpm.width)
-        height: pwm.height + rpm.height
+        height: temp.height + pwm.height + rpm.height
         radius: 4
         color: Qt.rgba(parent.color.r, parent.color.g, parent.color.b, 0.5)
         visible: root.enabled && pwmMouse.containsMouse
         
         Column {
+            Label {
+                property string suffix: (unit == 0) ? "°C" : (unit == 1) ? "K" : "°F"
+                
+                id: temp
+                font.pixelSize: root.height * 1.5
+                text: (fan.hasTemp ? fan.temp.value : "0") + suffix
+            }
             Label {
                 id: pwm
                 font.pixelSize: root.height * 1.5