Forráskód Böngészése

Merge branch 'master' of https://github.com/Maldela/fancontrol-gui

Malte Veerman 10 éve
szülő
commit
45394fe185

+ 1 - 1
fancontrol-gui/src/main.cpp

@@ -53,7 +53,7 @@ int main(int argc, char *argv[])
     decl.setDeclarativeEngine(&engine);
     decl.setupBindings();
         
-    GUIBase base;
+    Fancontrol::GUIBase base;
     base.loader()->load();
     QObject::connect(&app, &QApplication::aboutToQuit, [&] () { base.save(false); });
     engine.rootContext()->setContextProperty("base", &base);

+ 1 - 0
kcm/src/fancontrolkcm.h

@@ -29,6 +29,7 @@
 
 
 using namespace KQuickAddons;
+using namespace Fancontrol;
 
 class FancontrolKCM : public ConfigModule
 {

+ 6 - 0
lib/src/config.cpp

@@ -23,8 +23,13 @@
 
 #include "config.h"
 
+
 #define CONFIG_NAME "fancontrol-gui"
 
+
+namespace Fancontrol
+{
+
 Config *Config::m_instance = Q_NULLPTR;
 
 Config::Config(QObject *parent) : KCoreConfigSkeleton(KSharedConfig::openConfig(CONFIG_NAME), parent)
@@ -45,5 +50,6 @@ Config* Config::instance()
     return m_instance;
 }
 
+}
 
 // #include "config.moc"

+ 5 - 0
lib/src/config.h

@@ -27,6 +27,9 @@
 #include <KConfigCore/KCoreConfigSkeleton>
 
 
+namespace Fancontrol
+{
+
 class Config : public KCoreConfigSkeleton
 {
     
@@ -50,4 +53,6 @@ private:
     QString m_serviceName;
 };
 
+}
+
 #endif // CONFIG_H

+ 5 - 0
lib/src/fan.cpp

@@ -31,6 +31,9 @@
 #include <KConfigCore/KConfigGroup>
 
 
+namespace Fancontrol
+{
+
 Fan::Fan(Hwmon *parent, uint index) : 
     Sensor(parent, index, QString(parent->name() + QString("/fan") + QString::number(index))),
     m_rpmStream(new QTextStream)
@@ -101,4 +104,6 @@ void Fan::update()
     m_rpmStream->seek(0);
     *m_rpmStream >> m_rpm;
     emit rpmChanged();
+}
+
 }

+ 5 - 0
lib/src/fan.h

@@ -27,6 +27,9 @@
 
 class QTextStream;
 
+namespace Fancontrol
+{
+
 class Fan : public Sensor
 {
     Q_OBJECT
@@ -62,4 +65,6 @@ protected:
     QTextStream *m_rpmStream;
 };
 
+}
+
 #endif // FAN_H

+ 5 - 0
lib/src/guibase.cpp

@@ -30,6 +30,9 @@
 #include <QtCore/QLocale>
 
 
+namespace Fancontrol
+{
+
 GUIBase::GUIBase(QObject *parent) : QObject(parent),    
     m_config(Config::instance()),
 
@@ -128,4 +131,6 @@ void GUIBase::emitConfigChanged()
     emit serviceNameChanged();
     emit minTempChanged();
     emit maxTempChanged();
+}
+
 }

+ 5 - 0
lib/src/guibase.h

@@ -39,6 +39,9 @@
 #include "fancontrol_gui_lib_export.h"
 
 
+namespace Fancontrol
+{
+
 class Config;
 
 class FANCONTROL_GUI_LIB_EXPORT GUIBase : public QObject
@@ -105,4 +108,6 @@ private:
     int m_unit;
 };
 
+}
+
 #endif // GUIBASE_H

+ 6 - 0
lib/src/hwmon.cpp

@@ -24,6 +24,10 @@
 #include <QtCore/QTextStream>
 #include <QtCore/QDebug>
 
+
+namespace Fancontrol
+{
+
 Hwmon::Hwmon(const QString &path, QObject *parent) : QObject(parent),
     m_path(path),
     m_index(path.split('/').last().remove("hwmon").toInt())
@@ -181,3 +185,5 @@ Temp* Hwmon::temp(int i) const
 {
     return m_temps.value(i, Q_NULLPTR);
 }
+
+}

