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

List:       kde-commits
Subject:    KDE/kdeplasma-addons/applets/rememberthemilk
From:       Bruno de Oliveira Abinader <brunoabinader () gmail ! com>
Date:       2010-02-11 23:02:15
Message-ID: 1265929335.681855.26739.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1088935 by abinader:

Updated Remember the milk plasmoid fade animation to use \
                Plasma::Animator::FadeAnimation
-This line, and those below, will be ignored--

M    kdeplasma-addons/applets/rememberthemilk/taskeditor.cpp
M    kdeplasma-addons/applets/rememberthemilk/taskeditor.h


 M  +25 -27    taskeditor.cpp  
 M  +3 -2      taskeditor.h  


--- trunk/KDE/kdeplasma-addons/applets/rememberthemilk/taskeditor.cpp \
#1088934:1088935 @@ -34,6 +34,7 @@
 
 #include <Plasma/Theme>
 #include <Plasma/Animator>
+#include <Plasma/Animation>
 #include <Plasma/IconWidget>
 #include <Plasma/Service>
 
@@ -100,8 +101,6 @@
   mainLayout->addItem(saveChangesButton, 7, 0, 1, 2);
   mainLayout->addItem(discardChangesButton, 8, 0, 1, 2);
 
-  opacity = .9;
-
   setLayout(mainLayout);
 }
 
@@ -194,7 +193,6 @@
 void TaskEditor::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, \
QWidget* widget) {  Q_UNUSED(widget)
   QColor wash = Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor);
                
-  wash.setAlphaF(opacity);
   painter->setBrush(wash);
   painter->drawRect(option->exposedRect);
 }
@@ -208,45 +206,45 @@
 
 void TaskEditor::startAnimation(QSizeF endSize, bool show) {
     appearing = show;
-    if (appearing) {
-      opacity = 0;
+    if (appearing)
       foreach(QGraphicsItem* child, childItems())
-	child->show();
-    }
-    else
-      this->show();
+        child->show();
+
     this->show();
+
     fullSize = endSize;
     resize(fullSize);
-    if (show)
-      Plasma::Animator::self()->customAnimation(10, 100, \
                Plasma::Animator::EaseInCurve, this, "onAnimValueChanged");
-    else
-      Plasma::Animator::self()->customAnimation(10, 100, \
                Plasma::Animator::EaseOutCurve, this, "onAnimValueChanged");
-}
 
-void TaskEditor::onAnimValueChanged(qreal value) {
-    if (value == 1.0) {
-        animationFinished();
-        return;
+    Plasma::Animation *animation = m_fadeAnimation.data();
+    if (!animation) {
+      animation = Plasma::Animator::create(Plasma::Animator::FadeAnimation);
+      animation->setTargetWidget(this);
+      animation->setProperty("startValue", 0.0);
+      animation->setProperty("endValue", 1.0);
+      animation->setProperty("duration", 100);
+      m_fadeAnimation = animation;
+      connect(animation, SIGNAL(finished()), this, SLOT(animationFinished()));
+    } else if (animation->state() == QAbstractAnimation::Running) {
+      animation->pause();
     }
 
-
-  if (appearing)
-    opacity = value*.9;
-  else
-    opacity = (1-value)*.9;
-
-    update();
+    if (show) {
+      animation->setProperty("easingCurve", QEasingCurve::InQuad);
+      animation->setProperty("direction", QAbstractAnimation::Forward);
+      animation->start(QAbstractAnimation::KeepWhenStopped);
+    } else {
+      animation->setProperty("easingCurve", QEasingCurve::OutQuad);
+      animation->setProperty("direction", QAbstractAnimation::Backward);
+      animation->start(QAbstractAnimation::DeleteWhenStopped);
+    }
 }
 
 void TaskEditor::animationFinished() {
     if (appearing) {
       setPos(0, 0);
       resize(fullSize);
-      opacity = .9;
     }
     else {
-      opacity = 0;
       hide();
     }
 
--- trunk/KDE/kdeplasma-addons/applets/rememberthemilk/taskeditor.h #1088934:1088935
@@ -23,6 +23,7 @@
 
 namespace Plasma {
   class ServiceJob;
+  class Animation;
 }
 
 //#include <Plasma/Frame>
@@ -35,6 +36,7 @@
 #include <QGraphicsGridLayout>
 #include <QGraphicsWidget>
 #include <QModelIndex>
+#include <QWeakPointer>
 
 class TaskEditor : public QGraphicsWidget
 {
@@ -58,7 +60,6 @@
 
 public slots:
   void startAnimation(QSizeF endSize, bool show = true);
-  void onAnimValueChanged(qreal value);
   void animationFinished();
 
 protected slots:
@@ -90,12 +91,12 @@
 
   bool appearing; // used to know which direction to go in for the animation
   QSizeF fullSize;
-  qreal opacity;
   QString m_name;
   QString m_date;
   QString m_tags;
   int m_priority;
   Plasma::Service* m_service;
+  QWeakPointer<Plasma::Animation> m_fadeAnimation;
 };
 
 #endif // TASKEDITOR_H


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

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