Commit 0b8dfd30 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

[Icons KCM] Remove missing preview icons and indicate when theme has none

parent dee33b11
......@@ -525,7 +525,7 @@ QVariantList IconModule::previewIcons(const QString &themeName, int size, qreal
return QPixmap();
};
const QVariantList pixmaps{
QVariantList pixmaps{
getBestIcon({QStringLiteral("system-run"), QStringLiteral("exec")}),
getBestIcon({QStringLiteral("folder")}),
getBestIcon({QStringLiteral("document"), QStringLiteral("text-x-generic")}),
......@@ -548,6 +548,11 @@ QVariantList IconModule::previewIcons(const QString &themeName, int size, qreal
getBestIcon({QStringLiteral("folder-video"), QStringLiteral("folder-videos")})
};
// remove missing icons
pixmaps.erase(std::remove_if(pixmaps.begin(), pixmaps.end(), [](const QVariant &pixmapVariant) {
return pixmapVariant.value<QPixmap>().isNull();
}), pixmaps.end());
return pixmaps;
}
......
......@@ -65,7 +65,7 @@ KCM.GridViewKCM {
text: model.display
toolTip: model.description
thumbnailAvailable: true
thumbnailAvailable: typeof thumbFlow.previews === "undefined" || thumbFlow.previews.length > 0
thumbnail: MouseArea {
id: thumbArea
......@@ -98,7 +98,9 @@ KCM.GridViewKCM {
Flow {
id: thumbFlow
property var previews: []
// undefined is "didn't load preview yet"
// empty array is "no preview available"
property var previews
property int currentPage
readonly property int pageCount: Math.ceil(thumbRepeater.count / (thumbFlow.columns * thumbFlow.rows))
......
Supports Markdown
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