mirror of
git://projects.qi-hardware.com/nanomap.git
synced 2024-11-21 22:06:15 +02:00
beautify drawing of battery level a bit
This commit is contained in:
parent
3110a49a0d
commit
a3d3597d73
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010 Niels Kummerfeldt <niels.kummerfeldt@tu-harburg.de>
|
* Copyright 2010-2011 Niels Kummerfeldt <niels.kummerfeldt@tu-harburg.de>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -54,23 +54,27 @@ void BatteryLayer::paint(QPainter *painter)
|
|||||||
|
|
||||||
painter->setBrush(QBrush(QColor(255, 255, 255, 210)));
|
painter->setBrush(QBrush(QColor(255, 255, 255, 210)));
|
||||||
painter->drawRoundedRect(w - 111, h - 17, 110, 16, 5, 5);
|
painter->drawRoundedRect(w - 111, h - 17, 110, 16, 5, 5);
|
||||||
painter->drawText(w - 101, h - 15, 90, 14, Qt::AlignCenter, QString("%1%").arg(m_percent));
|
QColor color;
|
||||||
if (m_isCharging) {
|
if (m_isCharging) {
|
||||||
painter->setBrush(QBrush(QColor(0, 255, 0, 110)));
|
color = QColor(0, 255, 0, 220);
|
||||||
} else {
|
} else {
|
||||||
painter->setBrush(QBrush(QColor(0, 0, 255, 110)));
|
color = QColor(0, 0, 255, 220);
|
||||||
}
|
}
|
||||||
|
QLinearGradient grad(w - 111, h - 17, w - 111, h - 1);
|
||||||
|
grad.setColorAt(0, color.lighter());
|
||||||
|
grad.setColorAt(1, color.darker());
|
||||||
|
painter->setBrush(grad);
|
||||||
|
|
||||||
painter->drawRoundedRect(w - 111, h - 17, 10 + m_percent, 16, 5, 5);
|
painter->drawRoundedRect(w - 111, h - 17, 10 + m_percent, 16, 5, 5);
|
||||||
|
painter->drawText(w - 101, h - 15, 90, 14, Qt::AlignCenter, QString("%1%").arg(m_percent));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatteryLayer::repaint()
|
void BatteryLayer::repaint()
|
||||||
{
|
{
|
||||||
if (isVisible()) {
|
if (isVisible() && reload()) {
|
||||||
if (reload()) {
|
|
||||||
map()->update();
|
map()->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool BatteryLayer::reload()
|
bool BatteryLayer::reload()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user