[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/plasma/applets/digital-clock
From: Beat Wolf <asraniel () fryx ! ch>
Date: 2009-08-03 20:20:41
Message-ID: 1249330841.986271.21315.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1006495 by beatwolf:
don't make the clock jump around with non monospace fonts
BUG:185202
M +15 -7 clock.cpp
--- trunk/KDE/kdebase/workspace/plasma/applets/digital-clock/clock.cpp \
#1006494:1006495 @@ -343,10 +343,17 @@
// space is left for painting the time on top of it.
QRectF dateRect;
const QString timeString = KGlobal::locale()->formatTime(m_time, m_showSeconds);
+ QString fakeTimeString = "23:59";
+ if(m_showSeconds){
+ fakeTimeString += ":59";
+ }
+
QFont smallFont = KGlobalSettings::smallestReadableFont();
if (m_showDate || showTimezone()) {
QString dateString;
+
+ //Create the localized date string if needed
if (m_showDate) {
KLocale tmpLocale(*KGlobal::locale());
tmpLocale.setDateFormat("%e"); // day number of the month
@@ -411,7 +418,7 @@
if (formFactor() == Plasma::Vertical) {
smallFont.setPixelSize(qMax(contentsRect.height()/6, fm.ascent()));
} else if (formFactor() == Plasma::Horizontal) {
- smallFont.setPixelSize(qMax(qMin(contentsRect.height(), \
contentsRect.width())*2/7, fm.ascent())); + \
smallFont.setPixelSize(qMax(qMin(contentsRect.height(), contentsRect.width())*2/7, \
fm.ascent())); } else {
smallFont.setPixelSize(qMax(qMin(contentsRect.height(), \
contentsRect.width())/8, KGlobalSettings::smallestReadableFont().pointSize())); }
@@ -459,8 +466,8 @@
// kDebug(96669) << m_time;
// Choose a relatively big font size to start with
m_plainClockFont.setPointSizeF(qMax(m_timeRect.height(), \
KGlobalSettings::smallestReadableFont().pointSize()));
- preparePainter(p, m_timeRect, m_plainClockFont, timeString, true);
-
+ preparePainter(p, m_timeRect, m_plainClockFont, fakeTimeString, true);
+
if (!m_dateString.isEmpty()) {
if (m_dateTimezoneBesides) {
QFontMetrics fm(m_plainClockFont);
@@ -483,10 +490,11 @@
p->setFont(f);
}
-
- QTextOption textOption(m_dateTimezoneBesides ? Qt::AlignCenter | \
Qt::AlignVCenter : Qt::AlignCenter);
- textOption.setWrapMode(QTextOption::NoWrap);
- p->drawText(m_timeRect, timeString, textOption);
+
+ QFontMetrics fm(p->font());
+
+ p->drawText(QPoint(m_timeRect.center().x() - fm.width(fakeTimeString) / 2,
+ m_timeRect.center().y() + fm.height() / 3), timeString);
}
QRect Clock::preparePainter(QPainter *p, const QRect &rect, const QFont &font, const \
QString &text, bool singleline)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic