mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-18 09:14:01 -04:00
plugins: stipe dupe plugin previews & add fallback support
This commit is contained in:
@@ -13,7 +13,8 @@ DCard {
|
||||
property bool installed: false
|
||||
property bool selected: false
|
||||
property string fallbackIcon: "extension"
|
||||
property string previewSource: PluginService.previewUrl(plugin)
|
||||
property string previewSource: PluginService.thumbUrl(plugin)
|
||||
property string previewFallback: PluginService.previewUrl(plugin)
|
||||
property var badges: PluginService.badgeModel(plugin)
|
||||
property bool allowUninstall: false
|
||||
property var palette: null
|
||||
@@ -50,12 +51,20 @@ DCard {
|
||||
|
||||
CachingImage {
|
||||
id: cardPreview
|
||||
|
||||
property bool useFallback: false
|
||||
|
||||
anchors.fill: parent
|
||||
imagePath: root.previewSource
|
||||
imagePath: useFallback ? root.previewFallback : root.previewSource
|
||||
maxCacheSize: 640
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
animate: false
|
||||
visible: status === Image.Ready
|
||||
onStatusChanged: {
|
||||
if (status !== Image.Error || useFallback || !root.previewFallback || root.previewFallback === root.previewSource)
|
||||
return;
|
||||
useFallback = true;
|
||||
}
|
||||
}
|
||||
|
||||
DIcon {
|
||||
|
||||
@@ -372,6 +372,7 @@ RegistryBrowserWindow {
|
||||
busy: !!root.pendingThemes[cardCell.modelData.id]
|
||||
fallbackIcon: "palette"
|
||||
previewSource: root.themePreviewUrl(cardCell.modelData)
|
||||
previewFallback: ""
|
||||
badges: root.themeBadges(cardCell.modelData)
|
||||
palette: root.themePalette(cardCell.modelData)
|
||||
allowUninstall: true
|
||||
|
||||
@@ -1294,6 +1294,17 @@ Singleton {
|
||||
return plugin.screenshot || "";
|
||||
}
|
||||
|
||||
// 16:10 screenshot-only render; the full preview card bakes in title text the card already shows
|
||||
function thumbUrl(plugin) {
|
||||
if (!plugin)
|
||||
return "";
|
||||
if (plugin.thumbUrl)
|
||||
return plugin.thumbUrl;
|
||||
if (plugin.id)
|
||||
return previewApiBase + plugin.id + "/thumb";
|
||||
return "";
|
||||
}
|
||||
|
||||
function heroUrl(plugin) {
|
||||
if (!plugin)
|
||||
return "";
|
||||
|
||||
Reference in New Issue
Block a user