Commit 0f1dbde6 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: move animators code

parent 29f4fe99
......@@ -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 \
......
......@@ -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 */
......
/*****************************************************************************
* 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 );
}
}
/*****************************************************************************
* 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
......@@ -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 )
{
......
......@@ -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
**/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment