summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuiz Agostini <luiz.agostini@openbossa.org>2009-11-13 14:41:34 -0300
committerLuiz Agostini <luiz.agostini@openbossa.org>2009-11-13 15:42:02 -0300
commit112cb2a1503cdef17b09706822e0ec57096897ef (patch)
treeb13bb2eb498650b15eff8446a64275d9d8284f9e
parent93a769d08aa3642cb131b930e3fb9250e94ac9d6 (diff)
Weather: adjusting current temperature text alignment.
Signed-off-by: Luiz Agostini <luiz.agostini@openbossa.org>
-rw-r--r--weather/cityinfodisplay.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/weather/cityinfodisplay.cpp b/weather/cityinfodisplay.cpp
index ba50bd5..570ef8a 100644
--- a/weather/cityinfodisplay.cpp
+++ b/weather/cityinfodisplay.cpp
@@ -97,20 +97,27 @@ void CurrentTemperatureDisplay::setTemperature(int value)
m_text = QString::number(qAbs(m_value));
QFontMetrics metrics(m_font);
- int width = metrics.width(m_text);
- int left = -(width >> 1);
-
- m_numberPos = QPointF(left, m_unit.height());
-
- width += m_sign.width();
- left -= m_sign.width();
-
- m_signPos = QPointF(left, 0.0);
- m_unitPos = QPointF(left + width, 0.0);
-
- width += m_unit.width();
+ int textWidth = metrics.width(m_text);
+ int width = textWidth;
+ int left = 0;
+
+ if (m_value < 0) {
+ left = -(width >> 1);
+ m_numberPos = QPointF(left, m_unit.height());
+ width += m_sign.width();
+ left -= m_sign.width();
+ m_signPos = QPointF(left, 0.0);
+ m_unitPos = QPointF(left + width, 0.0);
+ width += m_unit.width();
+ } else {
+ width += m_unit.width();
+ int left = -(width >> 1);
+ m_numberPos = QPointF(left, m_unit.height());
+ m_unitPos = QPointF(left + textWidth, 0.0);
+ }
m_boundingRect = QRectF(left, 0.0, width, m_unit.height());
+
}
// TemperatureBoundDisplay