| 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 "pmpowerstateprofilepart.h" |
| 8 | #include <QList> |
| 9 | #include <QObject> |
| 10 | #include <QString> |
| 11 | #include <string> |
| 12 | #include <vector> |
| 13 | |
| 14 | namespace AMD { |
| 15 | |
| 16 | class PMPowerStateQMLItem |
| 17 | : public QMLItem |
| 18 | , public AMD::PMPowerStateProfilePart::Importer |
| 19 | , public AMD::PMPowerStateProfilePart::Exporter |
| 20 | { |
| 21 | Q_OBJECT |
| 22 | |
| 23 | public: |
| 24 | explicit PMPowerStateQMLItem() noexcept; |
| 25 | |
| 26 | signals: |
| 27 | void modeChanged(QString const &mode); |
| 28 | void modesChanged(QList<QString> const &modes); |
| 29 | |
| 30 | public slots: |
| 31 | void changeMode(QString const &mode); |
| 32 | |
| 33 | public: |
| 34 | void activate(bool active) override; |
| 35 | |
| 36 | std::optional<std::reference_wrapper<Importable::Importer>> |
| 37 | provideImporter(Item const &i) override; |
| 38 | std::optional<std::reference_wrapper<Exportable::Exporter>> |
| 39 | provideExporter(Item const &i) override; |
| 40 | |
| 41 | bool provideActive() const override; |
| 42 | std::string const &providePMPowerStateMode() const override; |
| 43 | |
| 44 | void takeActive(bool active) override; |
| 45 | void takePMPowerStateMode(std::string const &mode) override; |
| 46 | |
| 47 | std::unique_ptr<Exportable::Exporter> |
| 48 | initializer(IQMLComponentFactory const &qmlComponentFactory, |
| 49 | QQmlApplicationEngine &qmlEngine) override; |
| 50 | |
| 51 | private: |
| 52 | class Initializer; |
| 53 | void takePMPowerStateModes(std::vector<std::string> const &modes); |
| 54 | |
| 55 | bool active_; |
| 56 | std::string mode_; |
| 57 | |
| 58 | static bool register_(); |
| 59 | static bool const registered_; |
| 60 | |
| 61 | static char const *const trStrings[]; |
| 62 | }; |
| 63 | |
| 64 | } // namespace AMD |