Skip to content

Commit ff55ac8

Browse files
committed
service/upower: adopt bindable properties
1 parent d4deb11 commit ff55ac8

File tree

4 files changed

+155
-100
lines changed

4 files changed

+155
-100
lines changed

src/services/upower/core.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@ UPower::UPower() {
5353
}
5454

5555
void UPower::init() {
56-
QObject::connect(
57-
&this->pOnBattery,
58-
&dbus::AbstractDBusProperty::changed,
59-
this,
60-
&UPower::onBatteryChanged
61-
);
62-
6356
this->serviceProperties.setInterface(this->service);
6457
this->serviceProperties.updateAllViaGetAll();
6558

@@ -143,8 +136,6 @@ UPowerDevice* UPower::displayDevice() { return this->mDisplayDevice; }
143136

144137
ObjectModel<UPowerDevice>* UPower::devices() { return &this->readyDevices; }
145138

146-
bool UPower::onBattery() const { return this->pOnBattery.get(); }
147-
148139
UPower* UPower::instance() {
149140
static UPower* instance = new UPower(); // NOLINT
150141
return instance;
@@ -173,6 +164,4 @@ ObjectModel<UPowerDevice>* UPowerQml::devices() { // NOLINT
173164
return UPower::instance()->devices();
174165
}
175166

176-
bool UPowerQml::onBattery() { return UPower::instance()->onBattery(); }
177-
178167
} // namespace qs::service::upower

src/services/upower/core.hpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class UPower: public QObject {
2121
public:
2222
[[nodiscard]] UPowerDevice* displayDevice();
2323
[[nodiscard]] ObjectModel<UPowerDevice>* devices();
24-
[[nodiscard]] bool onBattery() const;
24+
QS_BINDABLE_GETTER(bool, bOnBattery, onBattery, bindableOnBattery);
2525

2626
static UPower* instance();
2727

@@ -44,8 +44,10 @@ private slots:
4444
QHash<QString, UPowerDevice*> mDevices;
4545
ObjectModel<UPowerDevice> readyDevices {this};
4646

47-
dbus::DBusPropertyGroup serviceProperties;
48-
dbus::DBusProperty<bool> pOnBattery {this->serviceProperties, "OnBattery"};
47+
Q_OBJECT_BINDABLE_PROPERTY(UPower, bool, bOnBattery, &UPower::onBatteryChanged);
48+
49+
QS_DBUS_BINDABLE_PROPERTY_GROUP(UPower, serviceProperties);
50+
QS_DBUS_PROPERTY_BINDING(UPower, pOnBattery, bOnBattery, serviceProperties, "OnBattery");
4951

5052
DBusUPowerService* service = nullptr;
5153
};
@@ -64,15 +66,19 @@ class UPowerQml: public QObject {
6466
QSDOC_TYPE_OVERRIDE(ObjectModel<qs::service::upower::UPowerDevice>*);
6567
Q_PROPERTY(UntypedObjectModel* devices READ devices CONSTANT);
6668
/// If the system is currently running on battery power, or discharging.
67-
Q_PROPERTY(bool onBattery READ onBattery NOTIFY onBatteryChanged);
69+
Q_PROPERTY(bool onBattery READ onBattery NOTIFY onBatteryChanged BINDABLE bindableOnBattery);
6870
// clang-format on
6971

7072
public:
7173
explicit UPowerQml(QObject* parent = nullptr);
7274

7375
[[nodiscard]] UPowerDevice* displayDevice();
7476
[[nodiscard]] ObjectModel<UPowerDevice>* devices();
75-
[[nodiscard]] static bool onBattery();
77+
[[nodiscard]] static bool onBattery() { return UPower::instance()->onBattery(); }
78+
79+
[[nodiscard]] static QBindable<bool> bindableOnBattery() {
80+
return UPower::instance()->bindableOnBattery();
81+
}
7682

7783
signals:
7884
void displayDeviceChanged();

src/services/upower/device.cpp

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,18 @@ UPowerDevice::UPowerDevice(const QString& path, QObject* parent): QObject(parent
7474
return;
7575
}
7676

77-
// clang-format off
78-
QObject::connect(&this->pType, &AbstractDBusProperty::changed, this, &UPowerDevice::typeChanged);
79-
QObject::connect(&this->pPowerSupply, &AbstractDBusProperty::changed, this, &UPowerDevice::powerSupplyChanged);
80-
QObject::connect(&this->pEnergy, &AbstractDBusProperty::changed, this, &UPowerDevice::energyChanged);
81-
QObject::connect(&this->pEnergyCapacity, &AbstractDBusProperty::changed, this, &UPowerDevice::energyCapacityChanged);
82-
QObject::connect(&this->pChangeRate, &AbstractDBusProperty::changed, this, &UPowerDevice::changeRateChanged);
83-
QObject::connect(&this->pTimeToEmpty, &AbstractDBusProperty::changed, this, &UPowerDevice::timeToEmptyChanged);
84-
QObject::connect(&this->pTimeToFull, &AbstractDBusProperty::changed, this, &UPowerDevice::timeToFullChanged);
85-
QObject::connect(&this->pPercentage, &AbstractDBusProperty::changed, this, &UPowerDevice::percentageChanged);
86-
QObject::connect(&this->pIsPresent, &AbstractDBusProperty::changed, this, &UPowerDevice::isPresentChanged);
87-
QObject::connect(&this->pState, &AbstractDBusProperty::changed, this, &UPowerDevice::stateChanged);
88-
QObject::connect(&this->pHealthPercentage, &AbstractDBusProperty::changed, this, &UPowerDevice::healthPercentageChanged);
89-
QObject::connect(&this->pHealthPercentage, &AbstractDBusProperty::changed, this, &UPowerDevice::healthSupportedChanged);
90-
QObject::connect(&this->pIconName, &AbstractDBusProperty::changed, this, &UPowerDevice::iconNameChanged);
91-
QObject::connect(&this->pType, &AbstractDBusProperty::changed, this, &UPowerDevice::isLaptopBatteryChanged);
92-
QObject::connect(&this->pNativePath, &AbstractDBusProperty::changed, this, &UPowerDevice::nativePathChanged);
93-
94-
QObject::connect(&this->deviceProperties, &DBusPropertyGroup::getAllFinished, this, &UPowerDevice::ready);
95-
// clang-format on
77+
this->bIsLaptopBattery.setBinding([this]() {
78+
return this->bType == UPowerDeviceType::Battery && this->bPowerSupply;
79+
});
80+
81+
this->bHealthSupported.setBinding([this]() { return this->bHealthPercentage != 0; });
82+
83+
QObject::connect(
84+
&this->deviceProperties,
85+
&DBusPropertyGroup::getAllFinished,
86+
this,
87+
&UPowerDevice::ready
88+
);
9689

9790
this->deviceProperties.setInterface(this->device);
9891
this->deviceProperties.updateAllViaGetAll();
@@ -102,33 +95,48 @@ bool UPowerDevice::isValid() const { return this->device->isValid(); }
10295
QString UPowerDevice::address() const { return this->device->service(); }
10396
QString UPowerDevice::path() const { return this->device->path(); }
10497

105-
UPowerDeviceType::Enum UPowerDevice::type() const {
106-
return static_cast<UPowerDeviceType::Enum>(this->pType.get());
107-
}
98+
} // namespace qs::service::upower
10899

109-
bool UPowerDevice::powerSupply() const { return this->pPowerSupply.get(); }
110-
qreal UPowerDevice::energy() const { return this->pEnergy.get(); }
111-
qreal UPowerDevice::energyCapacity() const { return this->pEnergyCapacity.get(); }
112-
qreal UPowerDevice::changeRate() const { return this->pChangeRate.get(); }
113-
qlonglong UPowerDevice::timeToEmpty() const { return this->pTimeToEmpty.get(); }
114-
qlonglong UPowerDevice::timeToFull() const { return this->pTimeToFull.get(); }
115-
qreal UPowerDevice::percentage() const { return this->pPercentage.get() / 100; }
116-
bool UPowerDevice::isPresent() const { return this->pIsPresent.get(); }
117-
118-
UPowerDeviceState::Enum UPowerDevice::state() const {
119-
return static_cast<UPowerDeviceState::Enum>(this->pState.get());
100+
namespace qs::dbus {
101+
102+
using namespace qs::service::upower;
103+
104+
DBusResult<qreal> DBusDataTransform<PowerPercentage>::fromWire(qreal wire) {
105+
return DBusResult(wire * 0.01);
120106
}
121107

122-
qreal UPowerDevice::healthPercentage() const { return this->pHealthPercentage.get(); }
108+
qreal DBusDataTransform<PowerPercentage>::toWire(const qreal& value) { return value * 100; }
109+
110+
DBusResult<UPowerDeviceState::Enum>
111+
DBusDataTransform<UPowerDeviceState::Enum>::fromWire(quint32 wire) {
112+
if (wire != UPowerDeviceType::Battery && wire >= UPowerDeviceState::Unknown
113+
&& wire <= UPowerDeviceState::PendingDischarge)
114+
{
115+
return DBusResult(static_cast<UPowerDeviceState::Enum>(wire));
116+
}
123117

124-
bool UPowerDevice::healthSupported() const { return this->healthPercentage() != 0; }
118+
return DBusResult<UPowerDeviceState::Enum>(
119+
QDBusError(QDBusError::InvalidArgs, QString("Invalid UPowerDeviceState: %1").arg(wire))
120+
);
121+
}
125122

126-
QString UPowerDevice::iconName() const { return this->pIconName.get(); }
123+
quint32 DBusDataTransform<UPowerDeviceState::Enum>::toWire(const UPowerDeviceState::Enum& value) {
124+
return static_cast<quint32>(value);
125+
}
127126

128-
bool UPowerDevice::isLaptopBattery() const {
129-
return this->pType.get() == UPowerDeviceType::Battery && this->pPowerSupply.get();
127+
DBusResult<UPowerDeviceType::Enum> DBusDataTransform<UPowerDeviceType::Enum>::fromWire(quint32 wire
128+
) {
129+
if (wire >= UPowerDeviceType::Unknown && wire <= UPowerDeviceType::BluetoothGeneric) {
130+
return DBusResult(static_cast<UPowerDeviceType::Enum>(wire));
131+
}
132+
133+
return DBusResult<UPowerDeviceType::Enum>(
134+
QDBusError(QDBusError::InvalidArgs, QString("Invalid UPowerDeviceType: %1").arg(wire))
135+
);
130136
}
131137

132-
QString UPowerDevice::nativePath() const { return this->pNativePath.get(); }
138+
quint32 DBusDataTransform<UPowerDeviceType::Enum>::toWire(const UPowerDeviceType::Enum& value) {
139+
return static_cast<quint32>(value);
140+
}
133141

134-
} // namespace qs::service::upower
142+
} // namespace qs::dbus

src/services/upower/device.hpp

Lines changed: 96 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -80,49 +80,83 @@ class UPowerDeviceType: public QObject {
8080
Q_INVOKABLE static QString toString(qs::service::upower::UPowerDeviceType::Enum type);
8181
};
8282

83+
struct PowerPercentage;
84+
85+
} // namespace qs::service::upower
86+
87+
namespace qs::dbus {
88+
89+
template <>
90+
struct DBusDataTransform<qs::service::upower::UPowerDeviceState::Enum> {
91+
using Wire = quint32;
92+
using Data = qs::service::upower::UPowerDeviceState::Enum;
93+
static DBusResult<Data> fromWire(Wire wire);
94+
static Wire toWire(const Data& value);
95+
};
96+
97+
template <>
98+
struct DBusDataTransform<qs::service::upower::UPowerDeviceType::Enum> {
99+
using Wire = quint32;
100+
using Data = qs::service::upower::UPowerDeviceType::Enum;
101+
static DBusResult<Data> fromWire(Wire wire);
102+
static Wire toWire(const Data& value);
103+
};
104+
105+
template <>
106+
struct DBusDataTransform<qs::service::upower::PowerPercentage> {
107+
using Wire = qreal;
108+
using Data = qreal;
109+
static DBusResult<Data> fromWire(Wire wire);
110+
static Wire toWire(const Data& value);
111+
};
112+
113+
} // namespace qs::dbus
114+
115+
namespace qs::service::upower {
116+
83117
///! A device exposed through the UPower system service.
84118
class UPowerDevice: public QObject {
85119
Q_OBJECT;
86120
// clang-format off
87121
/// The type of device.
88-
Q_PROPERTY(qs::service::upower::UPowerDeviceType::Enum type READ type NOTIFY typeChanged);
122+
Q_PROPERTY(qs::service::upower::UPowerDeviceType::Enum type READ type NOTIFY typeChanged BINDABLE bindableType);
89123
/// If the device is a power supply for your computer and can provide charge.
90-
Q_PROPERTY(bool powerSupply READ powerSupply NOTIFY powerSupplyChanged);
124+
Q_PROPERTY(bool powerSupply READ powerSupply NOTIFY powerSupplyChanged BINDABLE bindablePowerSupply);
91125
/// Current energy level of the device in watt-hours.
92-
Q_PROPERTY(qreal energy READ energy NOTIFY energyChanged);
126+
Q_PROPERTY(qreal energy READ energy NOTIFY energyChanged BINDABLE bindableEnergy);
93127
/// Maximum energy capacity of the device in watt-hours
94-
Q_PROPERTY(qreal energyCapacity READ energyCapacity NOTIFY energyCapacityChanged);
128+
Q_PROPERTY(qreal energyCapacity READ energyCapacity NOTIFY energyCapacityChanged BINDABLE bindableEnergyCapacity);
95129
/// Rate of energy change in watts (positive when charging, negative when discharging).
96-
Q_PROPERTY(qreal changeRate READ changeRate NOTIFY changeRateChanged);
130+
Q_PROPERTY(qreal changeRate READ changeRate NOTIFY changeRateChanged BINDABLE bindableChangeRate);
97131
/// Estimated time until the device is fully discharged, in seconds.
98132
///
99133
/// Will be set to `0` if charging.
100-
Q_PROPERTY(qreal timeToEmpty READ timeToEmpty NOTIFY timeToEmptyChanged);
134+
Q_PROPERTY(qreal timeToEmpty READ timeToEmpty NOTIFY timeToEmptyChanged BINDABLE bindableTimeToEmpty);
101135
/// Estimated time until the device is fully charged, in seconds.
102136
///
103137
/// Will be set to `0` if discharging.
104-
Q_PROPERTY(qreal timeToFull READ timeToFull NOTIFY timeToFullChanged);
138+
Q_PROPERTY(qreal timeToFull READ timeToFull NOTIFY timeToFullChanged BINDABLE bindableTimeToFull);
105139
/// Current charge level as a percentage.
106140
///
107141
/// This would be equivalent to @@energy / @@energyCapacity.
108-
Q_PROPERTY(qreal percentage READ percentage NOTIFY percentageChanged);
142+
Q_PROPERTY(qreal percentage READ percentage NOTIFY percentageChanged BINDABLE bindablePercentage);
109143
/// If the power source is present in the bay or slot, useful for hot-removable batteries.
110144
///
111145
/// If the device `type` is not `Battery`, then the property will be invalid.
112-
Q_PROPERTY(bool isPresent READ isPresent NOTIFY isPresentChanged);
146+
Q_PROPERTY(bool isPresent READ isPresent NOTIFY isPresentChanged BINDABLE bindableIsPresent);
113147
/// Current state of the device.
114-
Q_PROPERTY(qs::service::upower::UPowerDeviceState::Enum state READ state NOTIFY stateChanged);
148+
Q_PROPERTY(qs::service::upower::UPowerDeviceState::Enum state READ state NOTIFY stateChanged BINDABLE bindableState);
115149
/// Health of the device as a percentage of its original health.
116-
Q_PROPERTY(qreal healthPercentage READ healthPercentage NOTIFY healthPercentageChanged);
117-
Q_PROPERTY(bool healthSupported READ healthSupported NOTIFY healthSupportedChanged);
150+
Q_PROPERTY(qreal healthPercentage READ healthPercentage NOTIFY healthPercentageChanged BINDABLE bindableHealthPercentage);
151+
Q_PROPERTY(bool healthSupported READ healthSupported NOTIFY healthSupportedChanged BINDABLE bindableHealthSupported);
118152
/// Name of the icon representing the current state of the device, or an empty string if not provided.
119-
Q_PROPERTY(QString iconName READ iconName NOTIFY iconNameChanged);
153+
Q_PROPERTY(QString iconName READ iconName NOTIFY iconNameChanged BINDABLE bindableIconName);
120154
/// If the device is a laptop battery or not. Use this to check if your device is a valid battery.
121155
///
122156
/// This will be equivalent to @@type == Battery && @@powerSupply == true.
123-
Q_PROPERTY(bool isLaptopBattery READ isLaptopBattery NOTIFY isLaptopBatteryChanged);
157+
Q_PROPERTY(bool isLaptopBattery READ isLaptopBattery NOTIFY isLaptopBatteryChanged BINDABLE bindableIsLaptopBattery);
124158
/// Native path of the device specific to your OS.
125-
Q_PROPERTY(QString nativePath READ nativePath NOTIFY nativePathChanged);
159+
Q_PROPERTY(QString nativePath READ nativePath NOTIFY nativePathChanged BINDABLE bindableNativePath);
126160
// clang-format on
127161
QML_ELEMENT;
128162
QML_UNCREATABLE("UPowerDevices can only be acquired from UPower");
@@ -134,21 +168,21 @@ class UPowerDevice: public QObject {
134168
[[nodiscard]] QString address() const;
135169
[[nodiscard]] QString path() const;
136170

137-
[[nodiscard]] UPowerDeviceType::Enum type() const;
138-
[[nodiscard]] bool powerSupply() const;
139-
[[nodiscard]] qreal energy() const;
140-
[[nodiscard]] qreal energyCapacity() const;
141-
[[nodiscard]] qreal changeRate() const;
142-
[[nodiscard]] qlonglong timeToEmpty() const;
143-
[[nodiscard]] qlonglong timeToFull() const;
144-
[[nodiscard]] qreal percentage() const;
145-
[[nodiscard]] bool isPresent() const;
146-
[[nodiscard]] UPowerDeviceState::Enum state() const;
147-
[[nodiscard]] qreal healthPercentage() const;
148-
[[nodiscard]] bool healthSupported() const;
149-
[[nodiscard]] QString iconName() const;
150-
[[nodiscard]] bool isLaptopBattery() const;
151-
[[nodiscard]] QString nativePath() const;
171+
QS_BINDABLE_GETTER(UPowerDeviceType::Enum, bType, type, bindableType);
172+
QS_BINDABLE_GETTER(bool, bPowerSupply, powerSupply, bindablePowerSupply);
173+
QS_BINDABLE_GETTER(qreal, bEnergy, energy, bindableEnergy);
174+
QS_BINDABLE_GETTER(qreal, bEnergyCapacity, energyCapacity, bindableEnergyCapacity);
175+
QS_BINDABLE_GETTER(qreal, bChangeRate, changeRate, bindableChangeRate);
176+
QS_BINDABLE_GETTER(qlonglong, bTimeToEmpty, timeToEmpty, bindableTimeToEmpty);
177+
QS_BINDABLE_GETTER(qlonglong, bTimeToFull, timeToFull, bindableTimeToFull);
178+
QS_BINDABLE_GETTER(qreal, bPercentage, percentage, bindablePercentage);
179+
QS_BINDABLE_GETTER(bool, bIsPresent, isPresent, bindableIsPresent);
180+
QS_BINDABLE_GETTER(UPowerDeviceState::Enum, bState, state, bindableState);
181+
QS_BINDABLE_GETTER(qreal, bHealthPercentage, healthPercentage, bindableHealthPercentage);
182+
QS_BINDABLE_GETTER(bool, bHealthSupported, healthSupported, bindableHealthSupported);
183+
QS_BINDABLE_GETTER(QString, bIconName, iconName, bindableIconName);
184+
QS_BINDABLE_GETTER(bool, bIsLaptopBattery, isLaptopBattery, bindableIsLaptopBattery);
185+
QS_BINDABLE_GETTER(QString, bNativePath, nativePath, bindableNativePath);
152186

153187
signals:
154188
QSDOC_HIDE void ready();
@@ -170,20 +204,38 @@ class UPowerDevice: public QObject {
170204
void nativePathChanged();
171205

172206
private:
173-
dbus::DBusPropertyGroup deviceProperties;
174-
dbus::DBusProperty<quint32> pType {this->deviceProperties, "Type"};
175-
dbus::DBusProperty<bool> pPowerSupply {this->deviceProperties, "PowerSupply"};
176-
dbus::DBusProperty<qreal> pEnergy {this->deviceProperties, "Energy"};
177-
dbus::DBusProperty<qreal> pEnergyCapacity {this->deviceProperties, "EnergyFull"};
178-
dbus::DBusProperty<qreal> pChangeRate {this->deviceProperties, "EnergyRate"};
179-
dbus::DBusProperty<qlonglong> pTimeToEmpty {this->deviceProperties, "TimeToEmpty"};
180-
dbus::DBusProperty<qlonglong> pTimeToFull {this->deviceProperties, "TimeToFull"};
181-
dbus::DBusProperty<qreal> pPercentage {this->deviceProperties, "Percentage"};
182-
dbus::DBusProperty<bool> pIsPresent {this->deviceProperties, "IsPresent"};
183-
dbus::DBusProperty<quint32> pState {this->deviceProperties, "State"};
184-
dbus::DBusProperty<qreal> pHealthPercentage {this->deviceProperties, "Capacity"};
185-
dbus::DBusProperty<QString> pIconName {this->deviceProperties, "IconName"};
186-
dbus::DBusProperty<QString> pNativePath {this->deviceProperties, "NativePath"};
207+
// clang-format off
208+
Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, UPowerDeviceType::Enum, bType, &UPowerDevice::typeChanged);
209+
Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, bool, bPowerSupply, &UPowerDevice::powerSupplyChanged);
210+
Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, qreal, bEnergy, &UPowerDevice::energyChanged);
211+
Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, qreal, bEnergyCapacity, &UPowerDevice::energyCapacityChanged);
212+
Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, qreal, bChangeRate, &UPowerDevice::changeRateChanged);
213+
Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, qlonglong, bTimeToEmpty, &UPowerDevice::timeToEmptyChanged);
214+
Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, qlonglong, bTimeToFull, &UPowerDevice::timeToFullChanged);
215+
Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, qreal, bPercentage, &UPowerDevice::percentageChanged);
216+
Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, bool, bIsPresent, &UPowerDevice::isPresentChanged);
217+
Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, UPowerDeviceState::Enum, bState, &UPowerDevice::stateChanged);
218+
Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, qreal, bHealthPercentage, &UPowerDevice::healthPercentageChanged);
219+
Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, bool, bHealthSupported, &UPowerDevice::healthSupportedChanged);
220+
Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, QString, bIconName, &UPowerDevice::iconNameChanged);
221+
Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, bool, bIsLaptopBattery, &UPowerDevice::isLaptopBatteryChanged);
222+
Q_OBJECT_BINDABLE_PROPERTY(UPowerDevice, QString, bNativePath, &UPowerDevice::nativePathChanged);
223+
224+
QS_DBUS_BINDABLE_PROPERTY_GROUP(UPowerDevice, deviceProperties);
225+
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pType, bType, deviceProperties, "Type");
226+
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pPowerSupply, bPowerSupply, deviceProperties, "PowerSupply");
227+
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pEnergy, bEnergy, deviceProperties, "Energy");
228+
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pEnergyCapacity, bEnergyCapacity, deviceProperties, "EnergyFull");
229+
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pChangeRate, bChangeRate, deviceProperties, "EnergyRate");
230+
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pTimeToEmpty, bTimeToEmpty, deviceProperties, "TimeToEmpty");
231+
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pTimeToFull, bTimeToFull, deviceProperties, "TimeToFull");
232+
QS_DBUS_PROPERTY_BINDING(UPowerDevice, PowerPercentage, pPercentage, bPercentage, deviceProperties, "Percentage", true);
233+
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pIsPresent, bIsPresent, deviceProperties, "IsPresent");
234+
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pState, bState, deviceProperties, "State");
235+
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pHealthPercentage, bHealthPercentage, deviceProperties, "Capacity");
236+
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pIconName, bIconName, deviceProperties, "IconName");
237+
QS_DBUS_PROPERTY_BINDING(UPowerDevice, pNativePath, bNativePath, deviceProperties, "NativePath");
238+
// clang-format on
187239

188240
DBusUPowerDevice* device = nullptr;
189241
};

0 commit comments

Comments
 (0)