Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide the battery widget when the status is unknown #2319

Merged
merged 1 commit into from
Oct 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -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>
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
@@ -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>
15 changes: 3 additions & 12 deletions src/widget/wbattery.cpp
Original file line number Diff line number Diff line change
@@ -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()));
@@ -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,
@@ -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:
@@ -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()