service/upower: adopt bindable properties

This commit is contained in:
outfoxxed 2024-11-21 03:40:53 -08:00
parent d4deb11216
commit ff55ac874b
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
4 changed files with 162 additions and 107 deletions

View file

@ -53,13 +53,6 @@ UPower::UPower() {
} }
void UPower::init() { void UPower::init() {
QObject::connect(
&this->pOnBattery,
&dbus::AbstractDBusProperty::changed,
this,
&UPower::onBatteryChanged
);
this->serviceProperties.setInterface(this->service); this->serviceProperties.setInterface(this->service);
this->serviceProperties.updateAllViaGetAll(); this->serviceProperties.updateAllViaGetAll();
@ -143,8 +136,6 @@ UPowerDevice* UPower::displayDevice() { return this->mDisplayDevice; }
ObjectModel<UPowerDevice>* UPower::devices() { return &this->readyDevices; } ObjectModel<UPowerDevice>* UPower::devices() { return &this->readyDevices; }
bool UPower::onBattery() const { return this->pOnBattery.get(); }
UPower* UPower::instance() { UPower* UPower::instance() {
static UPower* instance = new UPower(); // NOLINT static UPower* instance = new UPower(); // NOLINT
return instance; return instance;
@ -173,6 +164,4 @@ ObjectModel<UPowerDevice>* UPowerQml::devices() { // NOLINT
return UPower::instance()->devices(); return UPower::instance()->devices();
} }
bool UPowerQml::onBattery() { return UPower::instance()->onBattery(); }
} // namespace qs::service::upower } // namespace qs::service::upower

View file

@ -21,7 +21,7 @@ class UPower: public QObject {
public: public:
[[nodiscard]] UPowerDevice* displayDevice(); [[nodiscard]] UPowerDevice* displayDevice();
[[nodiscard]] ObjectModel<UPowerDevice>* devices(); [[nodiscard]] ObjectModel<UPowerDevice>* devices();
[[nodiscard]] bool onBattery() const; QS_BINDABLE_GETTER(bool, bOnBattery, onBattery, bindableOnBattery);
static UPower* instance(); static UPower* instance();
@ -44,8 +44,10 @@ private:
QHash<QString, UPowerDevice*> mDevices; QHash<QString, UPowerDevice*> mDevices;
ObjectModel<UPowerDevice> readyDevices {this}; ObjectModel<UPowerDevice> readyDevices {this};
dbus::DBusPropertyGroup serviceProperties; Q_OBJECT_BINDABLE_PROPERTY(UPower, bool, bOnBattery, &UPower::onBatteryChanged);
dbus::DBusProperty<bool> pOnBattery {this->serviceProperties, "OnBattery"};
QS_DBUS_BINDABLE_PROPERTY_GROUP(UPower, serviceProperties);
QS_DBUS_PROPERTY_BINDING(UPower, pOnBattery, bOnBattery, serviceProperties, "OnBattery");
DBusUPowerService* service = nullptr; DBusUPowerService* service = nullptr;
}; };
@ -64,7 +66,7 @@ class UPowerQml: public QObject {
QSDOC_TYPE_OVERRIDE(ObjectModel<qs::service::upower::UPowerDevice>*); QSDOC_TYPE_OVERRIDE(ObjectModel<qs::service::upower::UPowerDevice>*);
Q_PROPERTY(UntypedObjectModel* devices READ devices CONSTANT); Q_PROPERTY(UntypedObjectModel* devices READ devices CONSTANT);
/// If the system is currently running on battery power, or discharging. /// If the system is currently running on battery power, or discharging.
Q_PROPERTY(bool onBattery READ onBattery NOTIFY onBatteryChanged); Q_PROPERTY(bool onBattery READ onBattery NOTIFY onBatteryChanged BINDABLE bindableOnBattery);
// clang-format on // clang-format on
public: public:
@ -72,7 +74,11 @@ public:
[[nodiscard]] UPowerDevice* displayDevice(); [[nodiscard]] UPowerDevice* displayDevice();
[[nodiscard]] ObjectModel<UPowerDevice>* devices(); [[nodiscard]] ObjectModel<UPowerDevice>* devices();
[[nodiscard]] static bool onBattery(); [[nodiscard]] static bool onBattery() { return UPower::instance()->onBattery(); }
[[nodiscard]] static QBindable<bool> bindableOnBattery() {
return UPower::instance()->bindableOnBattery();
}
signals: signals:
void displayDeviceChanged(); void displayDeviceChanged();

View file

@ -74,25 +74,18 @@ UPowerDevice::UPowerDevice(const QString& path, QObject* parent): QObject(parent
return; return;
} }
// clang-format off this->bIsLaptopBattery.setBinding([this]() {
QObject::connect(&this->pType, &AbstractDBusProperty::changed, this, &UPowerDevice::typeChanged); return this->bType == UPowerDeviceType::Battery && this->bPowerSupply;
QObject::connect(&this->pPowerSupply, &AbstractDBusProperty::changed, this, &UPowerDevice::powerSupplyChanged); });
QObject::connect(&this->pEnergy, &AbstractDBusProperty::changed, this, &UPowerDevice::energyChanged);
QObject::connect(&this->pEnergyCapacity, &AbstractDBusProperty::changed, this, &UPowerDevice::energyCapacityChanged);
QObject::connect(&this->pChangeRate, &AbstractDBusProperty::changed, this, &UPowerDevice::changeRateChanged);
QObject::connect(&this->pTimeToEmpty, &AbstractDBusProperty::changed, this, &UPowerDevice::timeToEmptyChanged);
QObject::connect(&this->pTimeToFull, &AbstractDBusProperty::changed, this, &UPowerDevice::timeToFullChanged);
QObject::connect(&this->pPercentage, &AbstractDBusProperty::changed, this, &UPowerDevice::percentageChanged);
QObject::connect(&this->pIsPresent, &AbstractDBusProperty::changed, this, &UPowerDevice::isPresentChanged);
QObject::connect(&this->pState, &AbstractDBusProperty::changed, this, &UPowerDevice::stateChanged);
QObject::connect(&this->pHealthPercentage, &AbstractDBusProperty::changed, this, &UPowerDevice::healthPercentageChanged);
QObject::connect(&this->pHealthPercentage, &AbstractDBusProperty::changed, this, &UPowerDevice::healthSupportedChanged);
QObject::connect(&this->pIconName, &AbstractDBusProperty::changed, this, &UPowerDevice::iconNameChanged);
QObject::connect(&this->pType, &AbstractDBusProperty::changed, this, &UPowerDevice::isLaptopBatteryChanged);
QObject::connect(&this->pNativePath, &AbstractDBusProperty::changed, this, &UPowerDevice::nativePathChanged);
QObject::connect(&this->deviceProperties, &DBusPropertyGroup::getAllFinished, this, &UPowerDevice::ready); this->bHealthSupported.setBinding([this]() { return this->bHealthPercentage != 0; });
// clang-format on
QObject::connect(
&this->deviceProperties,
&DBusPropertyGroup::getAllFinished,
this,
&UPowerDevice::ready
);
this->deviceProperties.setInterface(this->device); this->deviceProperties.setInterface(this->device);
this->deviceProperties.updateAllViaGetAll(); this->deviceProperties.updateAllViaGetAll();
@ -102,33 +95,48 @@ bool UPowerDevice::isValid() const { return this->device->isValid(); }
QString UPowerDevice::address() const { return this->device->service(); } QString UPowerDevice::address() const { return this->device->service(); }
QString UPowerDevice::path() const { return this->device->path(); } QString UPowerDevice::path() const { return this->device->path(); }
UPowerDeviceType::Enum UPowerDevice::type() const {
return static_cast<UPowerDeviceType::Enum>(this->pType.get());
}
bool UPowerDevice::powerSupply() const { return this->pPowerSupply.get(); }
qreal UPowerDevice::energy() const { return this->pEnergy.get(); }
qreal UPowerDevice::energyCapacity() const { return this->pEnergyCapacity.get(); }
qreal UPowerDevice::changeRate() const { return this->pChangeRate.get(); }
qlonglong UPowerDevice::timeToEmpty() const { return this->pTimeToEmpty.get(); }
qlonglong UPowerDevice::timeToFull() const { return this->pTimeToFull.get(); }
qreal UPowerDevice::percentage() const { return this->pPercentage.get() / 100; }
bool UPowerDevice::isPresent() const { return this->pIsPresent.get(); }
UPowerDeviceState::Enum UPowerDevice::state() const {
return static_cast<UPowerDeviceState::Enum>(this->pState.get());
}
qreal UPowerDevice::healthPercentage() const { return this->pHealthPercentage.get(); }
bool UPowerDevice::healthSupported() const { return this->healthPercentage() != 0; }
QString UPowerDevice::iconName() const { return this->pIconName.get(); }
bool UPowerDevice::isLaptopBattery() const {
return this->pType.get() == UPowerDeviceType::Battery && this->pPowerSupply.get();
}
QString UPowerDevice::nativePath() const { return this->pNativePath.get(); }
} // namespace qs::service::upower } // namespace qs::service::upower
namespace qs::dbus {
using namespace qs::service::upower;
DBusResult<qreal> DBusDataTransform<PowerPercentage>::fromWire(qreal wire) {
return DBusResult(wire * 0.01);
}
qreal DBusDataTransform<PowerPercentage>::toWire(const qreal& value) { return value * 100; }
DBusResult<UPowerDeviceState::Enum>
DBusDataTransform<UPowerDeviceState::Enum>::fromWire(quint32 wire) {
if (wire != UPowerDeviceType::Battery && wire >= UPowerDeviceState::Unknown
&& wire <= UPowerDeviceState::PendingDischarge)
{
return DBusResult(static_cast<UPowerDeviceState::Enum>(wire));
}
return DBusResult<UPowerDeviceState::Enum>(
QDBusError(QDBusError::InvalidArgs, QString("Invalid UPowerDeviceState: %1").arg(wire))
);
}
quint32 DBusDataTransform<UPowerDeviceState::Enum>::toWire(const UPowerDeviceState::Enum& value) {
return static_cast<quint32>(value);
}
DBusResult<UPowerDeviceType::Enum> DBusDataTransform<UPowerDeviceType::Enum>::fromWire(quint32 wire
) {
if (wire >= UPowerDeviceType::Unknown && wire <= UPowerDeviceType::BluetoothGeneric) {
return DBusResult(static_cast<UPowerDeviceType::Enum>(wire));
}
return DBusResult<UPowerDeviceType::Enum>(
QDBusError(QDBusError::InvalidArgs, QString("Invalid UPowerDeviceType: %1").arg(wire))
);
}
quint32 DBusDataTransform<UPowerDeviceType::Enum>::toWire(const UPowerDeviceType::Enum& value) {
return static_cast<quint32>(value);
}
} // namespace qs::dbus

