[vlc-commits] Qt: move animators code

Francois Cartegnie git at videolan.org
Sun Feb 9 21:27:03 CET 2014


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Feb  8 15:01:03 2014 +0100| [0f1dbde6699ea778da6c02eab5d73a8d1cacd8fb] | committer: Francois Cartegnie

Qt: move animators code

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0f1dbde6699ea778da6c02eab5d73a8d1cacd8fb
---

 modules/gui/qt4/Makefile.am                        |    2 +
 .../gui/qt4/components/playlist/standardpanel.cpp  |    2 +-
 modules/gui/qt4/util/animators.cpp                 |   47 ++++++++++++++++
 modules/gui/qt4/util/animators.hpp                 |   59 ++++++++++++++++++++
 modules/gui/qt4/util/customwidgets.cpp             |   22 --------
 modules/gui/qt4/util/customwidgets.hpp             |   32 +----------
 6 files changed, 111 insertions(+), 53 deletions(-)

diff --git a/modules/gui/qt4/Makefile.am b/modules/gui/qt4/Makefile.am
index 82f55fb..fd588dd 100644
--- a/modules/gui/qt4/Makefile.am
+++ b/modules/gui/qt4/Makefile.am
@@ -100,6 +100,7 @@ libqt4_plugin_la_SOURCES = \
 		components/sout/profile_selector.hpp \
 	components/sout/sout_widgets.cpp components/sout/sout_widgets.hpp \
 		components/sout/profiles.hpp \
+	util/animators.cpp util/animators.hpp \
 	util/input_slider.cpp util/input_slider.hpp \
 	util/timetooltip.cpp util/timetooltip.hpp \
 	util/customwidgets.cpp util/customwidgets.hpp \
@@ -190,6 +191,7 @@ nodist_libqt4_plugin_la_SOURCES = \
 	components/playlist/ml_model.moc.cpp \
 	components/sout/profile_selector.moc.cpp \
 	components/sout/sout_widgets.moc.cpp \
+	util/animators.moc.cpp \
 	util/input_slider.moc.cpp \
 	util/timetooltip.moc.cpp \
 	util/customwidgets.moc.cpp \
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index faac01b..954bda6 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -33,7 +33,7 @@
 #include "components/playlist/ml_model.hpp"       /* MLModel */
 #include "components/playlist/views.hpp"          /* 3 views */
 #include "components/playlist/selector.hpp"       /* PLSelector */
-#include "util/customwidgets.hpp"                 /* PixmapAnimator */
+#include "util/animators.hpp"                     /* PixmapAnimator */
 #include "menus.hpp"                              /* Popup */
 #include "input_manager.hpp"                      /* THEMIM */
 #include "dialogs_provider.hpp"                   /* THEDP */
diff --git a/modules/gui/qt4/util/animators.cpp b/modules/gui/qt4/util/animators.cpp
new file mode 100644
index 0000000..9bed3a6
--- /dev/null
+++ b/modules/gui/qt4/util/animators.cpp
@@ -0,0 +1,47 @@
+/*****************************************************************************
+ * animators.cpp: Object animators
+ ****************************************************************************
+ * Copyright (C) 2006-2014 the VideoLAN team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include "animators.hpp"
+
+#include <QWidget>
+#include <QPixmap>
+
+PixmapAnimator::PixmapAnimator( QWidget *parent, QList<QString> frames )
+    : QAbstractAnimation( parent ), current_frame( 0 )
+{
+    foreach( QString name, frames )
+        pixmaps.append( new QPixmap( name ) );
+    currentPixmap = pixmaps.at( 0 );
+    setFps( frames.count() ); /* default to 1 sec loop */
+    setLoopCount( -1 );
+}
+
+void PixmapAnimator::updateCurrentTime( int msecs )
+{
+    int i = msecs / interval;
+    if ( i >= pixmaps.count() ) i = pixmaps.count() - 1; /* roundings */
+    if ( i != current_frame )
+    {
+        current_frame = i;
+        currentPixmap = pixmaps.at( current_frame );
+        emit pixmapReady( *currentPixmap );
+    }
+}
+
diff --git a/modules/gui/qt4/util/animators.hpp b/modules/gui/qt4/util/animators.hpp
new file mode 100644
index 0000000..87cb160
--- /dev/null
+++ b/modules/gui/qt4/util/animators.hpp
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * animators.hpp: Object animators
+ ****************************************************************************
+ * Copyright (C) 2006-2014 the VideoLAN team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef ANIMATORS_HPP
+#define ANIMATORS_HPP
+
+#include <QObject>
+#include <QList>
+#include <QString>
+#include <QAbstractAnimation>
+class QWidget;
+class QPixmap;
+
+/** An animated pixmap
+     * Use this widget to display an animated icon based on a series of
+     * pixmaps. The pixmaps will be stored in memory and should be kept small.
+     * First, create the widget, add frames and then start playing. Looping
+     * is supported.
+     **/
+class PixmapAnimator : public QAbstractAnimation
+{
+    Q_OBJECT
+
+public:
+    PixmapAnimator( QWidget *parent, QList<QString> _frames );
+    void setFps( int _fps ) { fps = _fps; interval = 1000.0 / fps; }
+    virtual int duration() const { return interval * pixmaps.count(); }
+    virtual ~PixmapAnimator() { qDeleteAll( pixmaps ); }
+    QPixmap *getPixmap() { return currentPixmap; }
+protected:
+    virtual void updateCurrentTime ( int msecs );
+    QList<QPixmap *> pixmaps;
+    QPixmap *currentPixmap;
+    int fps;
+    int interval;
+    int lastframe_msecs;
+    int current_frame;
+signals:
+    void pixmapReady( const QPixmap & );
+};
+
+#endif // ANIMATORS_HPP
diff --git a/modules/gui/qt4/util/customwidgets.cpp b/modules/gui/qt4/util/customwidgets.cpp
index 847ea65..8b766ea 100644
--- a/modules/gui/qt4/util/customwidgets.cpp
+++ b/modules/gui/qt4/util/customwidgets.cpp
@@ -318,28 +318,6 @@ QString VLCKeyToString( unsigned val, bool locale )
     return r;
 }
 
