void VideoThumbnailer::slotCreateThumbnail(VideoData *videoData, const QSize &size) { m_media.setCurrentSource(videoData->playableUrl()); m_media.play(); m_thumbnailSize = size; int retcode = 0; for (int i = 0; i < 50; i++) { retcode = m_eventLoop.exec(); if (retcode == 0) { break; } kDebug() << "Seeking to " << (i * 3); m_media.seek(i * 3); } if (retcode) { kWarning() << "Unable to generate thumbnail for "; m_media.stop(); return; } m_media.stop(); emit thumbnailReady(); }
bool ThumbnailCache::event(QEvent *event) { if (event->type() == QEvent::User) { ThumbnailEvent *thumbnailEvent = static_cast<ThumbnailEvent *>(event); QMutexLocker locker(&mutex); if (Thumbnail *thumbnail = cache.object(thumbnailEvent->url)) { thumbnail->pixmap = QPixmap::fromImage(thumbnailEvent->image); locker.unlock(); emit thumbnailReady(); } return true; } else { return QThread::event(event); } }
//------------------------------------------------------------------------ // // ThumbnailLoadJob implementation // //------------------------------------------------------------------------ ThumbnailLoadJob::ThumbnailLoadJob(const KFileItemList& items, ThumbnailGroup::Enum group) : KIO::Job() , mState(STATE_NEXTTHUMB) , mThumbnailGroup(group) { LOG(this); // Make sure we have a place to store our thumbnails QString thumbnailDir = ThumbnailLoadJob::thumbnailBaseDir(mThumbnailGroup); KStandardDirs::makeDir(thumbnailDir, 0700); // Look for images and store the items in our todo list Q_ASSERT(!items.empty()); mItems = items; mCurrentItem = KFileItem(); connect(&mThumbnailThread, SIGNAL(done(QImage, QSize)), SLOT(thumbnailReady(QImage, QSize)), Qt::QueuedConnection); connect(&mThumbnailThread, SIGNAL(thumbnailReadyToBeCached(QString, QImage)), sThumbnailCache, SLOT(queueThumbnail(QString, QImage)), Qt::QueuedConnection); }
ThumbnailModel::ThumbnailModel(QAbstractGallery *gallery, QObject *parent) : QGalleryQueryModel(gallery, parent) { connect(&cache, SIGNAL(thumbnailReady()), this, SLOT(thumbnailLoaded())); }
void NewLoader::onThumbnailReady(int pos) { emit thumbnailReady(pos, cache->thumbnailAt(pos)); }