QmlDesigner: Add default icons for sound, font, and shader assets
Also create proper icon sizes for hdpi screens for all assets. Change-Id: Ie082030c7fe4893f90c5a75162b509416b73e5d4 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
@@ -79,6 +79,11 @@ static const QStringList &supportedAudioSuffixes()
|
||||
return retList;
|
||||
}
|
||||
|
||||
static QPixmap defaultPixmapForType(const QString &type, const QSize &size)
|
||||
{
|
||||
return QPixmap(QStringLiteral(":/ItemLibrary/images/asset_%1_%2.png").arg(type).arg(size.width()));
|
||||
}
|
||||
|
||||
static QPixmap generateFontImage(const QFileInfo &info, const QSize &size)
|
||||
{
|
||||
static QHash<QString, QPixmap> fontImageCache;
|
||||
@@ -92,12 +97,12 @@ static QPixmap generateFontImage(const QFileInfo &info, const QSize &size)
|
||||
while (!done) {
|
||||
QRawFont font(file, pixelSize);
|
||||
if (!font.isValid())
|
||||
return pixmap;
|
||||
break;
|
||||
QGlyphRun gr;
|
||||
gr.setRawFont(font);
|
||||
QVector<quint32> indices = font.glyphIndexesForString("Abc");
|
||||
if (indices.isEmpty())
|
||||
return pixmap;
|
||||
break;
|
||||
const QVector<QPointF> advances = font.advancesForGlyphIndexes(indices);
|
||||
QVector<QPointF> positions;
|
||||
QPointF totalAdvance;
|
||||
@@ -110,7 +115,7 @@ static QPixmap generateFontImage(const QFileInfo &info, const QSize &size)
|
||||
gr.setPositions(positions);
|
||||
QRectF bounds = gr.boundingRect();
|
||||
if (bounds.width() <= 0 || bounds.height() <= 0)
|
||||
return pixmap;
|
||||
break;
|
||||
|
||||
bounds.moveCenter({size.width() / 2., size.height() / 2.});
|
||||
|
||||
@@ -132,6 +137,10 @@ static QPixmap generateFontImage(const QFileInfo &info, const QSize &size)
|
||||
painter.drawGlyphRun(bounds.bottomLeft(), gr);
|
||||
done = true;
|
||||
}
|
||||
|
||||
if (!done)
|
||||
pixmap = defaultPixmapForType("font", size);
|
||||
|
||||
fontImageCache[key] = pixmap;
|
||||
}
|
||||
return fontImageCache[key];
|
||||
@@ -163,6 +172,10 @@ public:
|
||||
pixmap.load(info.absoluteFilePath());
|
||||
else if (supportedFontSuffixes().contains(suffix))
|
||||
pixmap = generateFontImage(info, iconSize);
|
||||
else if (supportedAudioSuffixes().contains(suffix))
|
||||
pixmap = defaultPixmapForType("sound", iconSize);
|
||||
else if (supportedShaderSuffixes().contains(suffix))
|
||||
pixmap = defaultPixmapForType("shader", iconSize);
|
||||
|
||||
if (pixmap.isNull())
|
||||
return QFileIconProvider::icon(info);
|
||||
@@ -176,8 +189,13 @@ public:
|
||||
return icon;
|
||||
}
|
||||
|
||||
// Generated icon sizes should match ItemLibraryResourceView needed icon sizes
|
||||
QList<QSize> iconSizes = {{192, 192}, {128, 128}, {96, 96}, {48, 48}, {32, 32}};
|
||||
// Generated icon sizes should contain all ItemLibraryResourceView needed icon sizes, and their
|
||||
// x2 versions for HDPI sceens
|
||||
QList<QSize> iconSizes = {{384, 384}, {192, 192}, // Large
|
||||
{256, 256}, {128, 128}, // Drag
|
||||
{96, 96}, // Medium
|
||||
{48, 48}, // Small
|
||||
{64, 64}, {32, 32}}; // List
|
||||
|
||||
};
|
||||
|
||||
|
After Width: | Height: | Size: 238 B |
After Width: | Height: | Size: 287 B |
After Width: | Height: | Size: 339 B |
After Width: | Height: | Size: 190 B |
After Width: | Height: | Size: 755 B |
After Width: | Height: | Size: 193 B |
After Width: | Height: | Size: 203 B |
After Width: | Height: | Size: 220 B |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 499 B |
After Width: | Height: | Size: 6.6 KiB |
After Width: | Height: | Size: 773 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 3.5 KiB |
After Width: | Height: | Size: 640 B |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 895 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.7 KiB |
@@ -5,5 +5,29 @@
|
||||
<file>images/item-default-icon@2x.png</file>
|
||||
<file>images/item-3D_model-icon.png</file>
|
||||
<file>images/item-3D_model-icon@2x.png</file>
|
||||
<file>images/asset_font_32.png</file>
|
||||
<file>images/asset_font_48.png</file>
|
||||
<file>images/asset_font_64.png</file>
|
||||
<file>images/asset_font_96.png</file>
|
||||
<file>images/asset_font_128.png</file>
|
||||
<file>images/asset_font_192.png</file>
|
||||
<file>images/asset_font_256.png</file>
|
||||
<file>images/asset_font_384.png</file>
|
||||
<file>images/asset_shader_32.png</file>
|
||||
<file>images/asset_shader_48.png</file>
|
||||
<file>images/asset_shader_64.png</file>
|
||||
<file>images/asset_shader_96.png</file>
|
||||
<file>images/asset_shader_128.png</file>
|
||||
<file>images/asset_shader_192.png</file>
|
||||
<file>images/asset_shader_256.png</file>
|
||||
<file>images/asset_shader_384.png</file>
|
||||
<file>images/asset_sound_32.png</file>
|
||||
<file>images/asset_sound_48.png</file>
|
||||
<file>images/asset_sound_64.png</file>
|
||||
<file>images/asset_sound_96.png</file>
|
||||
<file>images/asset_sound_128.png</file>
|
||||
<file>images/asset_sound_192.png</file>
|
||||
<file>images/asset_sound_256.png</file>
|
||||
<file>images/asset_sound_384.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|