-PixmapAnimator::PixmapAnimator( QWidget *parent, QList<QString> frames )
-    : QAbstractAnimation( parent ), current_frame( 0 )
-{
-    foreach( QString name, frames )
-        pixmaps.append( new QPixmap( name ) );
-    currentPixmap = pixmaps.at( 0 );
-    setFps( frames.count() ); /* default to 1 sec loop */
-    setLoopCount( -1 );
-}
-
-void PixmapAnimator::updateCurrentTime( int msecs )
-{
-    int i = msecs / interval;
-    if ( i >= pixmaps.count() ) i = pixmaps.count() - 1; /* roundings */
-    if ( i != current_frame )
-    {
-        current_frame = i;
-        currentPixmap = pixmaps.at( current_frame );
-        emit pixmapReady( *currentPixmap );
-    }
-}
-
 /* Animated Icon implementation */
 SpinningIcon::SpinningIcon( QWidget *parent ) : QLabel( parent )
 {
diff --git a/modules/gui/qt4/util/customwidgets.hpp b/modules/gui/qt4/util/customwidgets.hpp
index fd2cd93..e1e6c6d 100644
--- a/modules/gui/qt4/util/customwidgets.hpp
+++ b/modules/gui/qt4/util/customwidgets.hpp
@@ -34,11 +34,11 @@
 #include <QSpinBox>
 #include <QCheckBox>
 #include <QList>
-#include <QTimer>
 #include <QToolButton>
-#include <QAbstractAnimation>
 #include <QDial>
 
+#include "animators.hpp"
+
 class QPixmap;
 class QWidget;
 
@@ -112,34 +112,6 @@ protected:
     virtual int valueFromText( const QString& ) const { return -1; }
 };
 
-/** An animated pixmap
-     * Use this widget to display an animated icon based on a series of
-     * pixmaps. The pixmaps will be stored in memory and should be kept small.
-     * First, create the widget, add frames and then start playing. Looping
-     * is supported.
-     **/
-class PixmapAnimator : public QAbstractAnimation
-{
-    Q_OBJECT
-
-public:
-    PixmapAnimator( QWidget *parent, QList<QString> _frames );
-    void setFps( int _fps ) { fps = _fps; interval = 1000.0 / fps; };
-    virtual int duration() const { return interval * pixmaps.count(); };
-    virtual ~PixmapAnimator() { qDeleteAll( pixmaps ); };
-    QPixmap *getPixmap() { return currentPixmap; }
-protected:
-    virtual void updateCurrentTime ( int msecs );
-    QList<QPixmap *> pixmaps;
-    QPixmap *currentPixmap;
-    int fps;
-    int interval;
-    int lastframe_msecs;
-    int current_frame;
-signals:
-    void pixmapReady( const QPixmap & );
-};
-
 /** This spinning icon, to the colors of the VLC cone, will show
  * that there is some background activity running
  **/



More information about the vlc-commits mailing list