Provide default icon from system if problem seeking thumbnail.

This commit is contained in:
Tats
2016-02-15 20:05:36 -05:00
parent 3df0f7a955
commit 34abb070bb
2 changed files with 14 additions and 4 deletions
+12 -2
View File
@@ -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();