hwmon.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (C) 2015 Malte Veerman <maldela@halloarsch.de>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. *
  18. */
  19. #ifndef HWMON_H
  20. #define HWMON_H
  21. #include <QObject>
  22. #include <QString>
  23. #include <QList>
  24. #include "sensors.h"
  25. class Fan;
  26. class PwmFan;
  27. class Temp;
  28. class Loader;
  29. class Hwmon : public QObject
  30. {
  31. Q_OBJECT
  32. Q_PROPERTY(QString name READ name CONSTANT)
  33. Q_PROPERTY(QString path READ path CONSTANT)
  34. Q_PROPERTY(int index READ index CONSTANT)
  35. Q_PROPERTY(QList<QObject *> fans READ fans NOTIFY fansChanged)
  36. Q_PROPERTY(QList<QObject *> pwmFans READ pwmFans NOTIFY pwmFansChanged)
  37. Q_PROPERTY(QList<QObject *> temps READ temps NOTIFY tempsChanged)
  38. public:
  39. explicit Hwmon(const QString &, Loader *parent);
  40. void initialize();
  41. QString name() const { return m_name; }
  42. QString path() const { return m_path; }
  43. int index() const { return m_index; }
  44. QList<QObject *> fans() const;
  45. QList<QObject *> pwmFans() const;
  46. QList<QObject *> temps() const;
  47. Fan * fan(int i) const { return m_fans.value(i, Q_NULLPTR); }
  48. PwmFan * pwmFan(int i) const { return m_pwmFans.value(i, Q_NULLPTR); }
  49. Temp * temp(int i) const { return m_temps.value(i, Q_NULLPTR); }
  50. Q_INVOKABLE void testFans();
  51. public slots:
  52. void updateConfig() { emit configUpdateNeeded(); }
  53. void updateSensors() { emit sensorsUpdateNeeded(); }
  54. signals:
  55. void fansChanged();
  56. void pwmFansChanged();
  57. void tempsChanged();
  58. void configUpdateNeeded();
  59. void sensorsUpdateNeeded();
  60. protected:
  61. Loader *m_parent;
  62. QString m_name;
  63. QString m_path;
  64. int m_index;
  65. QList<Fan *> m_fans;
  66. QList<PwmFan *> m_pwmFans;
  67. QList<Temp *> m_temps;
  68. };
  69. #endif // HWMON_H