| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "core/qmlitem.h" |
| 7 | #include "fanfixedprofilepart.h" |
| 8 | #include <QObject> |
| 9 | |
| 10 | namespace AMD { |
| 11 | |
| 12 | class FanFixedQMLItem |
| 13 | : public QMLItem |
| 14 | , public AMD::FanFixedProfilePart::Importer |
| 15 | , public AMD::FanFixedProfilePart::Exporter |
| 16 | { |
| 17 | Q_OBJECT |
| 18 | |
| 19 | public: |
| 20 | explicit FanFixedQMLItem() noexcept; |
| 21 | |
| 22 | signals: |
| 23 | void valueChanged(int value); |
| 24 | void fanStopChanged(bool enabled); |
| 25 | void fanStartValueChanged(int value); |
| 26 | |
| 27 | public slots: |
| 28 | void changeValue(int value); |
| 29 | void enableFanStop(bool enabled); |
| 30 | void changeFanStartValue(int value); |
| 31 | |
| 32 | public: |
| 33 | void activate(bool active) override; |
| 34 | |
| 35 | std::optional<std::reference_wrapper<Importable::Importer>> |
| 36 | provideImporter(Item const &i) override; |
| 37 | std::optional<std::reference_wrapper<Exportable::Exporter>> |
| 38 | provideExporter(Item const &i) override; |
| 39 | |
| 40 | bool provideActive() const override; |
| 41 | units::concentration::percent_t provideFanFixedValue() const override; |
| 42 | bool provideFanFixedFanStop() const override; |
| 43 | units::concentration::percent_t provideFanFixedFanStartValue() const override; |
| 44 | |
| 45 | void takeActive(bool active) override; |
| 46 | void takeFanFixedValue(units::concentration::percent_t value) override; |
| 47 | void takeFanFixedFanStop(bool enabled) override; |
| 48 | void takeFanFixedFanStartValue(units::concentration::percent_t value) override; |
| 49 | |
| 50 | std::unique_ptr<Exportable::Exporter> |
| 51 | initializer(IQMLComponentFactory const &qmlComponentFactory, |
| 52 | QQmlApplicationEngine &qmlEngine) override; |
| 53 | |
| 54 | private: |
| 55 | class Initializer; |
| 56 | |
| 57 | bool active_; |
| 58 | |
| 59 | int value_; |
| 60 | bool fanStop_; |
| 61 | int fanStartValue_; |
| 62 | |
| 63 | static bool register_(); |
| 64 | static bool const registered_; |
| 65 | |
| 66 | static char const *const trStrings[]; |
| 67 | }; |
| 68 | |
| 69 | } // namespace AMD |