123456789101112131415161718192021222324252627282930313233343536373839 |
- #include "thumbnailimageprovider.h"
- #include "FilePathConst.h"
- #include <QApplication>
- #include <QDebug>
- #include <QUrl>
- ThumbnailImageProvider::ThumbnailImageProvider()
- : QDeclarativeImageProvider(QDeclarativeImageProvider::Image)
- {
- }
- QImage ThumbnailImageProvider::requestImage(const QString & id, QSize * size, const QSize & requestedSize)
- {
- QString path(QUrl(getThumbnailDataRoot()).toLocalFile());
- if (id.startsWith("resourceid"))
- {
- path += "drm/data/";
- }
- path += id;
- qDebug() << "requestImage " << path;
- int width = 100;
- int height = 50;
- if (size)
- *size = QSize(width, height);
- QImage image(requestedSize.width() > 0 ? requestedSize.width() : width,
- requestedSize.height() > 0 ? requestedSize.height() : height,
- QImage::Format_ARGB32_Premultiplied);
- if (!image.load(path))
- {
- qDebug() << "load failed";
- }
- return image;
- }
|