File indexing completed on 2024-05-19 05:29:58
0001 /* 0002 * SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <kde@privat.broulik.de> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include <QDebug> 0008 #include <QStandardPaths> 0009 0010 #include <QQmlContext> 0011 #include <QQmlEngine> 0012 #include <QStandardItemModel> 0013 #include <QtQml> 0014 0015 #include <Solid/Battery> 0016 #include <Solid/Device> 0017 #include <Solid/DeviceNotifier> 0018 0019 #include <KPluginFactory> 0020 #include <KQuickConfigModule> 0021 0022 #include "batterymodel.h" 0023 #include "statisticsprovider.h" 0024 0025 class KCMEnergyInfo : public KQuickConfigModule 0026 { 0027 Q_OBJECT 0028 Q_PROPERTY(BatteryModel *batteries READ batteries CONSTANT) 0029 public: 0030 explicit KCMEnergyInfo(QObject *parent, const KPluginMetaData &data) 0031 : KQuickConfigModule(parent, data) 0032 { 0033 qmlRegisterAnonymousType<BatteryModel>("org.kde.kinfocenter.energy.private", 1); 0034 0035 qmlRegisterType<StatisticsProvider>("org.kde.kinfocenter.energy.private", 1, 0, "HistoryModel"); 0036 qmlRegisterUncreatableType<BatteryModel>("org.kde.kinfocenter.energy.private", 1, 0, "BatteryModel", QStringLiteral("Use BatteryModel")); 0037 0038 m_batteries = new BatteryModel(this); 0039 } 0040 0041 BatteryModel *batteries() const 0042 { 0043 return m_batteries; 0044 } 0045 0046 private: 0047 BatteryModel *m_batteries = nullptr; 0048 }; 0049 0050 Q_DECLARE_METATYPE(QList<QPointF>) 0051 K_PLUGIN_CLASS_WITH_JSON(KCMEnergyInfo, "kcm_energyinfo.json") 0052 0053 #include "kcm.moc"