eric6/E5Gui/E5TabWidget.py

changeset 7514
0960c7c1f497
parent 7360
9190402e4505
child 7759
51aa6c6b66f7
--- a/eric6/E5Gui/E5TabWidget.py	Thu Apr 09 17:59:24 2020 +0200
+++ b/eric6/E5Gui/E5TabWidget.py	Thu Apr 09 18:00:40 2020 +0200
@@ -8,9 +8,11 @@
 """
 
 
-from PyQt5.QtCore import Qt, QPoint, QMimeData, QByteArray, pyqtSignal
-from PyQt5.QtGui import QDrag, QMovie
-from PyQt5.QtWidgets import QTabWidget, QTabBar, QApplication, QStyle, QLabel
+from PyQt5.QtCore import pyqtSignal, Qt, QPoint, QMimeData
+from PyQt5.QtGui import QDrag
+from PyQt5.QtWidgets import QTabWidget, QTabBar, QApplication, QStyle
+
+from E5Gui.E5AnimatedLabel import E5AnimatedLabel
 
 
 class E5WheelTabBar(QTabBar):
@@ -311,29 +313,29 @@
             side = QTabBar.LeftSide
         return side
     
-    def animationLabel(self, index, animationFile, speed=100):
+    def animationLabel(self, index, animationFile, interval=100):
         """
         Public slot to set an animated icon.
         
-        @param index tab index (integer)
-        @param animationFile name of the file containing the animation (string)
-        @param speed animation speed of the icon in percent of the original
-            icon's speed (integer)
-        @return reference to the created label (QLabel)
+        @param index tab index
+        @type int
+        @param animationFile name of the file containing the animation
+        @type str
+        @param interval interval in milliseconds between animation frames
+        @type int
+        @return reference to the created label
+        @rtype E5AnimatedLabel
         """
         if index == -1:
             return None
         
         if hasattr(self.__tabBar, 'setTabButton'):
             side = self.__freeSide()
-            animation = QLabel(self)
-            if animationFile and not animation.movie():
-                movie = QMovie(animationFile, QByteArray(), animation)
-                movie.setSpeed(speed)
-                animation.setMovie(movie)
-                movie.start()
+            animation = E5AnimatedLabel(
+                self, animationFile=animationFile, interval=interval)
             self.__tabBar.setTabButton(index, side, None)
             self.__tabBar.setTabButton(index, side, animation)
+            animation.start()
             return animation
         else:
             return None
@@ -351,6 +353,6 @@
             side = self.__freeSide()
             animation = self.__tabBar.tabButton(index, side)
             if animation is not None:
-                animation.movie().stop()
+                animation.stop()
                 self.__tabBar.setTabButton(index, side, None)
                 del animation

eric ide

mercurial