]> git.sesse.net Git - vlc/commitdiff
Qt: move animators code
authorFrancois Cartegnie <fcvlcdev@free.fr>
Sat, 8 Feb 2014 14:01:03 +0000 (15:01 +0100)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Sun, 9 Feb 2014 20:21:06 +0000 (21:21 +0100)
modules/gui/qt4/Makefile.am
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/util/animators.cpp [new file with mode: 0644]
modules/gui/qt4/util/animators.hpp [new file with mode: 0644]
modules/gui/qt4/util/customwidgets.cpp
modules/gui/qt4/util/customwidgets.hpp

index 82f55fbcb46ffb08c62823c73da74c67fc5c923b..fd588dd90623c55eb012410347430e7841ce2cdc 100644 (file)
@@ -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 \
index faac01b9a179706df40959d9de92874acb1a7236..954bda692c5341416c94bd698a33924c4b91f20a 100644 (file)
@@ -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 (file)
index 0000000..9bed3a6
--- /dev/null
@@ -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 (file)
index 0000000..87cb160
--- /dev/null
@@ -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
index 847ea65771f1cd417f092c399dac43e03ee79167..8b766ead8aa16e7d3555470acae6ea975838e799 100644 (file)
@@ -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 )
 {
index fd2cd937f8e18132b77fef19a5eb9779747571b2..e1e6c6d38f4c97b243b84fe316a0d11afa1b49a3 100644 (file)
 #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
  **/