Commit 0a2def83 authored by Ilia Ryabokon's avatar Ilia Ryabokon

Features widget preview downloader fix

parent 581e344b
...@@ -229,35 +229,45 @@ void UBFeaturesWidget::removeFromFavorite( const UBFeaturesMimeData * mimeData ) ...@@ -229,35 +229,45 @@ void UBFeaturesWidget::removeFromFavorite( const UBFeaturesMimeData * mimeData )
void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata ) void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata )
{ {
QString previewImageUrl; QString previewImageUrl = ":images/libpalette/notFound.png";
switch (static_cast<int>(UBFileSystemUtils::mimeTypeFromUrl(QUrl(metadata["Url"])))) QString widgetsUrl = metadata.value("Url", QString());
{ QString widgetsThumbsUrl = metadata.value("thumbnailUrl", QString());
case UBMimeType::RasterImage:
case UBMimeType::VectorImage:
{
previewImageUrl = ":images/libpalette/loading.png";
if (!imageGatherer) bool isLocal = QFileInfo(widgetsUrl).exists();
imageGatherer = new UBDownloadHttpFile(0, this);
connect(imageGatherer, SIGNAL(downloadFinished(int, bool, QUrl, QUrl, QString, QByteArray, QPointF, QSize, bool)), this, SLOT(onPreviewLoaded(int, bool, QUrl, QUrl, QString, QByteArray, QPointF, QSize, bool))); if (isLocal) {
QString strType = UBFileSystemUtils::mimeTypeFromFileName(widgetsUrl);
UBMimeType::Enum thumbType = UBFileSystemUtils::mimeTypeFromString(strType);
// We send here the request and store its reply in order to be able to cancel it if needed switch (static_cast<int>(thumbType)) {
imageGatherer->get(QUrl(metadata["Url"]), QPoint(0,0), QSize(), false); case UBMimeType::Audio:
} break; previewImageUrl = ":images/libpalette/soundIcon.svg";
case UBMimeType::Audio: break;
{
previewImageUrl = ":images/libpalette/soundIcon.svg"; case UBMimeType::Video:
}break;
case UBMimeType::Video:
{
previewImageUrl = ":images/libpalette/movieIcon.svg"; previewImageUrl = ":images/libpalette/movieIcon.svg";
}break; break;
case UBMimeType::Flash:
{ case UBMimeType::Flash:
previewImageUrl = ":images/libpalette/FlashIcon.svg"; previewImageUrl = ":images/libpalette/FlashIcon.svg";
}break; break;
case UBMimeType::RasterImage:
case UBMimeType::VectorImage:
previewImageUrl = widgetsUrl;
break;
}
} else if (!widgetsThumbsUrl.isNull()) {
previewImageUrl = ":/images/libpalette/loading.png";
if (!imageGatherer)
imageGatherer = new UBDownloadHttpFile(0, this);
connect(imageGatherer, SIGNAL(downloadFinished(int, bool, QUrl, QUrl, QString, QByteArray, QPointF, QSize, bool)), this, SLOT(onPreviewLoaded(int, bool, QUrl, QUrl, QString, QByteArray, QPointF, QSize, bool)));
// We send here the request and store its reply in order to be able to cancel it if needed
imageGatherer->get(QUrl(widgetsThumbsUrl), QPoint(0,0), QSize(), false);
} }
UBFeature feature( "/root", QImage(previewImageUrl), QString(), metadata["Url"], FEATURE_ITEM ); UBFeature feature( "/root", QImage(previewImageUrl), QString(), metadata["Url"], FEATURE_ITEM );
......
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