mirror of
https://github.com/mapmapteam/mapmap.git
synced 2026-06-16 12:33:19 +02:00
Provide default icon from system if problem seeking thumbnail.
This commit is contained in:
@@ -149,12 +149,20 @@ bool Media::hasVideoSupport()
|
||||
|
||||
bool Media::setUri(const QString &uri)
|
||||
{
|
||||
static QFileIconProvider provider;
|
||||
|
||||
// Default (in case seeking and loading don't work).
|
||||
icon = provider.icon(QFileInfo(uri));
|
||||
|
||||
// Try to load movie.
|
||||
bool success = false;
|
||||
this->uri = uri;
|
||||
success = this->impl_->loadMovie(uri);
|
||||
success = impl_->loadMovie(uri);
|
||||
if (! success)
|
||||
{
|
||||
qDebug() << "Cannot load movie " << uri << "." << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Try to get thumbnail.
|
||||
const uint* bits = NULL;
|
||||
@@ -173,12 +181,14 @@ bool Media::setUri(const QString &uri)
|
||||
bits = (uint*)impl_->getBits();
|
||||
|
||||
// Copy bits into thumbnail QImage.
|
||||
thumbnail = QImage(getWidth(), getHeight(), QImage::Format_ARGB32);
|
||||
QImage thumbnail(getWidth(), getHeight(), QImage::Format_ARGB32);
|
||||
int i=0;
|
||||
for (int y=0; y<getHeight(); y++)
|
||||
for (int x=0; x<getWidth(); x++)
|
||||
thumbnail.setPixel(x, y, bits[i++]);
|
||||
|
||||
icon = QIcon(QPixmap::fromImage(thumbnail));
|
||||
|
||||
// Reset movie.
|
||||
impl_->resetMovie();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user