Przeglądaj źródła

small improvements to the kcm

Malte Veerman 10 lat temu
rodzic
commit
f3a9b244dc
2 zmienionych plików z 46 dodań i 38 usunięć
  1. 46 36
      package/contents/ui/KCM.qml
  2. 0 2
      package/contents/ui/PwmFan.qml

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

@@ -24,47 +24,57 @@ import QtQuick.Layouts 1.1
 import org.kde.kcm 1.0
 import "../scripts/arrayfunctions.js" as ArrayFunctions
 
-ColumnLayout {
-    id: root
+Item {
+    implicitWidth: 800
+    implicitHeight: 600
     
-    CheckBox {
-        id: enabledBox
-        Layout.alignment: Qt.AlignLeft | Qt.AlignTop
-        text: i18n("Control fans manually")
-        checked: kcm.manualControl
-        onCheckedChanged: {
-            kcm.manualControl = checked;
-            fanRow.visible = checked;
-            fan.visible = checked;
+    ColumnLayout {
+        anchors.fill: parent    
+        
+        CheckBox {
+            id: enabledBox
+            Layout.alignment: Qt.AlignLeft | Qt.AlignTop
+            text: i18n("Control fans manually")
+            checked: kcm.manualControl
         }
-    }
-    
-    RowLayout {  
-        id: fanRow
         
         Label {
-            text: i18n("Fan:")
-            Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
-            renderType: Text.NativeRendering
+            visible: enabledBox.checked && kcm.loader.allPwmFans.length == 0
+            text: i18n("There are no pwm capable fans in your system.")
+            anchors.top: enabledBox.bottom
+            anchors.margins: 20
+        }
+        
+        RowLayout {  
+            visible: enabledBox.checked && kcm.loader.allPwmFans.length > 0
+            
+            Label {
+                text: i18n("Fan:")
+                Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
+                renderType: Text.NativeRendering
+            }
+            ComboBox {
+                id: fanCombobox
+                model: ArrayFunctions.namesWithPaths(kcm.loader.allPwmFans)
+                Layout.fillWidth: true
+                Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
+            }
         }
-        ComboBox {
-            id: fanCombobox
-            model: ArrayFunctions.namesWithPaths(kcm.loader.allPwmFans)
-            Layout.fillWidth: true
-            Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
+        
+        Loader {
+            active: enabledBox.checked && !!kcm.loader.allPwmFans[fanCombobox.currentIndex]
+            sourceComponent: PwmFan {
+                id: fan
+                minimizable: false
+                unit: kcm.unit
+                fan: kcm.loader.allPwmFans[fanCombobox.currentIndex]
+                loader: kcm.loader
+                systemdCom: kcm.systemdCom
+                minTemp: kcm.minTemp
+                maxTemp: kcm.maxTemp
+                Layout.fillWidth: true
+                Layout.fillHeight: true
+            }
         }
     }
-    
-    PwmFan {
-        id: fan
-        minimizable: false
-        unit: kcm.unit
-        fan: kcm.loader.allPwmFans[fanCombobox.currentIndex]
-        loader: kcm.loader
-        systemdCom: kcm.systemdCom
-        minTemp: kcm.minTemp
-        maxTemp: kcm.maxTemp
-        Layout.fillWidth: true
-        Layout.fillHeight: true
-    }
 }

+ 0 - 2
package/contents/ui/PwmFan.qml

@@ -37,8 +37,6 @@ Rectangle {
     property bool minimizable: true
 
     id: root
-    implicitWidth: 800
-    implicitHeight: 600
     color: "transparent"
     border.color: "black"
     border.width: 2