Plasma5Support

powermanagementengine.h
1/*
2 SPDX-FileCopyrightText: 2007 Aaron Seigo <aseigo@kde.org>
3 SPDX-FileCopyrightText: 2007-2008 Sebastian Kuegler <sebas@kde.org>
4 SPDX-FileCopyrightText: 2008 Dario Freddi <drf54321@gmail.com>
5
6 SPDX-License-Identifier: LGPL-2.0-only
7*/
8
9#pragma once
10
11#include <Plasma5Support/DataEngine>
12
13#include <solid/battery.h>
14
15#include <QDBusConnection>
16#include <QHash>
17#include <QPair>
18
20
21using InhibitionInfo = QPair<QString, QString>;
22
23/**
24 * This class provides runtime information about the battery and AC status
25 * for use in power management Plasma applets.
26 */
28{
30
31public:
33 ~PowermanagementEngine() override;
34 QStringList sources() const override;
35 Plasma5Support::Service *serviceForSource(const QString &source) override;
36
37protected:
38 bool sourceRequestEvent(const QString &name) override;
39 bool updateSourceEvent(const QString &source) override;
40 void init();
41
42private Q_SLOTS:
43 void updateBatteryChargeState(int newState, const QString &udi);
44 void updateBatteryPresentState(bool newState, const QString &udi);
45 void updateBatteryChargePercent(int newValue, const QString &udi);
46 void updateBatteryEnergy(double newValue, const QString &udi);
47 void updateBatteryPowerSupplyState(bool newState, const QString &udi);
48 void updateAcPlugState(bool onBattery);
49 void updateBatteryNames();
50 void updateOverallBattery();
51
52 void deviceRemoved(const QString &udi);
53 void deviceAdded(const QString &udi);
54 void batteryRemainingTimeChanged(qulonglong time);
55 void smoothedBatteryRemainingTimeChanged(qulonglong time);
56 void triggersLidActionChanged(bool triggers);
57 void hasInhibitionChanged(bool inhibited);
58 void inhibitionsChanged(const QList<InhibitionInfo> &added, const QStringList &removed);
59 void chargeStopThresholdChanged(int threshold);
60
61 void updatePowerProfileDaemonInstalled(const bool &installed);
62 void updatePowerProfileCurrentProfile(const QString &profile);
63 void updatePowerProfileChoices(const QStringList &choices);
64 void updatePowerProfilePerformanceInhibitedReason(const QString &reason);
65 void updatePowerProfilePerformanceDegradedReason(const QString &reason);
66 void updatePowerProfileHolds(const QList<QVariantMap> &holds);
67 void updatePowerProfileConfiguredProfile(const QString &profile);
68
69private:
70 template<typename ReplyType>
71 inline void createPowerManagementDBusMethodCallAndNotifyChanged(const QString &method, std::function<void(ReplyType)> &&callback);
72
73 template<typename ReplyType>
74 inline void createPowerProfileDBusMethodCallAndNotifyChanged(const QString &method, std::function<void(ReplyType)> &&callback);
75
76 void populateApplicationData(const QString &name, QString *prettyName, QString *icon);
77 QString batteryTypeToString(const Solid::Battery *battery) const;
78 QStringList basicSourceNames() const;
79 QString batteryStateToString(int newState) const;
80
81 QStringList m_sources;
82
83 QHash<QString, QString> m_batterySources; // <udi, Battery0>
84 QHash<QString, QPair<QString, QString>> m_applicationInfo; // <appname, <pretty name, icon>>
85
86 SessionManagement *m_session;
87};
Data provider for plasmoids (Plasma plugins)
Definition dataengine.h:45
This class provides a generic API for write access to settings or services.
Definition service.h:78
This class provides runtime information about the battery and AC status for use in power management P...
QStringList sources() const override
bool sourceRequestEvent(const QString &name) override
When a source that does not currently exist is requested by the consumer, this method is called to gi...
bool updateSourceEvent(const QString &source) override
Called by internal updating mechanisms to trigger the engine to refresh the data contained in a given...
Plasma5Support::Service * serviceForSource(const QString &source) override
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:57 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.