Bladeren bron

Improved fan testing

Maldela 9 jaren geleden
bovenliggende
commit
0077115fe5

+ 1 - 1
fancontrol-gui/package/contents/ui/PwmFansTab.qml

@@ -63,7 +63,7 @@ ColumnLayout {
         Layout.fillWidth: true
         active: !!tempModel && !!systemdCom && pwmFans.length > fanComboBox.currentIndex
 
-        sourceComponent: PwmFan {
+        sourceComponent: FanItem {
             unit: !!baseObject ? baseObject.unit : 0
             fan: pwmFans[fanComboBox.currentIndex]
             tempModel: root.tempModel

+ 3 - 3
import/CMakeLists.txt

@@ -9,11 +9,11 @@ set(LIB_SRCS src/hwmon.cpp
              src/pwmfanmodel.cpp
              src/tempmodel.cpp
              src/fancontrolqmlextension.cpp)
-             
+
 set(QML_FILES qml/qmldir
               qml/ErrorDialog.qml
               qml/OptionInput.qml
-              qml/PwmFan.qml
+              qml/FanItem.qml
               qml/PwmPoint.qml
               qml/StatusPoint.qml
               qml/colors.js
@@ -34,7 +34,7 @@ if(NOT NO_SYSTEMD)
 
     set(LIB_PRIVATE_LIBRARIES ${LIB_PRIVATE_LIBRARIES}
                               Qt5::DBus)
-                              
+
     find_package(Qt5DBus REQUIRED)
     include_directories(${Qt5DBus_INCLUDE_DIRS})
 

+ 7 - 1
import/qml/PwmFan.qml → import/qml/FanItem.qml

@@ -21,6 +21,7 @@
 import QtQuick 2.4
 import QtQuick.Controls 1.4
 import QtQuick.Layouts 1.1
+import Fancontrol.Qml 1.0 as Fancontrol
 import "math.js" as MoreMath
 import "units.js" as Units
 import "colors.js" as Colors
@@ -449,9 +450,10 @@ Rectangle {
                 Layout.fillWidth: true
             }
             Button {
+                id: testButton
+
                 property bool reactivateAfterTesting
 
-                id: testButton
                 text: !!fan ? fan.testing ? i18n("Abort test") : i18n("Test start and stop values") : ""
                 iconName: "dialog-password"
                 anchors.right: parent.right
@@ -466,6 +468,10 @@ Rectangle {
                         fan.test();
                     }
                 }
+                Connections {
+                    target: fan
+                    onTestStatusChanged: if (fan.testStatus === Fancontrol.PwmFan.Finished && testButton.reactivateAfterTesting) systemdCom.serviceActive = true
+                }
             }
         }
     }

+ 1 - 1
import/qml/qmldir

@@ -2,7 +2,7 @@ module Fancontrol.Qml
 plugin fancontrol_qml_plugin
 internal StatusPoint StatusPoint.qml
 internal PwmPoint PwmPoint.qml
-PwmFan 1.0 PwmFan.qml
+FanItem 1.0 FanItem.qml
 ErrorDialog 1.0 ErrorDialog.qml
 OptionInput 1.0 OptionInput.qml
 Units 1.0 units.js

+ 8 - 8
import/src/fancontrolqmlextension.cpp

@@ -1,6 +1,6 @@
 /*
  * Copyright 2016  Malte Veerman <maldela@halloarsch.de>
- * 
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
  * published by the Free Software Foundation; either version 2 of
@@ -8,15 +8,15 @@
  * accepted by the membership of KDE e.V. (or its successor approved
  * by the membership of KDE e.V.), which shall act as a proxy
  * defined in Section 14 of version 3 of the license.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- * 
+ *
  */
 
 #include "fancontrolqmlextension.h"
@@ -41,14 +41,14 @@ namespace Fancontrol
 void FancontrolQmlExtension::registerTypes(const char* uri)
 {
     Q_ASSERT(uri == QLatin1String("Fancontrol.Qml"));
-    
+
     qmlRegisterType<Loader>();
     qmlRegisterType<Hwmon>();
     qmlRegisterType<Fan>();
-    qmlRegisterType<PwmFan>();
+    qmlRegisterUncreatableType<PwmFan>(uri, 1, 0, "PwmFan", QStringLiteral("PwmFan is not instantiable from QML!"));
     qmlRegisterType<Temp>();
     qmlRegisterSingletonType<GUIBase>(uri, 1, 0, "base", base);
-    
+
 #ifndef NO_SYSTEMD
     qmlRegisterType<SystemdCommunicator>();
 #endif
@@ -58,7 +58,7 @@ QObject * FancontrolQmlExtension::base(QQmlEngine *engine, QJSEngine *jsengine)
 {
     Q_UNUSED(engine)
     Q_UNUSED(jsengine)
-    
+
     return new GUIBase;
 }
 

+ 6 - 6
kcm/package/contents/ui/KCM.qml

@@ -38,12 +38,12 @@ Item {
     id: root
     implicitWidth: 1024
     implicitHeight: 768
-    
+
     Connections {
         target: loader
         onConfigFileChanged: kcm.needsSave = true
     }
-    
+
     Connections {
         target: Fancontrol.base
         onMinTempChanged: kcm.needsSave = true
@@ -51,11 +51,11 @@ Item {
         onServiceNameChanged: kcm.needsSave = true
         onConfigUrlChanged: kcm.needsSave = true
     }
-    
+
     Connections {
         target: kcm
         onAboutToSave: {
-            base.save(true);
+            Fancontrol.base.save(true);
             if (systemdCom.serviceActive && enabledBox.checked) {
                 systemdCom.restartService();
             } else {
@@ -113,7 +113,7 @@ Item {
         visible: enabledBox.checked
 
         RowLayout {
-            visible: enabledBox.checked && pwmFanModel.count > 0
+            visible: enabledBox.checked && pwmFans.length > 0
 
             Label {
                 text: i18n("Fan:")
@@ -139,7 +139,7 @@ Item {
             Layout.fillWidth: true
             Layout.fillHeight: true
             active: !!pwmFans[fanComboBox.currentIndex]
-            sourceComponent: Fancontrol.PwmFan {
+            sourceComponent: Fancontrol.FanItem {
                 unit: Fancontrol.base.unit
                 fan: pwmFans[fanComboBox.currentIndex]
                 systemdCom: root.systemdCom