KVIrc
4.9.2
DeveloperAPIs
|
#include <KviAnimatedPixmap.h>
Signals | |
void | frameChanged () |
Public Member Functions | |
uint | activeFrameNumber () |
uint | framesCount () |
bool | isStarted () |
bool | isValid () |
KviAnimatedPixmap (QString fileName, int iWidth=0, int iHeight=0) | |
KviAnimatedPixmap (const KviAnimatedPixmap &source) | |
void | nextFrame (bool bEmitSignalAndScheduleNext) |
QPixmap * | pixmap () |
void | resize (QSize newSize, Qt::AspectRatioMode ratioMode) |
const QSize & | size () |
void | start () |
void | stop () |
virtual | ~KviAnimatedPixmap () |
Public Member Functions inherited from KviAnimatedPixmapInterface | |
virtual | ~KviAnimatedPixmapInterface () |
Protected Attributes | |
int | m_iStarted |
KviAnimatedPixmapCache::Data * | m_pFrameData |
QString | m_szFileName |
uint | m_uCurrentFrameNumber |
This class should not be here, because we already have QMovie with the same functionality.
But QMovie is really stupid, bacause: 1) It does not support infinitive animation. It relies on image metadata to determine loop count. So most of pics will be played only once.
2) It duplicates QPixmap while we calls currentFrame(), that's a very big overload for us.
3) If we try to scale QMovie by using built-in scale mechanism, it will manually scale each frame each time, we will call currentFrame(). So if we plan to play movie 10,100,1000 times, it will scale image 10,100,1000 times too:(
4) KviAnimatedPixmap uses internal cache mechanism with KviAnimatedPixmapCache class. It's managed inside KviAnimatedPixmap and KviAnimatedPixmapCache. No other actions needed to perform caching.
So... Here is my workaround. It's working in this way: You should create new pixmap with constructor KviAnimatedPixmap(QString fileName). It will automagically look at cache and use it, if possible.
KviAnimatedPixmap stores animation as a set of QPixmap's, and delays. when started (see start()) it emits frameChanged() events at the frame change.
You should use pixmap() methd to access the current frame.
This class owns all pixmaps. Do not store links to them.
KviAnimatedPixmap::KviAnimatedPixmap | ( | QString | fileName, |
int | iWidth = 0 , |
||
int | iHeight = 0 |
||
) |
References KviAnimatedPixmapCache::load(), and m_pFrameData.
|
virtual |
References KviAnimatedPixmapCache::free(), m_pFrameData, and KviAnimatedPixmapCache::notifyDelete().
KviAnimatedPixmap::KviAnimatedPixmap | ( | const KviAnimatedPixmap & | source | ) |
References m_pFrameData, and KviAnimatedPixmapCache::Data::refs.
|
inline |
|
signal |
Referenced by nextFrame().
|
inline |
|
inline |
|
inline |
|
virtual |
Implements KviAnimatedPixmapInterface.
References frameChanged(), m_iStarted, m_pFrameData, m_uCurrentFrameNumber, and KviAnimatedPixmapCache::scheduleFrameChange().
|
inline |
void KviAnimatedPixmap::resize | ( | QSize | newSize, |
Qt::AspectRatioMode | ratioMode | ||
) |
References m_pFrameData, KviAnimatedPixmapCache::resize(), and size().
Referenced by KviAvatar::forSize(), and KviAvatar::KviAvatar().
|
inline |
Referenced by KviAvatar::KviAvatar(), KviUserListEntry::recalcSize(), and resize().
void KviAnimatedPixmap::start | ( | ) |
References m_iStarted, m_pFrameData, m_uCurrentFrameNumber, and KviAnimatedPixmapCache::scheduleFrameChange().
Referenced by KviTextIcon::KviTextIcon(), KviTextIcon::setFilename(), and KviUserListEntry::updateAvatarData().
void KviAnimatedPixmap::stop | ( | ) |
References m_iStarted.
Referenced by KviTextIcon::KviTextIcon(), and KviTextIcon::setFilename().
|
protected |
Referenced by nextFrame(), start(), and stop().
|
protected |
Referenced by KviAnimatedPixmap(), nextFrame(), resize(), start(), and ~KviAnimatedPixmap().
|
protected |
|
protected |
Referenced by nextFrame(), and start().