浏览代码

resolved conflict

Malte Veerman 10 年之前
父节点
当前提交
095b43c612

+ 3 - 4
fancontrol-gui/CMakeLists.txt

@@ -1,9 +1,8 @@
-set(Fancontrol_GUI_SRCS src/main.cpp
-                        src/gui.cpp)
+set(Fancontrol_GUI_SRCS src/main.cpp)
 
 
 set(LIBRARIES fancontrol_gui_lib
 set(LIBRARIES fancontrol_gui_lib
-	      Qt5::Widgets
-	      KF5::Declarative
+              Qt5::Widgets
+              KF5::Declarative
               KF5::I18n)
               KF5::I18n)
               
               
 find_package(Qt5Widgets REQUIRED)
 find_package(Qt5Widgets REQUIRED)

+ 4 - 3
fancontrol-gui/src/main.cpp

@@ -25,7 +25,7 @@
 #include <KPackage/PackageLoader>
 #include <KPackage/PackageLoader>
 #include <KAboutData>
 #include <KAboutData>
 
 
-#include "gui.h"
+#include "../lib/src/guibase.h"
 
 
 
 
 int main(int argc, char *argv[])
 int main(int argc, char *argv[])
@@ -52,8 +52,9 @@ int main(int argc, char *argv[])
     decl.setDeclarativeEngine(&engine);
     decl.setDeclarativeEngine(&engine);
     decl.setupBindings();
     decl.setupBindings();
         
         
-    GUI gui;
-    engine.rootContext()->setContextProperty("gui", &gui);
+    GUIBase base;
+    base.loader()->load();
+    engine.rootContext()->setContextProperty("base", &base);
     
     
     KPackage::Package package = KPackage::PackageLoader::self()->loadPackage("KPackage/GenericQML");
     KPackage::Package package = KPackage::PackageLoader::self()->loadPackage("KPackage/GenericQML");
     package.setDefaultPackageRoot("kpackage/kcms");
     package.setDefaultPackageRoot("kpackage/kcms");

+ 7 - 31
kcm/src/fancontrolkcm.cpp

@@ -27,20 +27,12 @@
 #include <KLocalizedString>
 #include <KLocalizedString>
 #include <KPluginFactory>
 #include <KPluginFactory>
 
 
-#include "../../lib/src/hwmon.h"
-#include "../../lib/src/sensors.h"
-
 
 
 K_PLUGIN_FACTORY_WITH_JSON(FancontrolKCMFactory, "kcm_fancontrol.json", registerPlugin<FancontrolKCM>();)
 K_PLUGIN_FACTORY_WITH_JSON(FancontrolKCMFactory, "kcm_fancontrol.json", registerPlugin<FancontrolKCM>();)
 
 
 FancontrolKCM::FancontrolKCM(QObject *parent, const QVariantList& args)
 FancontrolKCM::FancontrolKCM(QObject *parent, const QVariantList& args)
     : ConfigModule(parent, args),
     : ConfigModule(parent, args),
