Changeset View
Changeset View
Standalone View
Standalone View
kcms/dateandtime/dtime.cpp
Show First 20 Lines • Show All 338 Lines • ▼ Show 20 Line(s) | |||||
339 | void Kclock::resizeEvent( QResizeEvent * ) | 339 | void Kclock::resizeEvent( QResizeEvent * ) | ||
340 | { | 340 | { | ||
341 | setClockSize( size() ); | 341 | setClockSize( size() ); | ||
342 | } | 342 | } | ||
343 | 343 | | |||
344 | void Kclock::setClockSize(const QSize &size) | 344 | void Kclock::setClockSize(const QSize &size) | ||
345 | { | 345 | { | ||
346 | int dim = qMin(size.width(), size.height()); | 346 | int dim = qMin(size.width(), size.height()); | ||
347 | QSize newSize = QSize(dim, dim) * devicePixelRatio(); | 347 | QSize newSize = QSize(dim, dim) * devicePixelRatioF(); | ||
348 | 348 | | |||
349 | if (newSize != m_faceCache.size()) { | 349 | if (newSize != m_faceCache.size()) { | ||
350 | m_faceCache = QPixmap(newSize); | 350 | m_faceCache = QPixmap(newSize); | ||
351 | m_handsCache = QPixmap(newSize); | 351 | m_handsCache = QPixmap(newSize); | ||
352 | m_glassCache = QPixmap(newSize); | 352 | m_glassCache = QPixmap(newSize); | ||
353 | m_faceCache.setDevicePixelRatio(devicePixelRatio()); | 353 | m_faceCache.setDevicePixelRatio(devicePixelRatioF()); | ||
354 | m_handsCache.setDevicePixelRatio(devicePixelRatio()); | 354 | m_handsCache.setDevicePixelRatio(devicePixelRatioF()); | ||
355 | m_glassCache.setDevicePixelRatio(devicePixelRatio()); | 355 | m_glassCache.setDevicePixelRatio(devicePixelRatioF()); | ||
356 | 356 | | |||
357 | m_theme->resize(QSize(dim, dim)); | 357 | m_theme->resize(QSize(dim, dim)); | ||
358 | m_repaintCache = RepaintAll; | 358 | m_repaintCache = RepaintAll; | ||
359 | } | 359 | } | ||
360 | } | 360 | } | ||
361 | 361 | | |||
362 | void Kclock::setTime(const QTime &time) | 362 | void Kclock::setTime(const QTime &time) | ||
363 | { | 363 | { | ||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 415 | { | |||
422 | qreal seconds = 0; | 422 | qreal seconds = 0; | ||
423 | if (m_showSecondHand) { | 423 | if (m_showSecondHand) { | ||
424 | static const double anglePerSec = 6; | 424 | static const double anglePerSec = 6; | ||
425 | seconds = anglePerSec * time.second() - 180; | 425 | seconds = anglePerSec * time.second() - 180; | ||
426 | } | 426 | } | ||
427 | 427 | | |||
428 | // paint face and glass cache | 428 | // paint face and glass cache | ||
429 | QRect faceRect = m_faceCache.rect(); | 429 | QRect faceRect = m_faceCache.rect(); | ||
430 | QRect targetRect = QRect(QPoint(0, 0), QSize(m_faceCache.width() / devicePixelRatio(), m_faceCache.height() / devicePixelRatio())); | 430 | QRect targetRect = QRect(QPoint(0, 0), QSize(m_faceCache.width() / devicePixelRatioF(), m_faceCache.height() / devicePixelRatioF())); | ||
431 | 431 | | |||
432 | if (m_repaintCache == RepaintAll) { | 432 | if (m_repaintCache == RepaintAll) { | ||
433 | m_faceCache.fill(Qt::transparent); | 433 | m_faceCache.fill(Qt::transparent); | ||
434 | m_glassCache.fill(Qt::transparent); | 434 | m_glassCache.fill(Qt::transparent); | ||
435 | 435 | | |||
436 | QPainter facePainter(&m_faceCache); | 436 | QPainter facePainter(&m_faceCache); | ||
437 | QPainter glassPainter(&m_glassCache); | 437 | QPainter glassPainter(&m_glassCache); | ||
438 | facePainter.setRenderHint(QPainter::SmoothPixmapTransform); | 438 | facePainter.setRenderHint(QPainter::SmoothPixmapTransform); | ||
439 | glassPainter.setRenderHint(QPainter::SmoothPixmapTransform); | 439 | glassPainter.setRenderHint(QPainter::SmoothPixmapTransform); | ||
440 | 440 | | |||
441 | m_theme->paint(&facePainter, targetRect, QStringLiteral("ClockFace")); | 441 | m_theme->paint(&facePainter, targetRect, QStringLiteral("ClockFace")); | ||
442 | 442 | | |||
443 | glassPainter.save(); | 443 | glassPainter.save(); | ||
444 | QRectF elementRect = QRectF(QPointF(0, 0), m_theme->elementSize(QStringLiteral("HandCenterScrew"))); | 444 | QRectF elementRect = QRectF(QPointF(0, 0), m_theme->elementSize(QStringLiteral("HandCenterScrew"))); | ||
445 | glassPainter.translate(faceRect.width() / (2 * devicePixelRatio()) - elementRect.width() / 2, faceRect.height() / (2 * devicePixelRatio()) - elementRect.height() / 2); | 445 | glassPainter.translate(faceRect.width() / (2 * devicePixelRatioF()) - elementRect.width() / 2, faceRect.height() / (2 * devicePixelRatioF()) - elementRect.height() / 2); | ||
446 | m_theme->paint(&glassPainter, elementRect, QStringLiteral("HandCenterScrew")); | 446 | m_theme->paint(&glassPainter, elementRect, QStringLiteral("HandCenterScrew")); | ||
447 | glassPainter.restore(); | 447 | glassPainter.restore(); | ||
448 | 448 | | |||
449 | m_theme->paint(&glassPainter, targetRect, QStringLiteral("Glass")); | 449 | m_theme->paint(&glassPainter, targetRect, QStringLiteral("Glass")); | ||
450 | 450 | | |||
451 | // get vertical translation, see drawHand() for more details | 451 | // get vertical translation, see drawHand() for more details | ||
452 | m_verticalTranslation = m_theme->elementRect(QStringLiteral("ClockFace")).center().y(); | 452 | m_verticalTranslation = m_theme->elementRect(QStringLiteral("ClockFace")).center().y(); | ||
453 | } | 453 | } | ||
Show All 37 Lines |