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

List:       kde-commits
Subject:    playground/base/plasma/applets/train-clock
From:       Riccardo Iaconelli <riccardo () kde ! org>
Date:       2009-09-03 11:44:28
Message-ID: 1251978268.466000.12410.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1019362 by ruphy:

last qt 4.5 compatible changes in

Signed-off-by: Riccardo Iaconelli <riccardo@kde.org>

 M  +2 -0      CMakeLists.txt  
 M  +54 -17    clock.cpp  
 M  +5 -0      clock.h  
 M  +16 -9     train-clock.svg  


--- trunk/playground/base/plasma/applets/train-clock/CMakeLists.txt #1019361:1019362
@@ -4,6 +4,8 @@
     clock.cpp
     clocknumber.cpp)
 
+add_definitions(-fexceptions)
+
 kde4_add_ui_files(clock_SRCS clockConfig.ui )
 kde4_add_plugin(plasma_applet_train_clock ${clock_SRCS})
 target_link_libraries(plasma_applet_train_clock plasmaclock ${KDE4_PLASMA_LIBS} \
                ${KDE4_KDEUI_LIBS})
--- trunk/playground/base/plasma/applets/train-clock/clock.cpp #1019361:1019362
@@ -31,6 +31,7 @@
 #include <QPushButton>
 #include <QTimeLine>
 #include <QGraphicsGridLayout>
+#include <QSizePolicy>
 
 #include <KConfigDialog>
 #include <KDebug>
@@ -145,7 +146,7 @@
         m_handsCache = QPixmap(pixmapSize);
         m_glassCache = QPixmap(pixmapSize);
         
-        updateSizes();
+//         updateSizes();
 //         m_theme->resize(pixmapSize);
     }
     
@@ -183,7 +184,8 @@
 //         animateUpdate();
 //     }
 //     update();
-    animateUpdate();
+    adjustElements();
+//     animateUpdate();
     
     speakTime(m_time);
 }
@@ -235,15 +237,60 @@
 #ifndef waaa
 void Clock::initElements()
 {
-    QGraphicsGridLayout l;
-    for (int i = 0; i <= 5; i++) {
+    QGraphicsGridLayout *l = new QGraphicsGridLayout;
+    for (int i = 0; i < 5; i++) {
         Plasma::SvgWidget *w = new Plasma::SvgWidget(m_theme, QString(), this);
-        l.addItem(w, i, 0);
+        l->addItem(w, 0, i);
         w = new Plasma::SvgWidget(m_theme, QString(), this);
-        l.addItem(w, i, 1);
+        l->addItem(w, 1, i);
     }
+    
+    m_animatingWidget = new Plasma::SvgWidget(m_theme, QString(), this);
+    m_animatingWidget->hide();
+    setLayout(l);
+}
 
+void Clock::adjustElements()
+{
+    QGraphicsGridLayout *l = dynamic_cast<QGraphicsGridLayout *>(layout());
+    
+    if(!l) return;
+    
+    if (m_time.isValid()) {
+        for (int i = 0; i < 5; i++) {
+            
+            if (i == 2) { // the :
+                Plasma::SvgWidget *item = dynamic_cast<Plasma::SvgWidget \
*>(l->itemAt(0, i)); +                item->setElementID("colon-top");
+                item = dynamic_cast<Plasma::SvgWidget *>(l->itemAt(1, i));
+                item->setElementID("colon-bottom");
+                continue;
+            }
+            
+            Plasma::SvgWidget *item = dynamic_cast<Plasma::SvgWidget *>(l->itemAt(0, \
i)); +            item->setElementID("e"+timeString()[i]+"-p1");
+            item = dynamic_cast<Plasma::SvgWidget *>(l->itemAt(1, i));
+            item->setElementID("e"+timeString()[i]+"-p2");
+        }
+    }
 }
+
+void Clock::animateUpdate()
+{
+    //     kDebug();
+    QTimeLine *tl = new QTimeLine(200, this);
+    tl->setFrameRange(0, 4);
+    //     tl->setCurveShape(QTimeLine::EaseInCurve);
+    connect(tl, SIGNAL(frameChanged(int)), this, SLOT(animationSlot(int)));
+    connect(tl, SIGNAL(finished()), this, SLOT(finishAnimation()));
+    tl->start();
+}
+
+QString Clock::timeString()
+{
+    return m_time.toString("hh:ss");
+}
+
 #endif
 
 void Clock::repaintNeeded()
@@ -271,6 +318,7 @@
         m_timeRect.setWidth((int)(((m_timeRect.height()-m_verticalSpacing)/2) \
*1.4*4+(6*m_horizontalSpacing)));  } // small enough now.
     