+ 5 - 0
lib/src/hwmon.h

@@ -30,6 +30,9 @@
 #include "pwmfan.h"
 
 
+namespace Fancontrol
+{
+
 class Hwmon : public QObject
 {
     Q_OBJECT
@@ -83,4 +86,6 @@ private:
     QList<Temp *> m_temps;
 };
 
+}
+
 #endif // HWMON_H

+ 7 - 2
lib/src/loader.cpp

@@ -34,6 +34,9 @@
 #define HWMON_PATH "/sys/class/hwmon"
 
 
+namespace Fancontrol
+{
+
 //function that takes a config file entry and returns the hwmon and sensor numbers
 //returns a pair of <-1, -1> in case an error occurs
 QPair<int, int> getEntryNumbers(const QString &str)
@@ -606,7 +609,7 @@ QList<QObject *> Loader::hwmons() const
     return list;
 }
 
-QList< QObject* > Loader::allPwmFans() const
+QList<QObject *> Loader::allPwmFans() const
 {
     QList<QObject *> list;
     foreach (const Hwmon *hwmon, m_hwmons)
@@ -616,7 +619,7 @@ QList< QObject* > Loader::allPwmFans() const
     return list;
 }
 
-QList< QObject* > Loader::allTemps() const
+QList<QObject *> Loader::allTemps() const
 {
     QList<QObject *> list;
     foreach (const Hwmon *hwmon, m_hwmons)
@@ -636,3 +639,5 @@ void Loader::setError (const QString &error)
     }
     qWarning() << error;
 }
+
+}

+ 8 - 1
lib/src/loader.h

@@ -29,10 +29,15 @@
 
 #include "fancontrol_gui_lib_export.h"
 
+
+class QTimer;
+
+namespace Fancontrol
+{
+    
 class Hwmon;
 class PwmFan;
 class Temp;
-class QTimer;
 
 class FANCONTROL_GUI_LIB_EXPORT Loader : public QObject
 {
@@ -109,4 +114,6 @@ signals:
     void allTempsChanged();
 };
 
+}
+
 #endif // LOADER_H

+ 5 - 0
lib/src/pwmfan.cpp

@@ -39,6 +39,9 @@
 #define MAX_ERRORS_FOR_RPM_ZERO 10
 
 
+namespace Fancontrol
+{
+
 PwmFan::PwmFan(Hwmon *parent, uint index) : Fan(parent, index),
     m_pwmStream(new QTextStream),
     m_modeStream(new QTextStream),
@@ -351,4 +354,6 @@ void PwmFan::setActive(bool a)
         localActive.writeEntry("pwmfan" + QString::number(m_index), a);
         emit activeChanged();
     }
+}
+
 }

+ 6 - 0
lib/src/pwmfan.h

@@ -31,6 +31,9 @@
 
 class QTextStream;
 
+namespace Fancontrol
+{
+
 class PwmFan : public Fan
 {
     Q_OBJECT
@@ -131,4 +134,7 @@ private:
         Error
     } m_testStatus;
 };
+
+}
+
 #endif // PWMFAN_H

+ 5 - 0
lib/src/sensor.cpp

@@ -23,9 +23,14 @@
 #include "hwmon.h"
 
 
+namespace Fancontrol
+{
+
 Sensor::Sensor(Hwmon *parent, uint index, const QString &path) : QObject(parent),
     m_parent(parent),
     m_index(index),
     m_path(path)
 {
+}
+
 }

+ 5 - 0
lib/src/sensor.h

@@ -25,6 +25,9 @@
 #include <QtCore/QString>
 
 
+namespace Fancontrol
+{
+
 class Hwmon;
 
 class Sensor : public QObject
@@ -64,4 +67,6 @@ protected:
     const QString m_path;
 };
 
+}
+
 #endif // SENSOR_H

+ 21 - 23
lib/src/systemdcommunicator.cpp

@@ -28,9 +28,6 @@
 #include <KAuth/KAuthExecuteJob>
 
 
-using namespace KAuth;
-
-
 typedef struct
 {
     QString path;
@@ -41,10 +38,26 @@ Q_DECLARE_METATYPE(SystemdUnitFile)
 typedef QList<SystemdUnitFile> SystemdUnitFileList;
 Q_DECLARE_METATYPE(SystemdUnitFileList)
 
-QDBusArgument &operator <<(QDBusArgument &argument, const SystemdUnitFile &unitFile);
-const QDBusArgument &operator >>(const QDBusArgument &argument, SystemdUnitFile &unitFile);
+QDBusArgument& operator <<(QDBusArgument &argument, const SystemdUnitFile &unitFile)
+{
+    argument.beginStructure();
+    argument << unitFile.path << unitFile.state;
+    argument.endStructure();
+    return argument;
+}
+
+const QDBusArgument& operator >>(const QDBusArgument &argument, SystemdUnitFile &unitFile)
+{
+    argument.beginStructure();
+    argument >> unitFile.path >> unitFile.state;
+    argument.endStructure();
+    return argument;
+}
 
 
+namespace Fancontrol
+{
+
 SystemdCommunicator::SystemdCommunicator(const QString &serviceName, QObject *parent) : QObject(parent),
     m_error("Success"),
     m_managerInterface(new QDBusInterface("org.freedesktop.systemd1",
@@ -231,7 +244,7 @@ bool SystemdCommunicator::dbusAction(const QString &method, const QVariantList &
     {
         if (dbusreply.errorMessage() == "Interactive authentication required.")
         {
-            Action action("fancontrol.gui.helper.action");
+            KAuth::Action action("fancontrol.gui.helper.action");
             action.setHelperId("fancontrol.gui.helper");
             QVariantMap map;
             map["action"] = "dbusaction";
@@ -239,7 +252,7 @@ bool SystemdCommunicator::dbusAction(const QString &method, const QVariantList &
             map["arguments"] = arguments;
             action.setArguments(map);
 
-            ExecuteJob *reply = action.execute();
+            KAuth::ExecuteJob *reply = action.execute();
 
             if (!reply->exec())
             {
@@ -282,19 +295,4 @@ void SystemdCommunicator::updateServiceProperties(QString, QVariantMap propchang
         emit serviceEnabledChanged();
 }
 
-
-QDBusArgument& operator <<(QDBusArgument &argument, const SystemdUnitFile &unitFile)
-{
-    argument.beginStructure();
-    argument << unitFile.path << unitFile.state;
-    argument.endStructure();
-    return argument;
-}
-
-const QDBusArgument& operator >>(const QDBusArgument &argument, SystemdUnitFile &unitFile)
-{
-    argument.beginStructure();
-    argument >> unitFile.path >> unitFile.state;
-    argument.endStructure();
-    return argument;
-}
+}

+ 5 - 0
lib/src/systemdcommunicator.h

@@ -28,6 +28,9 @@
 
 class QDBusInterface;
 
+namespace Fancontrol
+{
+
 class FANCONTROL_GUI_LIB_EXPORT SystemdCommunicator : public QObject
 {
     Q_OBJECT
@@ -80,4 +83,6 @@ private:
     QDBusInterface *m_serviceInterface;
 };
 
+}
+
 #endif // SYSTEMDCOMMUNICATOR_H

+ 7 - 2
lib/src/temp.cpp

@@ -23,8 +23,6 @@
 
 #include "temp.h"
 
-#include "hwmon.h"
-
 #include <QtCore/QTextStream>
 #include <QtCore/QFile>
 #include <QtCore/QDir>
@@ -33,6 +31,11 @@
 #include <KConfigCore/KSharedConfig>
 #include <KConfigCore/KConfigGroup>
 
+#include "hwmon.h"
+
+
+namespace Fancontrol
+{
 
 Temp::Temp(Hwmon *parent, uint index) : 
     Sensor(parent, index, QString(parent->name() + QString("/temp") + QString::number(index))),
@@ -118,4 +121,6 @@ void Temp::update()
     *m_valueStream >> m_value;
     m_value /= 1000;
     emit valueChanged();
+}
+
 }

+ 5 - 0
lib/src/temp.h

@@ -30,6 +30,9 @@
 
 class QTextStream;
 
+namespace Fancontrol
+{
+
 class Temp : public Sensor
 {
     Q_OBJECT
@@ -66,4 +69,6 @@ private:
     QTextStream *m_valueStream;
 };
 
+}
+
 #endif // TEMP_H