My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 79: Opacity animations with Qt4.5
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Mar 2010


 
Reported by filipe.c...@gmail.com, Mar 3, 2010
There are no opacity animations for Qt4.5.
The following patch adds them although I think it might be wise to have a 
way to disable them as it might make things slow on some systems:

--- a/marave/main.py
+++ b/marave/main.py
@@ -179,20 +179,25 @@ def fadein(thing, target=1., thendo=None):
         if thendo:
             thing.anim.finished.connect(thendo)
     else:
-        # FIXME maybe implement a timeline based opacity for 
QGraphicsItems
         if isinstance(thing, QtGui.QGraphicsItem):
-            thing.setOpacity(target)
-            if (target):
-                thing.show()
-            else:
-                thing.hide()
-        else:
-            thing.proxy.setOpacity(target)
-            if (target):
-                thing.proxy.show()
-            else:
-                thing.proxy.hide()
-        if thendo: thendo()
+           w = thing
+       else:
+           w = thing.proxy
+       w.show()
+       w.startOpacity = w.opacity()
+       w.endOpacity = target
+       def animateOpacity(v):
+           op = v*(w.endOpacity-w.startOpacity)+w.startOpacity
+           w.setOpacity(op)
+       def animationFinished():
+           if(w.endOpacity == 0):
+               w.hide()
+           if thendo: thendo()
+       thing.tline = QtCore.QTimeLine(200)         
+       thing.tline.setCurveShape(QtCore.QTimeLine.LinearCurve)
+       thing.tline.valueChanged.connect(animateOpacity)
+       thing.tline.finished.connect(animationFinished)
+       thing.tline.start()
 
 def fadeout(thing, thendo=None):
     fadein(thing, 0, thendo)
Mar 5, 2010
Project Member #1 roberto.alsina
I will commit the patch as r447 as soon as SVN becomes R/W again.
Mar 5, 2010
Project Member #2 roberto.alsina
Commited the patch, and also added a --no-animation option in r449.

I think that's all for this Issue, so closing it.
Status: Fixed

Powered by Google Project Hosting