View file

@ -80,49 +80,83 @@ public:
Q_INVOKABLE static QString toString(qs::service::upower::UPowerDeviceType::Enum type); Q_INVOKABLE static QString toString(qs::service::upower::UPowerDeviceType::Enum type);
}; };
struct PowerPercentage;
} // namespace qs::service::upower
namespace qs::dbus {
template <>
struct DBusDataTransform<qs::service::upower::UPowerDeviceState::Enum> {
using Wire = quint32;
using Data = qs::service::upower::UPowerDeviceState::Enum;
static DBusResult<Data> fromWire(Wire wire);
static Wire toWire(const Data& value);
};
template <>
struct DBusDataTransform<qs::service::upower::UPowerDeviceType::Enum> {
using Wire = quint32;
using Data = qs::service::upower::UPowerDeviceType::Enum;
static DBusResult<Data> fromWire(Wire wire);
static Wire toWire(const Data& value);
};
template <>
struct DBusDataTransform<qs::service::upower::PowerPercentage> {
using Wire = qreal;
using Data = qreal;
static DBusResult<Data> fromWire(Wire wire);
static Wire toWire(const Data& value);
};
} // namespace qs::dbus
namespace qs::service::upower {
///! A device exposed through the UPower system service. ///! A device exposed through the UPower system service.
class UPowerDevice: public QObject { class UPowerDevice: public QObject {
Q_OBJECT; Q_OBJECT;
// clang-format off // clang-format off
/// The type of device. /// The type of device.
Q_PROPERTY(qs::service::upower::UPowerDeviceType::Enum type READ type NOTIFY typeChanged); Q_PROPERTY(qs::service::upower::UPowerDeviceType::Enum type READ type NOTIFY typeChanged BINDABLE bindableType);
/// If the device is a power supply for your computer and can provide charge. /// If the device is a power supply for your computer and can provide charge.
Q_PROPERTY(bool powerSupply READ powerSupply NOTIFY powerSupplyChanged); Q_PROPERTY(bool powerSupply READ powerSupply NOTIFY powerSupplyChanged BINDABLE bindablePowerSupply);
/// Current energy level of the device in watt-hours. /// Current energy level of the device in watt-hours.
Q_PROPERTY(qreal energy READ energy NOTIFY energyChanged); Q_PROPERTY(qreal energy READ energy NOTIFY energyChanged BINDABLE bindableEnergy);
/// Maximum energy capacity of the device in watt-hours /// Maximum energy capacity of the device in watt-hours
Q_PROPERTY(qreal energyCapacity READ energyCapacity NOTIFY energyCapacityChanged); Q_PROPERTY(qreal energyCapacity READ energyCapacity NOTIFY energyCapacityChanged BINDABLE bindableEnergyCapacity);
/// Rate of energy change in watts (positive when charging, negative when discharging). /// Rate of energy change in watts (positive when charging, negative when discharging).
Q_PROPERTY(qreal changeRate READ changeRate NOTIFY changeRateChanged); Q_PROPERTY(qreal changeRate READ changeRate NOTIFY changeRateChanged BINDABLE bindableChangeRate);
/// Estimated time until the device is fully discharged, in seconds. /// Estimated time until the device is fully discharged, in seconds.
/// ///
/// Will be set to `0` if charging. /// Will be set to `0` if charging.
Q_PROPERTY(qreal timeToEmpty READ timeToEmpty NOTIFY timeToEmptyChanged); Q_PROPERTY(qreal timeToEmpty READ timeToEmpty NOTIFY timeToEmptyChanged BINDABLE bindableTimeToEmpty);
/// Estimated time until the device is fully charged, in seconds. /// Estimated time until the device is fully charged, in seconds.
/// ///
/// Will be set to `0` if discharging. /// Will be set to `0` if discharging.
Q_PROPERTY(qreal timeToFull READ timeToFull NOTIFY timeToFullChanged); Q_PROPERTY(qreal timeToFull READ timeToFull NOTIFY timeToFullChanged BINDABLE bindableTimeToFull);
/// Current charge level as a percentage. /// Current charge level as a percentage.
/// ///
/// This would be equivalent to @@energy / @@energyCapacity. /// This would be equivalent to @@energy / @@energyCapacity.
Q_PROPERTY(qreal percentage READ percentage NOTIFY percentageChanged); Q_PROPERTY(qreal percentage READ percentage NOTIFY percentageChanged BINDABLE bindablePercentage);
/// If the power source is present in the bay or slot, useful for hot-removable batteries. /// If the power source is present in the bay or slot, useful for hot-removable batteries.
/// ///
/// If the device `type` is not `Battery`, then the property will be invalid. /// If the device `type` is not `Battery`, then the property will be invalid.
Q_PROPERTY(bool isPresent READ isPresent NOTIFY isPresentChanged); Q_PROPERTY(bool isPresent READ isPresent NOTIFY isPresentChanged BINDABLE bindableIsPresent);
/// Current state of the device. /// Current state of the device.
Q_PROPERTY(qs::service::upower::UPowerDeviceState::Enum state READ state NOTIFY stateChanged); Q_PROPERTY(qs::service::upower::UPowerDeviceState::Enum state READ state NOTIFY stateChanged BINDABLE bindableState);
/// Health of the device as a percentage of its original health. /// Health of the device as a percentage of its original health.
Q_PROPERTY(qreal healthPercentage READ healthPercentage NOTIFY healthPercentageChanged); Q_PROPERTY(qreal healthPercentage READ healthPercentage NOTIFY healthPercentageChanged BINDABLE bindableHealthPercentage);
Q_PROPERTY(bool healthSupported READ healthSupported NOTIFY healthSupportedChanged); Q_PROPERTY(bool healthSupported READ healthSupported NOTIFY healthSupportedChanged BINDABLE bindableHealthSupported);
/// Name of the icon representing the current state of the device, or an empty string if not provided. /// Name of the icon representing the current state of the device, or an empty string if not provided.
Q_PROPERTY(QString iconName READ iconName NOTIFY iconNameChanged); Q_PROPERTY(QString iconName READ iconName NOTIFY iconNameChanged BINDABLE bindableIconName);
/// If the device is a laptop battery or not. Use this to check if your device is a valid battery. /// If the device is a laptop battery or not. Use this to check if your device is a valid battery.
/// ///
/// This will be equivalent to @@type == Battery && @@powerSupply == true. /// This will be equivalent to @@type == Battery && @@powerSupply == true.
Q_PROPERTY(bool isLaptopBattery READ isLaptopBattery NOTIFY isLaptopBatteryChanged); Q_PROPERTY(bool isLaptopBattery READ isLaptopBattery NOTIFY isLaptopBatteryChanged BINDABLE bindableIsLaptopBattery);
/// Native path of the device specific to your OS. /// Native path of the device specific to your OS.
Q_PROPERTY(QString nativePath READ nativePath NOTIFY nativePathChanged); Q_PROPERTY(QString nativePath READ nativePath NOTIFY nativePathChanged BINDABLE bindableNativePath);
// clang-format on // clang-format on
QML_ELEMENT; QML_ELEMENT;
QML_UNCREATABLE("UPowerDevices can only be acquired from UPower"); QML_UNCREATABLE("UPowerDevices can only be acquired from UPower");
@ -134,21 +168,21 @@ public:
[[nodiscard]] QString address() const; [[nodiscard]] QString address() const;
[[nodiscard]] QString path() const; [[nodiscard]] QString path() const;
[[nodiscard]] UPowerDeviceType::Enum type() const; QS_BINDABLE_GETTER(UPowerDeviceType::Enum, bType, type, bindableType);
[[nodiscard]] bool powerSupply() const; QS_BINDABLE_GETTER(bool, bPowerSupply, powerSupply, bindablePowerSupply);
[[nodiscard]] qreal energy() const; QS_BINDABLE_GETTER(qreal, bEnergy, energy, bindableEnergy);
[[nodiscard]] qreal energyCapacity() const; QS_BINDABLE_GETTER(qreal, bEnergyCapacity, energyCapacity, bindableEnergyCapacity);
[[nodiscard]] qreal changeRate() const; QS_BINDABLE_GETTER(qreal, bChangeRate, changeRate, bindableChangeRate);
[[nodiscard]] qlonglong timeToEmpty() const; QS_BINDABLE_GETTER(qlonglong, bTimeToEmpty, timeToEmpty, bindableTimeToEmpty);
[[nodiscard]] qlonglong timeToFull() const; QS_BINDABLE_GETTER(qlonglong, bTimeToFull, timeToFull, bindableTimeToFull);
[[nodiscard]] qreal percentage() const; QS_BINDABLE_GETTER(qreal, bPercentage, percentage, bindablePercentage);
[[nodiscard]] bool isPresent() const; QS_BINDABLE_GETTER(bool, bIsPresent, isPresent, bindableIsPresent);
[[nodiscard]] UPowerDeviceState::Enum state() const; QS_BINDABLE_GETTER(UPowerDeviceState::Enum, bState, state, bindableState);
[[nodiscard]] qreal healthPercentage() const; QS_BINDABLE_GETTER(qreal, bHealthPercentage, healthPercentage, bindableHealthPercentage);
[[nodiscard]] bool healthSupported() const; QS_BINDABLE_GETTER(bool, bHealthSupported, healthSupported, bindableHealthSupported);
[[nodiscard]] QString iconName() const; QS_BINDABLE_GETTER(QString, bIconName, iconName, bindableIconName);
[[nodiscard]] bool isLaptopBattery() const; QS_BINDABLE_GETTER(bool, bIsLaptopBattery, isLaptopBattery, bindableIsLaptopBattery);
[[nodiscard]] QString nativePath() const; QS_BINDABLE_GETTER(QString, bNativePath, nativePath, bindableNativePath);
signals: signals:
QSDOC_HIDE void ready(); QSDOC_HIDE void ready();
@ -170,20 +204,38 @@ signals:
void nativePathChanged(); void nativePathChanged();
private: private:
dbus::DBusPropertyGroup deviceProperties; // clang-format off
dbus::DBusProperty<quint32> pType {this->deviceProperties, "Type"}; Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, UPowerDeviceType::Enum, bType, &UPowerDevice::typeChanged);
dbus::DBusProperty<bool> pPowerSupply {this->deviceProperties, "PowerSupply"}; Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, bool, bPowerSupply, &UPowerDevice::powerSupplyChanged);
dbus::DBusProperty<qreal> pEnergy {this->deviceProperties, "Energy"}; Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, qreal, bEnergy, &UPowerDevice::energyChanged);
dbus::DBusProperty<qreal> pEnergyCapacity {this->deviceProperties, "EnergyFull"}; Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, qreal, bEnergyCapacity, &UPowerDevice::energyCapacityChanged);
dbus::DBusProperty<qreal> pChangeRate {this->deviceProperties, "EnergyRate"}; Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, qreal, bChangeRate, &UPowerDevice::changeRateChanged);
dbus::DBusProperty<qlonglong> pTimeToEmpty {this->deviceProperties, "TimeToEmpty"}; Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, qlonglong, bTimeToEmpty, &UPowerDevice::timeToEmptyChanged);
dbus::DBusProperty<qlonglong> pTimeToFull {this->deviceProperties, "TimeToFull"}; Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, qlonglong, bTimeToFull, &UPowerDevice::timeToFullChanged);
dbus::DBusProperty<qreal> pPercentage {this->deviceProperties, "Percentage"}; Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, qreal, bPercentage, &UPowerDevice::percentageChanged);
dbus::DBusProperty<bool> pIsPresent {this->deviceProperties, "IsPresent"}; Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, bool, bIsPresent, &UPowerDevice::isPresentChanged);
dbus::DBusProperty<quint32> pState {this->deviceProperties, "State"}; Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, UPowerDeviceState::Enum, bState, &UPowerDevice::stateChanged);
dbus::DBusProperty<qreal> pHealthPercentage {this->deviceProperties, "Capacity"}; Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, qreal, bHealthPercentage, &UPowerDevice::healthPercentageChanged);
dbus::DBusProperty<QString> pIconName {this->deviceProperties, "IconName"}; Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, bool, bHealthSupported, &UPowerDevice::healthSupportedChanged);
dbus::DBusProperty<QString> pNativePath {this->deviceProperties, "NativePath"}; Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, QString, bIconName, &UPowerDevice::iconNameChanged);
Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, bool, bIsLaptopBattery, &UPowerDevice::isLaptopBatteryChanged);
Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, QString, bNativePath, &UPowerDevice::nativePathChanged);
QS_DBUS_BINDABLE_PROPERTY_GROUP(UPowerDevice, deviceProperties);
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pType, bType, deviceProperties, "Type");
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pPowerSupply, bPowerSupply, deviceProperties, "PowerSupply");
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pEnergy, bEnergy, deviceProperties, "Energy");
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pEnergyCapacity, bEnergyCapacity, deviceProperties, "EnergyFull");
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pChangeRate, bChangeRate, deviceProperties, "EnergyRate");
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pTimeToEmpty, bTimeToEmpty, deviceProperties, "TimeToEmpty");
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pTimeToFull, bTimeToFull, deviceProperties, "TimeToFull");
QS_DBUS_PROPERTY_BINDING(UPowerDevice, PowerPercentage, pPercentage, bPercentage, deviceProperties, "Percentage", true);
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pIsPresent, bIsPresent, deviceProperties, "IsPresent");
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pState, bState, deviceProperties, "State");
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pHealthPercentage, bHealthPercentage, deviceProperties, "Capacity");
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pIconName, bIconName, deviceProperties, "IconName");
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pNativePath, bNativePath, deviceProperties, "NativePath");
// clang-format on
DBusUPowerDevice* device = nullptr; DBusUPowerDevice* device = nullptr;
}; };