mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 13:50:28 +01:00
[apps] Return boolean when charging state or charge level has changed
(to know if the redrawing is necessary) Change-Id: Iebb1d2ba1f188815b01bcbd6e632244f6169b3f9
This commit is contained in:
@@ -13,12 +13,12 @@ void AppsWindow::setTitle(I18n::Message title) {
|
||||
m_titleBarView.setTitle(title);
|
||||
}
|
||||
|
||||
void AppsWindow::updateBatteryLevel() {
|
||||
m_titleBarView.setChargeState(Ion::Battery::level());
|
||||
bool AppsWindow::updateBatteryLevel() {
|
||||
return m_titleBarView.setChargeState(Ion::Battery::level());
|
||||
}
|
||||
|
||||
void AppsWindow::updateIsChargingState() {
|
||||
m_titleBarView.setIsCharging(Ion::Battery::isCharging());
|
||||
bool AppsWindow::updateIsChargingState() {
|
||||
return m_titleBarView.setIsCharging(Ion::Battery::isCharging());
|
||||
}
|
||||
|
||||
void AppsWindow::refreshPreferences() {
|
||||
|
||||
@@ -8,8 +8,8 @@ class AppsWindow : public Window {
|
||||
public:
|
||||
AppsWindow();
|
||||
void setTitle(I18n::Message title);
|
||||
void updateBatteryLevel();
|
||||
void updateIsChargingState();
|
||||
bool updateBatteryLevel();
|
||||
bool updateIsChargingState();
|
||||
void refreshPreferences();
|
||||
private:
|
||||
constexpr static KDCoordinate k_titleBarHeight = 18;
|
||||
|
||||
@@ -18,18 +18,22 @@ BatteryView::BatteryView() :
|
||||
{
|
||||
}
|
||||
|
||||
void BatteryView::setChargeState(Ion::Battery::Charge chargeState) {
|
||||
bool BatteryView::setChargeState(Ion::Battery::Charge chargeState) {
|
||||
if (chargeState != m_chargeState) {
|
||||
m_chargeState = chargeState;
|
||||
markRectAsDirty(bounds());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void BatteryView::setIsCharging(bool isCharging) {
|
||||
bool BatteryView::setIsCharging(bool isCharging) {
|
||||
if (m_isCharging != isCharging) {
|
||||
m_isCharging = isCharging;
|
||||
markRectAsDirty(bounds());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
KDColor s_flashWorkingBuffer[BatteryView::k_flashHeight*BatteryView::k_flashWidth];
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
class BatteryView : public View {
|
||||
public:
|
||||
BatteryView();
|
||||
void setChargeState(Ion::Battery::Charge chargeState);
|
||||
void setIsCharging(bool isCharging);
|
||||
bool setChargeState(Ion::Battery::Charge chargeState);
|
||||
bool setIsCharging(bool isCharging);
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
KDSize minimalSizeForOptimalDisplay() const override;
|
||||
constexpr static int k_flashHeight = 8;
|
||||
|
||||
@@ -13,21 +13,16 @@ TitleBarView::TitleBarView() :
|
||||
{
|
||||
}
|
||||
|
||||
void TitleBarView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->fillRect(bounds(), Palette::YellowDark);
|
||||
|
||||
}
|
||||
|
||||
void TitleBarView::setTitle(I18n::Message title) {
|
||||
m_titleView.setMessage(title);
|
||||
}
|
||||
|
||||
void TitleBarView::setChargeState(Ion::Battery::Charge chargeState) {
|
||||
m_batteryView.setChargeState(chargeState);
|
||||
bool TitleBarView::setChargeState(Ion::Battery::Charge chargeState) {
|
||||
return m_batteryView.setChargeState(chargeState);
|
||||
}
|
||||
|
||||
void TitleBarView::setIsCharging(bool isCharging) {
|
||||
m_batteryView.setIsCharging(isCharging);
|
||||
bool TitleBarView::setIsCharging(bool isCharging) {
|
||||
return m_batteryView.setIsCharging(isCharging);
|
||||
}
|
||||
|
||||
int TitleBarView::numberOfSubviews() const {
|
||||
|
||||
@@ -8,10 +8,9 @@
|
||||
class TitleBarView : public View {
|
||||
public:
|
||||
TitleBarView();
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
void setTitle(I18n::Message title);
|
||||
void setChargeState(Ion::Battery::Charge chargeState);
|
||||
void setIsCharging(bool isCharging);
|
||||
bool setChargeState(Ion::Battery::Charge chargeState);
|
||||
bool setIsCharging(bool isCharging);
|
||||
void refreshPreferences();
|
||||
private:
|
||||
constexpr static KDCoordinate k_batteryLeftMargin = 5;
|
||||
|
||||
Reference in New Issue
Block a user