Bläddra i källkod

Removed find sensors functionality

Malte Veerman 6 år sedan
förälder
incheckning
75b7a5295c

+ 9 - 10
fancontrol-gui/package/contents/ui/PwmFansTab.qml

@@ -60,11 +60,6 @@ Kirigami.Page {
                 onTriggered: systemdCom.serviceEnabled = !systemdCom.serviceEnabled
             }
         },
-        Kirigami.Action {
-            text: loader.sensorsDetected ? i18n("Detect fans again") : i18n("Detect fans")
-            icon.name: "dialog-password"
-            onTriggered: loader.detectSensors()
-        },
         Kirigami.Action {
             visible: !!systemdCom && !!fan
             text: !!fan ? fan.testing ? i18n("Abort test") : i18n("Test start and stop values") : ""
@@ -106,12 +101,16 @@ Kirigami.Page {
         }
     }
 
-    Label {
+    Loader {
         anchors.centerIn: parent
-        visible: pwmFanModel.length === 0
-        text: i18n("There are no pwm capable fans in your system.")
-        font.pointSize: 14
-        font.bold: true
+        active: pwmFanModel.length === 0
+
+        sourceComponent: Label {
+            text: i18n("There are no pwm capable fans in your system.\nTry running 'sensors-detect' in a terminal and restart this application.")
+            horizontalAlignment: Text.AlignHCenter
+            font.pointSize: 14
+            font.bold: true
+        }
     }
 
     Fancontrol.ProfilesDialog {

+ 0 - 21
helper/src/helper.cpp

@@ -21,7 +21,6 @@
 
 #include <QtCore/QFile>
 #include <QtCore/QTextStream>
-#include <QtCore/QProcess>
 #include <QtCore/QFileInfo>
 
 #include <KAuth/KAuthHelperSupport>
@@ -207,26 +206,6 @@ ActionReply Helper::action(const QVariantMap &arguments)
         }
     }
 
-    else if (arguments[QStringLiteral("action")] == "detectSensors")
-    {
-        const auto program = QStringLiteral("sensors-detect");
-        const auto arguments = QStringList() << QStringLiteral("--auto");
-
-        QProcess process;
-        process.start(program, arguments);
-
-        if (!process.waitForStarted(1000))
-        {
-            reply = ActionReply::HelperErrorReply();
-            reply.setErrorDescription(process.errorString());
-        }
-        else if (!process.waitForFinished(10000))
-        {
-            reply = ActionReply::HelperErrorReply();
-            reply.setErrorDescription(process.errorString());
-        }
-    }
-
     else
     {
         reply = ActionReply::HelperErrorReply();

+ 0 - 81
import/src/loader.cpp

@@ -758,87 +758,6 @@ void Loader::abortTestingFans()
         hwmon->abortTestingFans();
 }
 
-void Loader::detectSensors()
-{
-    emit info(i18n("Start detecting Sensors"));
-    auto program = QStringLiteral("sensors-detect");
-    auto arguments = QStringList() << QStringLiteral("--auto");
-
-    auto process = new QProcess(this);
-    process->start(program, arguments);
-
-    connect(process, static_cast<void(QProcess::*)(int)>(&QProcess::finished),
-            this, static_cast<void(Loader::*)(int)>(&Loader::handleDetectSensorsResult));
-}
-
-void Loader::handleDetectSensorsResult(int exitCode)
-{
-    auto process = qobject_cast<QProcess *>(sender());
-
-    if (exitCode)
-    {
-        if (process)
-            emit error(process->readAllStandardOutput());
-
-        auto action = newFancontrolAction();
-
-        if (action.isValid())
-        {
-            QVariantMap map;
-            map[QStringLiteral("action")] = QVariant("detectSensors");
-
-            action.setArguments(map);
-            auto job = action.execute();
-
-            connect(job, &KAuth::ExecuteJob::result, this, static_cast<void(Loader::*)(KJob *)>(&Loader::handleDetectSensorsResult));
-            job->start();
-        }
-        else
-            emit error(i18n("Action not supported! Try running the application as root."), true);
-    }
-    else
-    {
-        if (!m_sensorsDetected)
-        {
-            m_sensorsDetected = true;
-            emit sensorsDetectedChanged();
-        }
-
-        parseHwmons();
-    }
-
-    if (process)
-        process->deleteLater();
-
-    emit info(i18n("Finished detecting Sensors"));
-}
-
-void Loader::handleDetectSensorsResult(KJob *job)
-{
-    if (job->error())
-    {
-        if (job->error() == 4)
-        {
-//            qDebug() << "Aborted by user";
-            return;
-        }
-
-        emit error(job->errorString() + job->errorText(), true);
-    }
-    else
-    {
-        if (!m_sensorsDetected)
-        {
-            m_sensorsDetected = true;
-            emit sensorsDetectedChanged();
-        }
-
-        parseHwmons();
-    }
-
-    emit info(i18n("Finished detecting Sensors"));
-}
-
 QList<QObject *> Loader::hwmonsAsObjects() const
 {
     auto list = QList<QObject *>();

+ 0 - 7
import/src/loader.h

@@ -63,7 +63,6 @@ public:
     Q_INVOKABLE bool save(const QUrl & = QUrl());
     Q_INVOKABLE void testFans();
     Q_INVOKABLE void abortTestingFans();
-    Q_INVOKABLE void detectSensors();
 
     void load(const QString &config);
     QUrl configUrl() const { return m_configUrl; }
@@ -84,13 +83,7 @@ public:
     Fan *fan(int hwmonIndex, int fanIndex) const;
     void toDefault();
     bool needsSave() const { return m_config != m_configFileContent; }
-
-
-public slots:
-
     void updateConfig();
-    void handleDetectSensorsResult(KJob *job);
-    void handleDetectSensorsResult(int exitCode);
     void handleTestStatusChanged();
 
 

+ 8 - 18
kcm/package/contents/ui/KCM.qml

@@ -59,34 +59,24 @@ Kirigami.Page {
         onAboutToDefault: enabledBox.checked = false
     }
 
-    ColumnLayout {
-        id: noFansInfo
-
-        width: root.width
-        y: root.height / 2 - height / 2
-        spacing: Kirigami.Units.smallSpacing * 2
-        visible: pwmFanModel.length === 0
+    Loader {
+        anchors.centerIn: parent
+        active: pwmFanModel.length === 0
 
-        Label {
-            Layout.alignment: Qt.AlignCenter
-            text: i18n("There are no pwm capable fans in your system.")
+        sourceComponent: Label {
+            text: i18n("There are no pwm capable fans in your system.\nTry running 'sensors-detect' in a terminal and restart this application.")
+            horizontalAlignment: Text.AlignHCenter
             font.pointSize: 14
             font.bold: true
         }
-
-        Button {
-            Layout.alignment: Qt.AlignCenter
-            text: loader.sensorsDetected ? i18n("Detect fans again") : i18n("Detect fans")
-            icon.name: kcm.needsAuthorization ? "dialog-password" : ""
-            onClicked: loader.detectSensors()
-        }
     }
 
     header: CheckBox {
         id: enabledBox
 
         text: i18n("Control fans manually")
-        checked: systemdCom.serviceEnabled && systemdCom.serviceActive;
+        checked: systemdCom.serviceEnabled && systemdCom.serviceActive && pwmFanModel.length > 0
+        enabled: pwmFanModel.length > 0
         onCheckedChanged: {
             systemdCom.serviceActive = enabledBox.checked;
             loader.restartServiceAfterTesting = checked;