Display battery percentage

pull/7/head
cutefishd 5 years ago
parent b8757abecf
commit bde3b2a773

@ -183,15 +183,24 @@ Item {
wirelessIcon.status === Image.Ready
}
Image {
id: batteryIcon
visible: battery.available && status === Image.Ready
height: rootItem.iconSize
width: height + 6
sourceSize: Qt.size(width, height)
source: "qrc:/images/" + (Meui.Theme.darkMode ? "dark/" : "light/") + battery.iconSource
Layout.alignment: Qt.AlignCenter
asynchronous: true
// Battery Item
RowLayout {
Label {
font.pointSize: 11
text: battery.chargePercent + "%"
visible: battery.showPercentage
}
Image {
id: batteryIcon
visible: battery.available && status === Image.Ready
height: rootItem.iconSize
width: height + 6
sourceSize: Qt.size(width, height)
source: "qrc:/images/" + (Meui.Theme.darkMode ? "dark/" : "light/") + battery.iconSource
Layout.alignment: Qt.AlignCenter
asynchronous: true
}
}
// Image {

@ -74,6 +74,12 @@ bool Battery::onBattery() const
return m_onBattery;
}
bool Battery::showPercentage() const
{
// TODO
return true;
}
int Battery::chargeState() const
{
return m_interface.property("chargeState").toInt();

@ -33,6 +33,7 @@ class Battery : public QObject
Q_PROPERTY(int capacity READ capacity NOTIFY capacityChanged)
Q_PROPERTY(QString statusString READ statusString NOTIFY remainingTimeChanged)
Q_PROPERTY(bool onBattery READ onBattery NOTIFY onBatteryChanged)
Q_PROPERTY(bool showPercentage READ showPercentage NOTIFY showPercentageChanged)
Q_PROPERTY(QString iconSource READ iconSource NOTIFY iconSourceChanged)
public:
@ -40,6 +41,7 @@ public:
bool available() const;
bool onBattery() const;
bool showPercentage() const;
int chargeState() const;
int chargePercent() const;
@ -58,6 +60,7 @@ signals:
void onBatteryChanged();
void lastChargedPercentChanged();
void iconSourceChanged();
void showPercentageChanged();
private slots:
void onPropertiesChanged(const QString &ifaceName, const QVariantMap &changedProps, const QStringList &invalidatedProps);

Loading…
Cancel
Save