+    
     m_timeRect = QRect(QPoint(0, 0), contentsRect().size().toSize());
     m_dateRect = QRect(0, 0, 0, 0);
     
@@ -300,17 +348,6 @@
     m_horizontalSpacing = qMin(4, qRound(m_elWidth/10));
 }
 
-void Clock::animateUpdate()
-{
-    //     kDebug();
-    QTimeLine *tl = new QTimeLine(200, this);
-    tl->setFrameRange(0, 4);
-//     tl->setCurveShape(QTimeLine::EaseInCurve);
-    connect(tl, SIGNAL(frameChanged(int)), this, SLOT(animationSlot(int)));
-    connect(tl, SIGNAL(finished()), this, SLOT(finishAnimation()));
-    tl->start();
-}
-
 void Clock::finishAnimation()
 {
     m_animating = false;
--- trunk/playground/base/plasma/applets/train-clock/clock.h #1019361:1019362
@@ -39,6 +39,7 @@
 {
     class FrameSvg;
     class Svg;
+    class SvgWidget;
     class Dialog;
 }
 
@@ -69,7 +70,9 @@
         
     private:
         void initElements();
+        void adjustElements();
         void connectToEngine();
+        QString timeString();
         QRect tzRect();
         Plasma::FrameSvg *tzFrame();
         int getOffsetForDigit(int digitNumber);
@@ -130,6 +133,8 @@
         int m_horizontalSpacing;
         int m_verticalSpacing;
         
+        Plasma::SvgWidget *m_animatingWidget;
+        
 };
 
 K_EXPORT_PLASMA_APPLET(train_clock, Clock)
--- trunk/playground/base/plasma/applets/train-clock/train-clock.svg #1019361:1019362
@@ -1,9 +1,8 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!-- Created with Inkscape (http://www.inkscape.org/) -->
 <svg
-   xmlns:ns="http://creativecommons.org/ns#"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
-   xmlns:cc="http://web.resource.org/cc/"
+   xmlns:cc="http://creativecommons.org/ns#"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:svg="http://www.w3.org/2000/svg"
    xmlns="http://www.w3.org/2000/svg"
@@ -14,7 +13,7 @@
    height="211.72636"
    id="svg3383"
    sodipodi:version="0.32"
-   inkscape:version="0.45.1"
+   inkscape:version="0.46"
    version="1.0"
    sodipodi:docbase="/home/sebas/dev/KDE/playground-base/plasma/applets/train-clock"
    sodipodi:docname="train-clock.svg"
@@ -39,9 +38,9 @@
      width="130px"
      height="130px"
      inkscape:window-width="1219"
-     inkscape:window-height="734"
-     inkscape:window-x="456"
-     inkscape:window-y="80"
+     inkscape:window-height="720"
+     inkscape:window-x="139"
+     inkscape:window-y="-29"
      showguides="true"
      inkscape:guide-bbox="true"
      gridtolerance="7"
@@ -55,6 +54,13 @@
   </sodipodi:namedview>
   <defs
      id="defs3385">
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 105.86318 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="692 : 105.86318 : 1"
+       inkscape:persp3d-origin="346 : 70.575455 : 1"
+       id="perspective2622" />
     <linearGradient
        inkscape:collect="always"
        id="linearGradient4349">
@@ -502,12 +508,12 @@
   <metadata
      id="metadata3388">
     <rdf:RDF>
-      <ns:Work
+      <cc:Work
          rdf:about="">
         <dc:format>image/svg+xml</dc:format>
         <dc:type
            rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-      </ns:Work>
+      </cc:Work>
       <cc:Work
          rdf:about="">
         <dc:format>image/svg+xml</dc:format>
@@ -994,7 +1000,8 @@
     </g>
     <g
        id="colon-bottom"
-       transform="matrix(1,0,0,1.0311312,0,-2.13929)">
+       transform="matrix(1,0,0,1.0311312,0,-2.13929)"
+       inkscape:label="#wawa">
       <g
          transform="matrix(0.5775876,0,0,1,-239.9009,0)"
          id="g3185">


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

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