Add back history view cover photos
This commit is contained in:
11 files changed
+476
-28
No files matched your search
@@ -0,0 +1,28 @@
|
||||
#include "FileIconProvider.h"
|
||||
#include <QFileIconProvider>
|
||||
#include <QFileInfo>
|
||||
#include <QIcon>
|
||||
|
||||
FileIconProvider::FileIconProvider()
|
||||
: QQuickImageProvider(QQuickImageProvider::Image)
|
||||
{}
|
||||
|
||||
QImage FileIconProvider::requestImage(const QString &id, QSize *size,
|
||||
const QSize &requestedSize)
|
||||
{
|
||||
// QML strips the leading slash from the URL path component, so restore it on Unix.
|
||||
QString filePath = id.startsWith(QLatin1Char('/')) ? id : QLatin1Char('/') + id;
|
||||
|
||||
QFileIconProvider iconProvider;
|
||||
QIcon icon = iconProvider.icon(QFileInfo(filePath));
|
||||
if (icon.isNull())
|
||||
icon = iconProvider.icon(QFileIconProvider::File);
|
||||
|
||||
QSize target = (requestedSize.width() > 0 && requestedSize.height() > 0)
|
||||
? requestedSize : QSize(60, 80);
|
||||
|
||||
QImage image = icon.pixmap(target).toImage();
|
||||
if (size)
|
||||
*size = image.size();
|
||||
return image;
|
||||
}
|
||||
Reference in new issue
Block a user