[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeplasma-addons/applets/timer
From:       Davide Bettio <davide.bettio () kdemail ! net>
Date:       2009-04-20 20:13:35
Message-ID: 1240258415.443611.27382.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 956873 by bettio:

WheelEvent is managed correctly.


 M  +1 -1      CMakeLists.txt  
 M  +18 -44    timer.cpp  
 M  +5 -4      timer.h  
 A             timerdigit.cpp   [License: LGPL (v2+)]
 A             timerdigit.h   [License: LGPL (v2+)]


--- trunk/KDE/kdeplasma-addons/applets/timer/CMakeLists.txt #956872:956873
@@ -15,7 +15,7 @@
    )
 
 # We add our source code here
-set(timer_SRCS timer.cpp customtimeeditor.cpp)
+set(timer_SRCS timer.cpp timerdigit.cpp customtimeeditor.cpp)
 kde4_add_ui_files(timer_SRCS timerConfig.ui predefinedTimersConfig.ui)
 
 # Now make sure all files get to the right place
--- trunk/KDE/kdeplasma-addons/applets/timer/timer.cpp #956872:956873
@@ -65,17 +65,24 @@
         m_separatorBasename += 'C';
     }
 
-    m_hoursDigit[0] = new Plasma::SvgWidget(m_svg, "0", this);
-    m_hoursDigit[1] = new Plasma::SvgWidget(m_svg, "0", this);
-    m_minutesDigit[0] = new Plasma::SvgWidget(m_svg, "0", this);
-    m_minutesDigit[1] = new Plasma::SvgWidget(m_svg, "0", this);
-    m_secondsDigit[0] = new Plasma::SvgWidget(m_svg, "0", this);
-    m_secondsDigit[1] = new Plasma::SvgWidget(m_svg, "0", this);
+    m_hoursDigit[0] = new TimerDigit(m_svg, 36000, this);
+    m_hoursDigit[1] = new TimerDigit(m_svg, 3600, this);
+    m_minutesDigit[0] = new TimerDigit(m_svg, 600, this);
+    m_minutesDigit[1] = new TimerDigit(m_svg, 60, this);
+    m_secondsDigit[0] = new TimerDigit(m_svg, 10, this);
+    m_secondsDigit[1] = new TimerDigit(m_svg, 1, this);
     m_separator[0] = new Plasma::SvgWidget(m_svg, m_separatorBasename, this);
     m_separator[1] = new Plasma::SvgWidget(m_svg, m_separatorBasename, this);
     m_title = new Plasma::Label(this);
     m_title->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
 
+    connect(m_hoursDigit[0], SIGNAL(changed(int)), this, SLOT(digitChanged(int)));
+    connect(m_hoursDigit[1], SIGNAL(changed(int)), this, SLOT(digitChanged(int)));
+    connect(m_minutesDigit[0], SIGNAL(changed(int)), this, SLOT(digitChanged(int)));
+    connect(m_minutesDigit[1], SIGNAL(changed(int)), this, SLOT(digitChanged(int)));
+    connect(m_secondsDigit[0], SIGNAL(changed(int)), this, SLOT(digitChanged(int)));
+    connect(m_secondsDigit[1], SIGNAL(changed(int)), this, SLOT(digitChanged(int)));
+
     KConfigGroup cg = config();
     m_predefinedTimers = cg.readEntry("predefinedTimers", QStringList() << "00:00:30" << "00:01:00"
                                                        << "00:02:00" << "00:05:00" << "00:07:30"
@@ -387,49 +394,16 @@
     startTimer();
 }
 
-void Timer::wheelEvent(QGraphicsSceneWheelEvent * event)
+void Timer::digitChanged(int value)
 {
-    Q_UNUSED(event);
-
     if (m_running) return;
 
-    int delta = 0;
-
-    int appletHeight = (int) contentsRect().height();
-    int appletWidth = (int) contentsRect().width();
-
-    int h = (appletHeight / 2) * 7 < appletWidth ? appletHeight : ((appletWidth - 6) / 7) * 2;
-    int w = h / 2;
-    int y = ((int) contentsRect().y()) + (appletHeight - h) / 2;
-    int x = ((int) contentsRect().x()) + (appletWidth - w * 7) / 2;
-
-    if (!(event->pos().y() > y && event->pos().y() < y + h)) return;
-
-    if ((event->pos().x() > x) && (event->pos().x() < x + w)){
-        delta = 36000;
-
-    }else if ((event->pos().x() > x + w) && (event->pos().x() < x + (w * 2))){
-        delta = 3600;
-
-    }else if ((event->pos().x() > x + (w * 2) + (w / 2)) && (event->pos().x() < x + (w * 3) + (w / 2))){
-        delta = 600;
-
-    }else if ((event->pos().x() > x + (w * 3) + (w / 2)) && (event->pos().x() < x + (w * 4) + (w / 2))){
-        delta = 60;
-
-    }else if ((event->pos().x() > x + (w * 5)) && (event->pos().x() < x + (w * 6))){
-        delta = 10;
-
-    }else if ((event->pos().x() > x + (w * 6)) && (event->pos().x() < x + (w * 7))){
-        delta = 1;
-    }
-
-    if (event->delta() < 0){
-        if (m_seconds >= delta){
-            setSeconds((m_seconds - delta) % 86400);
+    if (value < 0){
+        if (m_seconds >= abs(value)){
+            setSeconds((m_seconds - abs(value)) % 86400);
         }
     }else{
-        setSeconds((m_seconds + delta) % 86400);
+        setSeconds((m_seconds + abs(value)) % 86400);
     }
 
     if (m_seconds != 0){
--- trunk/KDE/kdeplasma-addons/applets/timer/timer.h #956872:956873
@@ -26,6 +26,7 @@
 
 #include "ui_predefinedTimersConfig.h"
 #include "ui_timerConfig.h"
+#include "timerdigit.h"
 
 class QGraphicsSceneMouseEvent;
 class QGraphicsTextItem;
@@ -50,7 +51,6 @@
         void init();
         void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
         void mousePressEvent(QGraphicsSceneMouseEvent * event);
-        void wheelEvent(QGraphicsSceneWheelEvent * event);
         QList<QAction*> contextualActions();
 
     protected:
@@ -64,6 +64,7 @@
         void stopTimer();
         void resetTimer();
         void startTimerFromAction();
+        void digitChanged(int value);
 
     private:
         void saveTimer();
@@ -74,9 +75,9 @@
 
         QTimer timer;
         Plasma::Svg *m_svg;
-        Plasma::SvgWidget *m_hoursDigit[2];
-        Plasma::SvgWidget *m_minutesDigit[2];
-        Plasma::SvgWidget *m_secondsDigit[2];
+        TimerDigit *m_hoursDigit[2];
+        TimerDigit *m_minutesDigit[2];
+        TimerDigit *m_secondsDigit[2];
         Plasma::SvgWidget *m_separator[2];
         Plasma::Label *m_title;
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic