Skip to content

Commit

Permalink
Merge pull request #2319 from rrrapha/battery-hide
Browse files Browse the repository at this point in the history
Hide the battery widget when the status is unknown
  • Loading branch information
daschuer authored Oct 17, 2019
2 parents 14037e9 + d42c767 commit 6bc55a5
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 16 deletions.
1 change: 0 additions & 1 deletion res/skins/Deere/icon/ic_battery_unknown_48px.svg

This file was deleted.

1 change: 0 additions & 1 deletion res/skins/Deere/tool_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<ObjectName>Battery</ObjectName>
<Size>24,24</Size>
<SizePolicy>f,f</SizePolicy>
<PixmapUnknown scalemode="STRETCH_ASPECT">icon/ic_battery_unknown_48px.svg</PixmapUnknown>
<PixmapCharged scalemode="STRETCH_ASPECT">icon/ic_battery_charged_48px.svg</PixmapCharged>
<NumberStates>8</NumberStates>
<PixmapsCharging scalemode="STRETCH_ASPECT">icon/ic_battery_charging_%1_48px.svg</PixmapsCharging>
Expand Down
1 change: 0 additions & 1 deletion res/skins/Tango/graphics/batt/ic_battery_unknown.svg

This file was deleted.

1 change: 0 additions & 1 deletion res/skins/Tango/topbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ Description:
<ObjectName>Battery</ObjectName>
<Size>24,24</Size>
<SizePolicy>f,f</SizePolicy>
<PixmapUnknown scalemode="STRETCH_ASPECT">graphics/batt/ic_battery_unknown.svg</PixmapUnknown>
<PixmapCharged scalemode="STRETCH_ASPECT">graphics/batt/ic_battery_charged.svg</PixmapCharged>
<NumberStates>8</NumberStates>
<PixmapsCharging scalemode="STRETCH_ASPECT">graphics/batt/ic_battery_charging_%1.svg</PixmapsCharging>
Expand Down
15 changes: 3 additions & 12 deletions src/widget/wbattery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
WBattery::WBattery(QWidget* parent)
: WWidget(parent),
m_pBattery(Battery::getBattery(this)) {
setVisible(false);
if (m_pBattery) {
connect(m_pBattery.data(), SIGNAL(stateChanged()),
this, SLOT(update()));
Expand All @@ -23,14 +24,6 @@ void WBattery::setup(const QDomNode& node, const SkinContext& context) {
context.getScaleFactor());
}

QDomElement unknownPath = context.selectElement(node, "PixmapUnknown");
if (!unknownPath.isNull()) {
setPixmap(&m_pPixmapUnknown,
context.getPixmapSource(unknownPath),
context.selectScaleMode(unknownPath, Paintable::TILE),
context.getScaleFactor());
}

QDomElement chargedPath = context.selectElement(node, "PixmapCharged");
if (!chargedPath.isNull()) {
setPixmap(&m_pPixmapCharged,
Expand Down Expand Up @@ -99,9 +92,8 @@ void WBattery::update() {

if (chargingState != Battery::UNKNOWN) {
setBaseTooltip(QString("%1\%").arg(dPercentage, 0, 'f', 0));
} else {
setBaseTooltip(tr("Battery status unknown."));
}

m_pCurrentPixmap.clear();
switch (chargingState) {
case Battery::CHARGING:
Expand Down Expand Up @@ -130,11 +122,10 @@ void WBattery::update() {
m_pCurrentPixmap = m_pPixmapCharged;
appendBaseTooltip("\n" + tr("Battery fully charged."));
break;
case Battery::UNKNOWN:
default:
m_pCurrentPixmap = m_pPixmapUnknown;
break;
}
setVisible(chargingState != Battery::UNKNOWN);

// call parent's update() to show changes, this should call
// QWidget::update()
Expand Down

0 comments on commit 6bc55a5

Please sign in to comment.