Browse Source

lots of fixes and improvements. should be usable again...

Malte Veerman 10 years ago
parent
commit
bb5ffea98e

+ 3 - 3
package/contents/ui/Application.qml

@@ -151,7 +151,7 @@ ApplicationWindow {
     Action {
     Action {
 	id: saveAction
 	id: saveAction
 	text: i18n("Save configuration file")
 	text: i18n("Save configuration file")
-        onTriggered: gui.loader.save()
+        onTriggered: base.loader.save()
         iconName: "document-save"
         iconName: "document-save"
 	tooltip: i18n("Save configuration file")
 	tooltip: i18n("Save configuration file")
 	shortcut: StandardKey.Save
 	shortcut: StandardKey.Save
@@ -166,7 +166,7 @@ ApplicationWindow {
         modality: Qt.NonModal
         modality: Qt.NonModal
 
 
         onAccepted: {
         onAccepted: {
-            gui.loader.load(fileUrl);
+            base.loader.load(fileUrl);
         }
         }
     }
     }
     FileDialog {
     FileDialog {
@@ -178,7 +178,7 @@ ApplicationWindow {
         modality: Qt.NonModal
         modality: Qt.NonModal
 
 
         onAccepted: {
         onAccepted: {
-            gui.loader.save(fileUrl);
+            base.loader.save(fileUrl);
         }
         }
     }
     }
 }
 }

+ 36 - 28
package/contents/ui/KCM.qml

@@ -20,41 +20,49 @@
 
 
 import QtQuick 2.4
 import QtQuick 2.4
 import QtQuick.Controls 1.3
 import QtQuick.Controls 1.3
+import QtQuick.Layouts 1.1
 import org.kde.kcm 1.0
 import org.kde.kcm 1.0
+import "../scripts/arrayfunctions.js" as ArrayFunctions
 
 
-TabView {
-    id: tabView
-    frameVisible: true
-    implicitHeight: 480
-    implicitWidth: 640
+ColumnLayout {
+    id: root
+    implicitWidth: 1024
+    implicitHeight: 768
     
     
-    Tab {
-        title: i18n("Sensors")
-        SensorsTab {
-            loader: kcm.base.loader
-        }
-    }
-    Tab {
-        title: i18n("PwmFans")
-        PwmFansTab {
-            size: 0.5
-            baseObject: kcm.base
-        }
+    CheckBox {
+        id: enabledBox
+        anchors.left: parent.left
+        anchors.right: parent.right
+        text: i18n("Control fans manually")
+        checked: kcm.base.systemdCom.serviceEnabled
+        onCheckedChanged: kcm.base.systemdCom.serviceEnabled = checked
     }
     }
-    Tab {
-        title: i18n("Configfile")
-        ConfigfileTab {
-            loader: kcm.base.loader
+    
+    RowLayout {
+        enabled: enabledBox.checked
+        
+        Label {
+            text: i18n("Fan:")
+            Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
+            renderType: Text.NativeRendering
         }
         }
-    }
-    Tab {
-        title: i18n("Settings")
-        SettingsTab {
-            baseObject: kcm.base
+        ComboBox {
+            id: fanCombobox
+            model: ArrayFunctions.names(kcm.base.loader.allPwmFans)
+            Layout.fillWidth: true
+            Layout.maximumWidth: 300
         }
         }
     }
     }
     
     
-    SystemPalette {
-        id: palette
+    PwmFan {
+        id: fan
+        enabled: enabledBox.checked
+        minimizable: false
+        fan: kcm.base.loader.allPwmFans[fanCombobox.currentIndex]
+        loader: kcm.base.loader
+        systemdCom: kcm.base.systemdCom
+        anchors.left: parent.left
+        anchors.right: parent.right
+        Layout.fillHeight: true
     }
     }
 }
 }

+ 43 - 38
package/contents/ui/PwmFan.qml

@@ -28,34 +28,41 @@ import "../scripts/coordinates.js" as Coordinates
 Rectangle {
 Rectangle {
     property QtObject fan
     property QtObject fan
     property QtObject loader
     property QtObject loader
+    property QtObject systemdCom
     property real minTemp: 30.0
     property real minTemp: 30.0
     property real maxTemp: 90.0
     property real maxTemp: 90.0
     property int margin: 5
     property int margin: 5
     property int minimizeDuration: 400
     property int minimizeDuration: 400
-    property real hwRatio
     property int unit: 0
     property int unit: 0
+    property bool minimizable: true
 
 
     id: root
     id: root
-    height: width * hwRatio
+    implicitWidth: 800
+    implicitHeight: 600
     color: "transparent"
     color: "transparent"
     border.color: "black"
     border.color: "black"
     border.width: 2
     border.width: 2
     radius: 10
     radius: 10
     clip: false
     clip: false
-    state: fan.active ? "" : "minimized"
+    state: fan.active ? "" : minimizable ? "minimized" : ""
 
 
     function update() {
     function update() {
-        hasTempCheckBox.checked = fan.hasTemp;
-        fanOffCheckBox.checked = (fan.minPwm == 0);
-        minStartInput.text = fan.minStart;
-        hwmonBox.currentIndex = fan.temp ? fan.temp.parent.index : 0;
-        tempBox.currentIndex = fan.temp ? fan.temp.index - 1 : 0;
+        if (fan) {
+            hasTempCheckBox.checked = Qt.binding(function() { return fan.hasTemp; })
+            fanOffCheckBox.checked = Qt.binding(function() { return (fan.minPwm == 0); })
+            minStartInput.text = Qt.binding(function() { return fan.minStart; })
+            if (fan.hasTemp) {
+                hwmonBox.currentIndex = fan.temp.parent.index;
+                tempBox.currentIndex = fan.temp.index - 1;
+            }
+        }
         canvas.requestPaint();
         canvas.requestPaint();
     }
     }
     
     
     onFanChanged: update()
     onFanChanged: update()
-    onLoaderChanged: update()
     onUnitChanged: update()
     onUnitChanged: update()
+    onMinTempChanged: update()
+    onMaxTempChanged: update()
     
     
     Connections {
     Connections {
         target: loader
         target: loader
@@ -93,10 +100,6 @@ Rectangle {
     SystemPalette {
     SystemPalette {
         id: palette
         id: palette
     }
     }
-    SystemPalette {
-        id: disabledPalette
-        colorGroup: SystemPalette.Disabled
-    }
 
 
     RowLayout {
     RowLayout {
         id: header
         id: header
@@ -136,6 +139,8 @@ Rectangle {
             Layout.alignment: Qt.AlignTop
             Layout.alignment: Qt.AlignTop
             color: collapseMouseArea.containsMouse ? "red" : "transparent"
             color: collapseMouseArea.containsMouse ? "red" : "transparent"
             radius: width / 2
             radius: width / 2
+            visible: minimizable
+            enabled: minimizable
 
 
             Label {
             Label {
                 anchors.fill: parent
                 anchors.fill: parent
@@ -198,7 +203,7 @@ Rectangle {
             drag.minimumY: Math.max(canvas.scaleY(canvas.scalePwm(maxPoint.y)-1), maxPoint.y+1)
             drag.minimumY: Math.max(canvas.scaleY(canvas.scalePwm(maxPoint.y)-1), maxPoint.y+1)
             x: canvas.scaleX(MoreMath.bound(minTemp, fan.minTemp, maxTemp)) - width/2
             x: canvas.scaleX(MoreMath.bound(minTemp, fan.minTemp, maxTemp)) - width/2
             y: canvas.scaleY(fan.minStop) - height/2
             y: canvas.scaleY(fan.minStop) - height/2
-            visible: parent.contains(Coordinates.centerOf(this))
+            visible: parent.contains(Coordinates.centerOf(this)) && parent.height > 0
             drag.onActiveChanged: {
             drag.onActiveChanged: {
                 if (!drag.active) {
                 if (!drag.active) {
                     fan.minStop = canvas.scalePwm(centerY);
                     fan.minStop = canvas.scalePwm(centerY);
@@ -215,7 +220,7 @@ Rectangle {
             drag.maximumY: stopPoint.y
             drag.maximumY: stopPoint.y
             x: canvas.scaleX(MoreMath.bound(minTemp, fan.maxTemp, maxTemp)) - width/2
             x: canvas.scaleX(MoreMath.bound(minTemp, fan.maxTemp, maxTemp)) - width/2
             y: canvas.scaleY(fan.maxPwm) - height/2
             y: canvas.scaleY(fan.maxPwm) - height/2
-            visible: parent.contains(Coordinates.centerOf(this))
+            visible: parent.contains(Coordinates.centerOf(this)) && parent.height > 0
             drag.onActiveChanged: {
             drag.onActiveChanged: {
                 if (!drag.active) {
                 if (!drag.active) {
                     fan.maxPwm = canvas.scalePwm(centerY);
                     fan.maxPwm = canvas.scalePwm(centerY);
@@ -334,9 +339,6 @@ Rectangle {
         spacing: 2
         spacing: 2
 
 
         RowLayout {
         RowLayout {
-            spacing: 0
-            width: parent.width
-
             CheckBox {
             CheckBox {
                 id: hasTempCheckBox
                 id: hasTempCheckBox
                 text: i18n("Controlled by:")
                 text: i18n("Controlled by:")
@@ -348,18 +350,17 @@ Rectangle {
                 Layout.fillWidth: true
                 Layout.fillWidth: true
                 
                 
                 ComboBox {
                 ComboBox {
-                property QtObject hwmon: loader.hwmons[currentIndex]
+                    property QtObject hwmon: loader.hwmons[currentIndex]
 
 
-                id: hwmonBox
-                width: (parent.width-slash.width) / 2
-                anchors.verticalCenter: parent.verticalCenter
-                model: ArrayFunctions.names(loader.hwmons)
-                enabled: hasTempCheckBox.checked
+                    id: hwmonBox
+                    width: (parent.width-slash.width) / 2
+                    anchors.verticalCenter: parent.verticalCenter
+                    model: ArrayFunctions.names(loader.hwmons)
+                    enabled: hasTempCheckBox.checked
                 }
                 }
                 Label {
                 Label {
                     id: slash
                     id: slash
                     text: "/"
                     text: "/"
-                    color: enabled ? palette.text : disabledPalette.text
                     anchors.verticalCenter: parent.verticalCenter
                     anchors.verticalCenter: parent.verticalCenter
                     verticalAlignment: Text.AlignVCenter
                     verticalAlignment: Text.AlignVCenter
                     enabled: hasTempCheckBox.checked
                     enabled: hasTempCheckBox.checked
@@ -395,51 +396,55 @@ Rectangle {
         }
         }
 
 
         RowLayout {
         RowLayout {
-            anchors.left: parent.left
-            anchors.right: parent.right
-
             Label {
             Label {
                 text: i18n("Pwm value for fan to start:")
                 text: i18n("Pwm value for fan to start:")
                 Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
                 Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
                 enabled: fanOffCheckBox.checked && fanOffCheckBox.enabled
                 enabled: fanOffCheckBox.checked && fanOffCheckBox.enabled
-                color: enabled ? palette.text : disabledPalette.text
                 renderType: Text.NativeRendering
                 renderType: Text.NativeRendering
             }
             }
             OptionInput {
             OptionInput {
                 id: minStartInput
                 id: minStartInput
-                anchors.right: parent.right
-                width: 50
+                Layout.fillWidth: true
                 enabled: fanOffCheckBox.checked && fanOffCheckBox.enabled
                 enabled: fanOffCheckBox.checked && fanOffCheckBox.enabled
                 text: fan.minStart
                 text: fan.minStart
-                onTextChanged: fan.minStart = text
+                onTextChanged: fan.minStart = parseInt(text)
             }
             }
         }
         }
 
 
         RowLayout {
         RowLayout {
-            anchors.left: parent.left
-            anchors.right: parent.right
-
+            visible: systemdCom
+            
             Label {
             Label {
                 text: i18n("Test start and stop values")
                 text: i18n("Test start and stop values")
                 Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
                 Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
                 enabled: fanOffCheckBox.checked && fanOffCheckBox.enabled
                 enabled: fanOffCheckBox.checked && fanOffCheckBox.enabled
-                color: enabled ? palette.text : disabledPalette.text
                 renderType: Text.NativeRendering
                 renderType: Text.NativeRendering
             }
             }
+            Item {
+                Layout.fillWidth: true
+            }
             Button {
             Button {
+                id: testButton
+                property bool reactivateAfterTesting
                 text: fan.testing? i18n("Abort") : i18n("Test")
                 text: fan.testing? i18n("Abort") : i18n("Test")
                 anchors.right: parent.right
                 anchors.right: parent.right
                 height: hwmonBox.height
                 height: hwmonBox.height
                 onClicked: {
                 onClicked: {
                     if (fan.testing) {
                     if (fan.testing) {
-                        systemdCom.dbusAction("StartUnit", [systemdCom.serviceName + ".service", "replace"]);
                         fan.abortTesting();
                         fan.abortTesting();
+                        systemdCom.serviceActive = true;
                     } else {
                     } else {
-                        systemdCom.dbusAction("StopUnit", [systemdCom.serviceName + ".service", "replace"]);
+                        reactivateAfterTesting = systemdCom.serviceActive;
+                        systemdCom.serviceActive = false;
                         minStartInput.text = Qt.binding(function() { return fan.minStart });
                         minStartInput.text = Qt.binding(function() { return fan.minStart });
                         fan.test();
                         fan.test();
                     }
                     }
                 }
                 }
+                
+                Connections {
+                    target: fan
+                    onTestingChanged: if (!fan.testing) systemdCom.serviceActive = testButton.reactivateAfterTesting
+                }
             }
             }
         }
         }
     }
     }

+ 7 - 5
package/contents/ui/PwmFansTab.qml

@@ -24,6 +24,7 @@ import "../scripts/arrayfunctions.js" as ArrayFunctions
 ScrollView {
 ScrollView {
     property QtObject baseObject
     property QtObject baseObject
     property QtObject loader: baseObject ? baseObject.loader : null
     property QtObject loader: baseObject ? baseObject.loader : null
+    property QtObject systemdCom: baseObject && baseObject.hasSystemdCommunicator() ? baseObject.systemdCom : null
     property real size: 1.0
     property real size: 1.0
 
 
     id: scrollView
     id: scrollView
@@ -49,9 +50,10 @@ ScrollView {
 
 
             PwmFan {
             PwmFan {
                 width: 1000 * size
                 width: 1000 * size
-                hwRatio: 0.8
+                height: 800 * size
                 fan: repeater.fans[index]
                 fan: repeater.fans[index]
                 loader: scrollView.loader
                 loader: scrollView.loader
+                systemdCom: scrollView.systemdCom
                 minTemp: baseObject.minTemp
                 minTemp: baseObject.minTemp
                 maxTemp: baseObject.maxTemp
                 maxTemp: baseObject.maxTemp
                 unit: baseObject.unit
                 unit: baseObject.unit
@@ -60,9 +62,9 @@ ScrollView {
     }
     }
     
     
     Label {
     Label {
-	anchors.margins: 10
-	visible: repeater.fans.length == 0
-	text: i18n("There are no pwm capable fans in your system.")
-	font.bold: true
+        anchors.margins: 10
+        visible: repeater.fans.length == 0
+        text: i18n("There are no pwm capable fans in your system.")
+        font.bold: true
     }
     }
 }
 }