From e2de64d6f1beb9e492daf5b886e19933c1fa41dd Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- noatun/modules/winskin/waDigit.cpp | 89 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 noatun/modules/winskin/waDigit.cpp (limited to 'noatun/modules/winskin/waDigit.cpp') diff --git a/noatun/modules/winskin/waDigit.cpp b/noatun/modules/winskin/waDigit.cpp new file mode 100644 index 00000000..b775d7cf --- /dev/null +++ b/noatun/modules/winskin/waDigit.cpp @@ -0,0 +1,89 @@ +/* + The digit for the time + Copyright (C) 1999 Martin Vogt + Copyright (C) 2002 Ryan Cumming + + 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 + the Free Software Foundation. + + For more information look at the file COPYRIGHT in this package + + */ + + +#include "waDigit.h" +#include "waSkinModel.h" + +#include +#include + +WaDigit::WaDigit() : WaWidget(_WA_MAPPING_DIGITS) +{ + KConfig *config = KGlobal::config(); + config->setGroup("Winskin"); + + reverse_time = config->readNumEntry("timeReversed", false); +} + + +WaDigit::~WaDigit() +{ + KConfig *config = KGlobal::config(); + config->setGroup("Winskin"); + config->writeEntry("timeReversed", reverse_time); +} + +void WaDigit::paintEvent(QPaintEvent *) +{ + paintBackground(); + + const char *time = timeString.latin1(); + int len = strlen(time); + if (len == 0) + return; + + // Declare all these variables after we check for zero-length + WaSkinModel *waSkinModel = WaSkinModel::instance(); + + int x = waSkinModel->getMapGeometry(mapping).x(); + int y = waSkinModel->getMapGeometry(mapping).y(); + + QRect mapRect; + + // We expect strings either in the form "xx:yy", or "-xx:yy" + // If the string length is 6, we have it in the form of "-xx:yy" + // Remove the -, move the string forward one character, and + // continue parsing + mapRect = waSkinModel->getMapGeometry(_WA_MAPPING_MINUS); + if (len == 6) { + waSkinModel->getDigit('-', this, mapRect.x() - x, mapRect.y() - y); + time++; + } + else { + waSkinModel->getDigit(' ', this, mapRect.x() - x, mapRect.y() - y); + } + + mapRect = waSkinModel->getMapGeometry(_WA_MAPPING_DIGIT_1); + waSkinModel->getDigit(time[0], this, mapRect.x() - x, mapRect.y() - y); + + mapRect = waSkinModel->getMapGeometry(_WA_MAPPING_DIGIT_2); + waSkinModel->getDigit(time[1], this, mapRect.x() - x, mapRect.y() - y); + + mapRect = waSkinModel->getMapGeometry(_WA_MAPPING_DIGIT_3); + waSkinModel->getDigit(time[3], this, mapRect.x() - x, mapRect.y() - y); + + mapRect = waSkinModel->getMapGeometry(_WA_MAPPING_DIGIT_4); + waSkinModel->getDigit(time[4], this, mapRect.x() - x, mapRect.y() - y); +} + +void WaDigit::mousePressEvent(QMouseEvent* e) { + if (e->button() == LeftButton) { + reverse_time = !reverse_time; + emit digitsClicked(); + } + else + WaWidget::mousePressEvent(e); +} + +#include "waDigit.moc" -- cgit v1.2.3