-
-#ifndef NO_SYSTEMD
-    m_communicator(new SystemdCommunicator(this)),
-#endif
-
-    m_loader(new Loader(this))
+    m_base(new GUIBase(this))
 {
 {
     KAboutData *about = new KAboutData("kcm_fancontrol",
     KAboutData *about = new KAboutData("kcm_fancontrol",
                                        i18n("Fancontrol-KCM"),
                                        i18n("Fancontrol-KCM"),
@@ -57,32 +49,16 @@ FancontrolKCM::FancontrolKCM(QObject *parent, const QVariantList& args)
     setButtons(Apply | Default);
     setButtons(Apply | Default);
     setAuthActionName("fancontrol.gui.helper.action");
     setAuthActionName("fancontrol.gui.helper.action");
     
     
-    connect(m_loader, &Loader::configFileChanged, [this] () { setNeedsSave(true);
-							      qDebug() << "Changes made..."; });
-    
-    qmlRegisterType<Loader>();
-    qmlRegisterType<Hwmon>();
-    qmlRegisterType<Fan>();
-    qmlRegisterType<PwmFan>();
-    qmlRegisterType<Temp>();
-    
-#ifndef NO_SYSTEMD
-    qmlRegisterType<SystemdCommunicator>();
-#endif
-    
-}
-
-FancontrolKCM::~FancontrolKCM() 
-{
+    connect(m_base->loader(), &Loader::configFileChanged, [this] () { setNeedsSave(true); });
 }
 }
 
 
 void FancontrolKCM::save()
 void FancontrolKCM::save()
 {
 {
     qDebug() << "saving...";
     qDebug() << "saving...";
-    setNeedsSave(!m_loader->save()
+    setNeedsSave(!m_base->loader()->save()
 
 
 #ifndef NO_SYSTEMD
 #ifndef NO_SYSTEMD
-		 || !m_communicator->restartService()
+		 || !m_base->systemdCommunicator()->restartService()
 #endif
 #endif
 
 
 		);
 		);
@@ -90,7 +66,7 @@ void FancontrolKCM::save()
 
 
 void FancontrolKCM::load()
 void FancontrolKCM::load()
 {
 {
-    setNeedsSave(!m_loader->load(QUrl::fromLocalFile("/etc/fancontrol")));
+    setNeedsSave(!m_base->loader()->load(QUrl::fromLocalFile("/etc/fancontrol")));
     qDebug() << "Loaded config file";
     qDebug() << "Loaded config file";
 }
 }
 
 
@@ -98,8 +74,8 @@ void FancontrolKCM::defaults()
 {
 {
     
     
 #ifndef NO_SYSTEMD
 #ifndef NO_SYSTEMD
-    m_communicator->setServiceEnabled(false);
-    m_communicator->setServiceActive(false);    
+    m_base->systemdCommunicator()->setServiceEnabled(false);
+    m_base->systemdCommunicator()->setServiceActive(false);    
 #endif
 #endif
     
     
 }
 }

+ 6 - 28
kcm/src/fancontrolkcm.h

@@ -25,55 +25,33 @@
 
 
 #include <KQuickAddons/ConfigModule>
 #include <KQuickAddons/ConfigModule>
 
 
-#include "../../lib/src/loader.h"
+#include "../lib/src/guibase.h"
 
 
-#ifndef NO_SYSTEMD
-#include "../../lib/src/systemdcommunicator.h"
-
-#define SYSTEMD_BOOL true
-#else
-#define SYSTEMD_BOOL false
-#endif
 
 
 using namespace KQuickAddons;
 using namespace KQuickAddons;
 
 
 class FancontrolKCM : public ConfigModule
 class FancontrolKCM : public ConfigModule
 {
 {
     Q_OBJECT
     Q_OBJECT
-    Q_PROPERTY(Loader* loader READ loader CONSTANT)
-    
-#ifndef NO_SYSTEMD
-    Q_PROPERTY(SystemdCommunicator* systemdCom READ systemdCommunicator CONSTANT)
-#endif
+    Q_PROPERTY(GUIBase *base READ base CONSTANT)
     
     
 public:
 public:
     
     
     explicit FancontrolKCM(QObject *parent, const QVariantList &args = QVariantList());
     explicit FancontrolKCM(QObject *parent, const QVariantList &args = QVariantList());
-    ~FancontrolKCM() Q_DECL_OVERRIDE;
     
     
-    Loader *loader() const { return m_loader; }
-        
-    Q_INVOKABLE bool hasSystemdCommunicator() const { return SYSTEMD_BOOL; }
+    QUIBase *base() const { return m_base; }
+    
     
     
-#ifndef NO_SYSTEMD
-    SystemdCommunicator *systemdCommunicator() const { return m_communicator; }
-#endif
-        
-        
 public slots:
 public slots:
     
     
     void load() Q_DECL_OVERRIDE;
     void load() Q_DECL_OVERRIDE;
     void save() Q_DECL_OVERRIDE;
     void save() Q_DECL_OVERRIDE;
     void defaults() Q_DECL_OVERRIDE;
     void defaults() Q_DECL_OVERRIDE;
-        
     
     
+
 protected:
 protected:
-        
-#ifndef NO_SYSTEMD
-    SystemdCommunicator *const m_communicator;
-#endif
     
     
-    Loader *const m_loader;
+    GUIBase *const m_base;
 };
 };
 
 
 #endif // FANCONTROLKCM_H
 #endif // FANCONTROLKCM_H

+ 6 - 5
lib/CMakeLists.txt

@@ -1,10 +1,11 @@
 set(LIB_SRCS src/hwmon.cpp
 set(LIB_SRCS src/hwmon.cpp
-	     src/loader.cpp
-	     src/sensors.cpp)
+             src/loader.cpp
+             src/sensors.cpp
+             src/guibase.cpp)
                         
                         
 set(LIB_PRIVATE_LIBRARIES Qt5::Qml
 set(LIB_PRIVATE_LIBRARIES Qt5::Qml
-			  KF5::Auth
-			  KF5::ConfigCore)
+                          KF5::Auth
+                          KF5::ConfigCore)
 
 
 set(LIB_PUBLIC_LIBRARIES Qt5::Core)
 set(LIB_PUBLIC_LIBRARIES Qt5::Core)
               
               
@@ -14,7 +15,7 @@ if(NOT NO_SYSTEMD)
                  src/systemdcommunicator.cpp)
                  src/systemdcommunicator.cpp)
 
 
     set(LIB_PUBLIC_LIBRARIES ${LIB_PUBLIC_LIBRARIES}
     set(LIB_PUBLIC_LIBRARIES ${LIB_PUBLIC_LIBRARIES}
-			     Qt5::DBus)
+                             Qt5::DBus)
 
 
 endif(NOT NO_SYSTEMD)
 endif(NOT NO_SYSTEMD)
 
 

+ 3 - 3
lib/src/hwmon.cpp

@@ -23,10 +23,10 @@
 #include <QtQml>
 #include <QtQml>
 #include <QDebug>
 #include <QDebug>
 
 
-Hwmon::Hwmon(const QString &path, Loader *parent) : QObject(parent)
+Hwmon::Hwmon(const QString &path, Loader *parent) : QObject(parent),
+    m_parent(parent),
+    m_path(path)
 {
 {
-    m_parent = parent;
-    m_path = path;
     m_index = path.split('/').last().remove("hwmon").toInt();
     m_index = path.split('/').last().remove("hwmon").toInt();
     QFile nameFile(path + "/name");
     QFile nameFile(path + "/name");
     if (nameFile.open(QFile::ReadOnly))
     if (nameFile.open(QFile::ReadOnly))

+ 14 - 16
lib/src/sensors.cpp

@@ -26,8 +26,8 @@
 #include <KF5/KAuth/KAuthExecuteJob>
 #include <KF5/KAuth/KAuthExecuteJob>
 
 
 Sensor::Sensor(Hwmon *parent, uint index) : QObject(parent),
 Sensor::Sensor(Hwmon *parent, uint index) : QObject(parent),
-                                            m_parent(parent),
-                                            m_index(index)
+    m_parent(parent),
+    m_index(index)
 {
 {
 }
 }
 
 
@@ -80,22 +80,20 @@ void Fan::update()
 }
 }
 
 
 
 
-PwmFan::PwmFan(Hwmon *parent, uint index) : Fan(parent, index)
+PwmFan::PwmFan(Hwmon *parent, uint index) : Fan(parent, index),
+    m_temp(Q_NULLPTR),
+    m_hasTemp(false),
+    m_testing(false),
+    m_minTemp(0),
+    m_maxTemp(100),
+    m_minPwm(255),
+    m_maxPwm(255),
+    m_minStart(255),
+    m_minStop(255),
+    m_testStatus(notTesting)
 {
 {
-    m_temp = Q_NULLPTR;
-    m_hasTemp = false;
-    m_minTemp = 0;
-    m_maxTemp = 100;
-    m_minPwm = 255;
-    m_maxPwm = 255;
-    m_minStart = 255;
-    m_minStop = 255;
-
     m_testTimer.setSingleShot(true);
     m_testTimer.setSingleShot(true);
 
 
-    m_testStatus = notTesting;
-    m_testing = false;
-
     connect(this, SIGNAL(tempChanged()), parent, SLOT(updateConfig()));
     connect(this, SIGNAL(tempChanged()), parent, SLOT(updateConfig()));
     connect(this, SIGNAL(hasTempChanged()), parent, SLOT(updateConfig()));
     connect(this, SIGNAL(hasTempChanged()), parent, SLOT(updateConfig()));
     connect(this, SIGNAL(minTempChanged()), parent, SLOT(updateConfig()));
     connect(this, SIGNAL(minTempChanged()), parent, SLOT(updateConfig()));
@@ -104,7 +102,7 @@ PwmFan::PwmFan(Hwmon *parent, uint index) : Fan(parent, index)
     connect(this, SIGNAL(maxPwmChanged()), parent, SLOT(updateConfig()));
     connect(this, SIGNAL(maxPwmChanged()), parent, SLOT(updateConfig()));
     connect(this, SIGNAL(minStartChanged()), parent, SLOT(updateConfig()));
     connect(this, SIGNAL(minStartChanged()), parent, SLOT(updateConfig()));
     connect(this, SIGNAL(minStopChanged()), parent, SLOT(updateConfig()));
     connect(this, SIGNAL(minStopChanged()), parent, SLOT(updateConfig()));
-    connect(&m_testTimer, SIGNAL(timeout()), this, SLOT(continueTesting()));
+    connect(&m_testTimer, SIGNAL(timeout()), this, SLOT(continueTest()));
 
 
     if (QDir(parent->path()).isReadable())
     if (QDir(parent->path()).isReadable())
     {
     {

+ 1 - 1
package/contents/scripts/units.js

@@ -18,7 +18,7 @@
  */
  */
 
 
 function round(number, dec) {
 function round(number, dec) {
-    if (!dec) dec = 5;
+    if (!dec || dec == 0) return Math.round(number);
     return Math.round(number*10*dec) / (10*dec);
     return Math.round(number*10*dec) / (10*dec);
 }
 }
 
 

+ 19 - 33
package/contents/ui/Application.qml

@@ -36,14 +36,14 @@ ApplicationWindow {
             MenuItem { action: loadAction }
             MenuItem { action: loadAction }
             MenuItem { action: saveAction }
             MenuItem { action: saveAction }
             MenuItem { 
             MenuItem { 
-		text: i18n("Save configuration file as")
-		onTriggered: saveFileDialog.open()
-		shortcut: StandardKey.SaveAs
-	    }
+                text: i18n("Save configuration file as")
+                onTriggered: saveFileDialog.open()
+                shortcut: StandardKey.SaveAs
+            }
             MenuItem {
             MenuItem {
                 text: i18n("Exit")
                 text: i18n("Exit")
                 onTriggered: Qt.quit()
                 onTriggered: Qt.quit()
-		shortcut: StandardKey.Quit
+                shortcut: StandardKey.Quit
             }
             }
         }
         }
     }
     }
@@ -55,19 +55,19 @@ ApplicationWindow {
             ToolButton { action: loadAction }
             ToolButton { action: loadAction }
             ToolButton { action: saveAction }
             ToolButton { action: saveAction }
             Loader {
             Loader {
-                active: gui.hasSystemdCommunicator()
+                active: base.hasSystemdCommunicator()
                 sourceComponent: ToolButton {
                 sourceComponent: ToolButton {
-                    iconName: gui.systemdCom.serviceActive ? "system-reboot" : "system-run"
-                    onClicked: gui.systemdCom.serviceActive ? gui.systemdCom.restartService() : gui.systemdCom.serviceActive = true;
-		    tooltip: gui.systemdCom.serviceActive ? i18n("Restart fancontrol") : i18n("Start fancontrol")
+                    iconName: base.systemdCom.serviceActive ? "system-reboot" : "system-run"
+                    onClicked: base.systemdCom.serviceActive ? base.systemdCom.restartService() : base.systemdCom.serviceActive = true;
+                    tooltip: base.systemdCom.serviceActive ? i18n("Restart fancontrol") : i18n("Start fancontrol")
                 }
                 }
             }
             }
             Loader {
             Loader {
-                active: gui.hasSystemdCommunicator()
+                active: base.hasSystemdCommunicator()
                 sourceComponent: ToolButton {
                 sourceComponent: ToolButton {
                     iconName: "system-shutdown"
                     iconName: "system-shutdown"
-                    enabled: gui.systemdCom.serviceActive
-                    onClicked: gui.systemdCom.serviceActive = false;
+                    enabled: base.systemdCom.serviceActive
+                    onClicked: base.systemdCom.serviceActive = false;
                     tooltip: i18n("Stop fancontrol")
                     tooltip: i18n("Stop fancontrol")
                 }
                 }
             }
             }
@@ -85,10 +85,6 @@ ApplicationWindow {
     }
     }
 
 
     TabView {
     TabView {
-        property real minTemp: 30.0
-        property real maxTemp: 90.0
-        property string unit: i18n("Celsius")
-
         id: tabView
         id: tabView
         anchors.fill: parent
         anchors.fill: parent
         anchors.topMargin: 5
         anchors.topMargin: 5
@@ -97,45 +93,35 @@ ApplicationWindow {
         Tab {
         Tab {
             title: i18n("Sensors")
             title: i18n("Sensors")
             SensorsTab {
             SensorsTab {
-                loader: gui.loader
+                loader: base.loader
             }
             }
         }
         }
         Tab {
         Tab {
             title: i18n("PwmFans")
             title: i18n("PwmFans")
             PwmFansTab {
             PwmFansTab {
                 size: sizeSlider.value
                 size: sizeSlider.value
-                minTemp: tabView.minTemp
-                maxTemp: tabView.maxTemp
-                unit: tabView.unit
-                loader: gui.loader
+                baseObject: base
             }
             }
         }
         }
         Tab {
         Tab {
             title: i18n("Configfile")
             title: i18n("Configfile")
             ConfigfileTab {
             ConfigfileTab {
-                loader: gui.loader
+                loader: base.loader
             }
             }
         }
         }
         Tab {
         Tab {
+            id: settingsTab
             title: i18n("Settings")
             title: i18n("Settings")
             SettingsTab {
             SettingsTab {
-                id: settingsTab
-                interval: gui.loader.interval
-                minTemp: tabView.minTemp
-                maxTemp: tabView.maxTemp
-                onMinTempChanged: tabView.minTemp = minTemp
-                onMaxTempChanged: tabView.maxTemp = maxTemp
-                onUnitChanged: tabView.unit = unit
-                loader: gui.loader
-                systemdCom: gui.hasSystemdCommunicator() ? gui.systemdCom : null
+                baseObject: base
             }
             }
         }
         }
     }
     }
 
 
     statusBar: StatusBar {
     statusBar: StatusBar {
         Label {
         Label {
-            property string systemdError: gui.hasSystemdCommunicator() ? gui.systemdCom.error : ""
-            property string loaderError: gui.loader.error
+            property string systemdError: base.hasSystemdCommunicator() ? base.systemdCom.error : ""
+            property string loaderError: base.loader.error
 
 
             color: "red"
             color: "red"
 
 

+ 5 - 5
package/contents/ui/KCM.qml

@@ -35,7 +35,7 @@ TabView {
     Tab {
     Tab {
         title: i18n("Sensors")
         title: i18n("Sensors")
         SensorsTab {
         SensorsTab {
-            loader: kcm.loader
+            loader: kcm.base.loader
         }
         }
     }
     }
     Tab {
     Tab {
@@ -45,13 +45,13 @@ TabView {
             minTemp: tabView.minTemp
             minTemp: tabView.minTemp
             maxTemp: tabView.maxTemp
             maxTemp: tabView.maxTemp
             unit: tabView.unit
             unit: tabView.unit
-            loader: kcm.loader
+            loader: kcm.base.loader
         }
         }
     }
     }
     Tab {
     Tab {
         title: i18n("Configfile")
         title: i18n("Configfile")
         ConfigfileTab {
         ConfigfileTab {
-            loader: kcm.loader
+            loader: kcm.base.loader
         }
         }
     }
     }
     Tab {
     Tab {
@@ -63,8 +63,8 @@ TabView {
             onMinTempChanged: tabView.minTemp = minTemp
             onMinTempChanged: tabView.minTemp = minTemp
             onMaxTempChanged: tabView.maxTemp = maxTemp
             onMaxTempChanged: tabView.maxTemp = maxTemp
             onUnitChanged: tabView.unit = unit
             onUnitChanged: tabView.unit = unit
-            loader: kcm.loader
-            systemdCom: kcm.hasSystemdCommunicator() ? kcm.systemdCom : null
+            loader: kcm.base.loader
+            systemdCom: kcm.base.hasSystemdCommunicator() ? kcm.base.systemdCom : null
         }
         }
     }
     }
     
     

+ 51 - 45
package/contents/ui/PwmFan.qml

@@ -20,7 +20,6 @@
 import QtQuick 2.4
 import QtQuick 2.4
 import QtQuick.Controls 1.4
 import QtQuick.Controls 1.4
 import QtQuick.Layouts 1.1
 import QtQuick.Layouts 1.1
-import QtQuick.Window 2.2
 import "../scripts/arrayfunctions.js" as ArrayFunctions
 import "../scripts/arrayfunctions.js" as ArrayFunctions
 import "../scripts/math.js" as MoreMath
 import "../scripts/math.js" as MoreMath
 import "../scripts/units.js" as Units
 import "../scripts/units.js" as Units
@@ -34,7 +33,7 @@ Rectangle {
     property int margin: 5
     property int margin: 5
     property int minimizeDuration: 400
     property int minimizeDuration: 400
     property real hwRatio
     property real hwRatio
-    property string unit: "Celsius"
+    property int unit: 0
 
 
     id: root
     id: root
     height: width * hwRatio
     height: width * hwRatio
@@ -54,8 +53,9 @@ Rectangle {
         canvas.requestPaint();
         canvas.requestPaint();
     }
     }
     
     
-    onFanChanged: update();
-    onLoaderChanged: update();
+    onFanChanged: update()
+    onLoaderChanged: update()
+    onUnitChanged: update()
     
     
     Connections {
     Connections {
         target: loader
         target: loader
@@ -156,10 +156,11 @@ Rectangle {
     }
     }
 
 
     Canvas {
     Canvas {
-        property int leftPadding: 40 * Screen.devicePixelRatio
-        property int rightPadding: 20 * Screen.devicePixelRatio
-        property int topPadding: 10 * Screen.devicePixelRatio
-        property int bottomPadding: 20 * Screen.devicePixelRatio
+        property int fontSize: Math.max(9, Math.min(height / 20, 20))
+        property int leftPadding: fontSize * 4
+        property int rightPadding: fontSize * 2
+        property int topPadding: fontSize
+        property int bottomPadding: fontSize * 2
         property int plotWidth: width - leftPadding - rightPadding
         property int plotWidth: width - leftPadding - rightPadding
         property int plotHeight: height - topPadding - bottomPadding
         property int plotHeight: height - topPadding - bottomPadding
         property alias minTemp: root.minTemp
         property alias minTemp: root.minTemp
@@ -183,7 +184,7 @@ Rectangle {
             id: currentPwm
             id: currentPwm
             x: parent.scaleX(fan.temp ? fan.temp.value : minTemp) - width/2
             x: parent.scaleX(fan.temp ? fan.temp.value : minTemp) - width/2
             y: parent.scaleY(fan.pwm) - height/2
             y: parent.scaleY(fan.pwm) - height/2
-            width: 7
+            width: canvas.fontSize
             height: width
             height: width
             radius: width / 2
             radius: width / 2
             color: "black"
             color: "black"
@@ -192,6 +193,7 @@ Rectangle {
         PwmPoint {
         PwmPoint {
             id: stopPoint
             id: stopPoint
             color: "blue"
             color: "blue"
+            size: canvas.fontSize
             drag.maximumX: Math.min(canvas.scaleX(canvas.scaleTemp(maxPoint.x)-1), maxPoint.x-1)
             drag.maximumX: Math.min(canvas.scaleX(canvas.scaleTemp(maxPoint.x)-1), maxPoint.x-1)
             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
@@ -208,6 +210,7 @@ Rectangle {
         PwmPoint {
         PwmPoint {
             id: maxPoint
             id: maxPoint
             color: "red"
             color: "red"
+            size: canvas.fontSize
             drag.minimumX: stopPoint.x
             drag.minimumX: stopPoint.x
             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
@@ -240,6 +243,7 @@ Rectangle {
 
 
         onPaint: {
         onPaint: {
             var c = canvas.getContext("2d");
             var c = canvas.getContext("2d");
+            c.font = canvas.fontSize + "px sans-serif";
 
 
             c.clearRect(0, 0, width, height);
             c.clearRect(0, 0, width, height);
             c.fillStyle = palette.base;
             c.fillStyle = palette.base;
@@ -299,7 +303,7 @@ Rectangle {
             var convertedMaxTemp = Units.fromCelsius(maxTemp, unit);
             var convertedMaxTemp = Units.fromCelsius(maxTemp, unit);
             for (i=convertedMinTemp; i<convertedMaxTemp; i+= 10) {
             for (i=convertedMinTemp; i<convertedMaxTemp; i+= 10) {
                 var x = scaleX(Units.toCelsius(i, unit));
                 var x = scaleX(Units.toCelsius(i, unit));
-                c.fillText(i + '°', x, height-15);
+                c.fillText(i + '°', x, topPadding+plotHeight+fontSize/2);
                 if (i != convertedMinTemp) {
                 if (i != convertedMinTemp) {
                     for (var j=scaleY(255); j<=scaleY(0); j+=20) {
                     for (var j=scaleY(255); j<=scaleY(0); j+=20) {
                         c.moveTo(x, j);
                         c.moveTo(x, j);
@@ -308,7 +312,7 @@ Rectangle {
                     c.stroke();
                     c.stroke();
                 }
                 }
             }
             }
-            c.fillText(convertedMaxTemp + '°', scaleX(maxTemp), height-15);
+            c.fillText(convertedMaxTemp + '°', scaleX(maxTemp), topPadding+plotHeight+fontSize/2);
         }
         }
     }
     }
 
 
@@ -327,59 +331,61 @@ Rectangle {
         visible: root.height >= header.height + height + 2*margin
         visible: root.height >= header.height + height + 2*margin
         opacity: canvas.opacity
         opacity: canvas.opacity
         clip: true
         clip: true
-        spacing: 0
+        spacing: 2
 
 
         RowLayout {
         RowLayout {
             spacing: 0
             spacing: 0
-            height: hwmonBox.height
-            anchors.left: parent.left
-            anchors.right: parent.right
+            width: parent.width
 
 
             CheckBox {
             CheckBox {
                 id: hasTempCheckBox
                 id: hasTempCheckBox
-                text: "Controlled by:"
+                text: i18n("Controlled by:")
                 checked: fan.hasTemp
                 checked: fan.hasTemp
                 Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
                 Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
                 onCheckedChanged: fan.hasTemp = checked
                 onCheckedChanged: fan.hasTemp = checked
             }
             }
-            Item {
+            Row {    
                 Layout.fillWidth: true
                 Layout.fillWidth: true
-            }
-            ComboBox {
-                property var hwmon: loader.hwmons[currentIndex]
+                
+                ComboBox {
+                property QtObject hwmon: loader.hwmons[currentIndex]
 
 
                 id: hwmonBox
                 id: hwmonBox
-                Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
+                width: (parent.width-slash.width) / 2
+                anchors.verticalCenter: parent.verticalCenter
                 model: ArrayFunctions.names(loader.hwmons)
                 model: ArrayFunctions.names(loader.hwmons)
                 enabled: hasTempCheckBox.checked
                 enabled: hasTempCheckBox.checked
-            }
-            Label {
-                text: "/"
-                color: enabled ? palette.text : disabledPalette.text
-                Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
-                verticalAlignment: Text.AlignVCenter
-                enabled: hasTempCheckBox.checked
-                renderType: Text.NativeRendering
-            }
-            ComboBox {
-                id: tempBox
-                Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
-                model: ArrayFunctions.names(hwmonBox.hwmon.temps)
-                enabled: hasTempCheckBox.checked
-                onCurrentIndexChanged: { 
-                    if (hasTempCheckBox.checked)
-                        fan.temp = hwmonBox.hwmon.temps[currentIndex];
                 }
                 }
-                onModelChanged: {
-                    if (hasTempCheckBox.checked)
-                        fan.temp = hwmonBox.hwmon.temps[currentIndex];
+                Label {
+                    id: slash
+                    text: "/"
+                    color: enabled ? palette.text : disabledPalette.text
+                    anchors.verticalCenter: parent.verticalCenter
+                    verticalAlignment: Text.AlignVCenter
+                    enabled: hasTempCheckBox.checked
+                    renderType: Text.NativeRendering
+                }
+                ComboBox {
+                    id: tempBox
+                    width: (parent.width-slash.width) / 2
+                    anchors.verticalCenter: parent.verticalCenter
+                    model: ArrayFunctions.names(hwmonBox.hwmon.temps)
+                    enabled: hasTempCheckBox.checked
+                    onCurrentIndexChanged: { 
+                        if (hasTempCheckBox.checked && hwmonBox.hwmon)
+                            fan.temp = hwmonBox.hwmon.temps[currentIndex];
+                    }
+                    onModelChanged: {
+                        if (hasTempCheckBox.checked && hwmonBox.hwmon)
+                            fan.temp = hwmonBox.hwmon.temps[currentIndex];
+                    }
                 }
                 }
             }
             }
         }
         }
 
 
         CheckBox {
         CheckBox {
             id: fanOffCheckBox
             id: fanOffCheckBox
-            text: "Turn Fan off if temp < MINTEMP"
+            text: i18n("Turn Fan off if temp < MINTEMP")
             enabled: hasTempCheckBox.checked
             enabled: hasTempCheckBox.checked
             checked: fan.minPwm == 0
             checked: fan.minPwm == 0
             onCheckedChanged: {
             onCheckedChanged: {
@@ -393,7 +399,7 @@ Rectangle {
             anchors.right: parent.right
             anchors.right: parent.right
 
 
             Label {
             Label {
-                text: "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
                 color: enabled ? palette.text : disabledPalette.text
@@ -414,14 +420,14 @@ Rectangle {
             anchors.right: parent.right
             anchors.right: parent.right
 
 
             Label {
             Label {
-                text: "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
                 color: enabled ? palette.text : disabledPalette.text
                 renderType: Text.NativeRendering
                 renderType: Text.NativeRendering
             }
             }
             Button {
             Button {
-                text: fan.testing? "Abort" : "Test"
+                text: fan.testing? i18n("Abort") : i18n("Test")
                 anchors.right: parent.right
                 anchors.right: parent.right
                 height: hwmonBox.height
                 height: hwmonBox.height
                 onClicked: {
                 onClicked: {

+ 6 - 8
package/contents/ui/PwmFansTab.qml

@@ -22,11 +22,9 @@ import QtQuick.Controls 1.4
 import "../scripts/arrayfunctions.js" as ArrayFunctions
 import "../scripts/arrayfunctions.js" as ArrayFunctions
 
 
 ScrollView {
 ScrollView {
-    property QtObject loader
+    property QtObject baseObject
+    property QtObject loader: baseObject ? baseObject.loader : null
     property real size: 1.0
     property real size: 1.0
-    property real minTemp: 30.0
-    property real maxTemp: 90.0
-    property string unit: "Celsius"
 
 
     id: scrollView
     id: scrollView
     anchors.fill: parent
     anchors.fill: parent
@@ -53,10 +51,10 @@ ScrollView {
                 width: 1000 * size
                 width: 1000 * size
                 hwRatio: 0.8
                 hwRatio: 0.8
                 fan: repeater.fans[index]
                 fan: repeater.fans[index]
-                loader: loader
-                minTemp: scrollView.minTemp
-                maxTemp: scrollView.maxTemp
-                unit: scrollView.unit
+                loader: scrollView.loader
+                minTemp: baseObject.minTemp
+                maxTemp: baseObject.maxTemp
+                unit: baseObject.unit
             }
             }
         }
         }
     }
     }

+ 3 - 2
package/contents/ui/PwmPoint.qml

@@ -27,6 +27,7 @@ Rectangle {
     readonly property real centerX: x + width / 2
     readonly property real centerX: x + width / 2
     readonly property real centerY: y + height / 2
     readonly property real centerY: y + height / 2
     property alias drag: pwmMouse.drag
     property alias drag: pwmMouse.drag
+    property alias size: root.width
 
 
     id: root
     id: root
     width: 10
     width: 10
@@ -65,12 +66,12 @@ Rectangle {
         Column {
         Column {
             Label {
             Label {
                 id: pwm
                 id: pwm
-                font.pointSize: 9
+                font.pixelSize: root.size
                 text: Math.round(canvas.scalePwm(root.centerY) / 2.55) + '%'
                 text: Math.round(canvas.scalePwm(root.centerY) / 2.55) + '%'
             }
             }
             Label {
             Label {
                 id: temp
                 id: temp
-                font.pointSize: 9
+                font.pixelSize: root.size
                 text: Math.round(canvas.scaleTemp(root.centerX)) + '°'
                 text: Math.round(canvas.scaleTemp(root.centerX)) + '°'
             }
             }
         }
         }

+ 19 - 13
package/contents/ui/SettingsTab.qml

@@ -24,13 +24,11 @@ import "../scripts/arrayfunctions.js" as ArrayFunctions
 import "../scripts/units.js" as Units
 import "../scripts/units.js" as Units
 
 
 Item {
 Item {
-    property QtObject loader
-    property QtObject systemdCom
-    property real minTemp: 30.0
-    property real maxTemp: 90.0
+    property QtObject baseObject
+    property QtObject loader: baseObject ? baseObject.loader : null
+    property QtObject systemdCom: baseObject ? baseObject.hasSystemdCommunicator() ? baseObject.systemdCom : null : null
     property int interval: loader ? loader.interval : 1
     property int interval: loader ? loader.interval : 1
     property int padding: 10
     property int padding: 10
-    property string unit: i18n("Celsius")
     property real textWidth: 0
     property real textWidth: 0
 
 
     id: root
     id: root
@@ -77,8 +75,13 @@ Item {
                 Layout.minimumWidth: implicitWidth
                 Layout.minimumWidth: implicitWidth
                 Layout.fillWidth: true
                 Layout.fillWidth: true
                 inputMethodHints: Qt.ImhDigitsOnly
                 inputMethodHints: Qt.ImhDigitsOnly
-                onTextChanged: if (activeFocus) minTemp = Units.toCelsius(text, unit)
-                Component.onCompleted: text = Units.fromCelsius(minTemp, unit)
+                onTextChanged: if (activeFocus) baseObject.minTemp = Units.toCelsius(text, baseObject.unit)
+                Component.onCompleted: text = Units.fromCelsius(baseObject.minTemp, baseObject.unit)
+                
+                Connections {
+                    target: baseObject
+                    onUnitChanged: minTempValue.text = Units.fromCelsius(baseObject.minTemp, baseObject.unit)
+                }
             }
             }
         }
         }
         RowLayout {
         RowLayout {
@@ -96,9 +99,13 @@ Item {
                 Layout.minimumWidth: implicitWidth
                 Layout.minimumWidth: implicitWidth
                 Layout.fillWidth: true
                 Layout.fillWidth: true
                 inputMethodHints: Qt.ImhDigitsOnly
                 inputMethodHints: Qt.ImhDigitsOnly
-                text: Units.fromCelsius(maxTemp, unit.currentText)
-                onTextChanged: if (activeFocus) maxTemp = Units.toCelsius(text, unit)
-                Component.onCompleted: text = Units.fromCelsius(maxTemp, unit)
+                onTextChanged: if (activeFocus) baseObject.maxTemp = Units.toCelsius(text, baseObject.unit)
+                Component.onCompleted: text = Units.fromCelsius(baseObject.maxTemp, baseObject.unit)
+                
+                Connections {
+                    target: baseObject
+                    onUnitChanged: maxTempValue.text = Units.fromCelsius(baseObject.maxTemp, baseObject.unit)
+                }
             }
             }
         }
         }
         RowLayout {
         RowLayout {
@@ -116,10 +123,9 @@ Item {
                 Layout.minimumWidth: implicitWidth
                 Layout.minimumWidth: implicitWidth
                 Layout.fillWidth: true
                 Layout.fillWidth: true
                 model: [i18n("Celsius"), i18n("Kelvin"), i18n("Fahrenheit")]
                 model: [i18n("Celsius"), i18n("Kelvin"), i18n("Fahrenheit")]
-                currentIndex: find(root.unit)
+                currentIndex: baseObject.unit
                 onCurrentIndexChanged: {
                 onCurrentIndexChanged: {
-                    minTempValue.text = Units.fromCelsius(minTemp, currentIndex);
-                    maxTempValue.text = Units.fromCelsius(maxTemp, currentIndex);
+                    baseObject.unit = currentIndex;
                 }
                 }
             }
             }
         }
         }