mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 13:32:50 -05:00
launcher v2: use AppIconRenderer from legacy launcha
This commit is contained in:
@@ -16,6 +16,25 @@ Rectangle {
|
|||||||
signal clicked
|
signal clicked
|
||||||
signal rightClicked(real mouseX, real mouseY)
|
signal rightClicked(real mouseX, real mouseY)
|
||||||
|
|
||||||
|
readonly property string iconValue: {
|
||||||
|
if (!item)
|
||||||
|
return "";
|
||||||
|
switch (item.iconType) {
|
||||||
|
case "material":
|
||||||
|
case "nerd":
|
||||||
|
return "material:" + (item.icon || "apps");
|
||||||
|
case "unicode":
|
||||||
|
return "unicode:" + (item.icon || "");
|
||||||
|
case "composite":
|
||||||
|
return item.iconFull || "";
|
||||||
|
case "image":
|
||||||
|
default:
|
||||||
|
return item.icon || "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly property int computedIconSize: Math.min(48, Math.max(32, width * 0.45))
|
||||||
|
|
||||||
radius: Theme.cornerRadius
|
radius: Theme.cornerRadius
|
||||||
color: isSelected ? Theme.primaryPressed : isHovered ? Theme.primaryPressed : "transparent"
|
color: isSelected ? Theme.primaryPressed : isHovered ? Theme.primaryPressed : "transparent"
|
||||||
|
|
||||||
@@ -25,88 +44,15 @@ Rectangle {
|
|||||||
spacing: Theme.spacingS
|
spacing: Theme.spacingS
|
||||||
width: parent.width - Theme.spacingM
|
width: parent.width - Theme.spacingM
|
||||||
|
|
||||||
Item {
|
AppIconRenderer {
|
||||||
width: iconSize
|
width: root.computedIconSize
|
||||||
height: iconSize
|
height: root.computedIconSize
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
iconValue: root.iconValue
|
||||||
property int iconSize: Math.min(48, Math.max(32, root.width * 0.45))
|
iconSize: root.computedIconSize
|
||||||
|
fallbackText: (root.item?.name?.length > 0) ? root.item.name.charAt(0).toUpperCase() : "?"
|
||||||
Image {
|
iconColor: root.isSelected ? Theme.primary : Theme.surfaceText
|
||||||
id: appIcon
|
materialIconSizeAdjustment: root.computedIconSize * 0.3
|
||||||
anchors.fill: parent
|
|
||||||
visible: root.item?.iconType === "image"
|
|
||||||
asynchronous: true
|
|
||||||
source: root.item?.iconType === "image" ? "image://icon/" + (root.item?.icon || "application-x-executable") : ""
|
|
||||||
sourceSize.width: parent.iconSize
|
|
||||||
sourceSize.height: parent.iconSize
|
|
||||||
fillMode: Image.PreserveAspectFit
|
|
||||||
cache: false
|
|
||||||
}
|
|
||||||
|
|
||||||
DankIcon {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
visible: root.item?.iconType === "material" || root.item?.iconType === "nerd"
|
|
||||||
name: root.item?.icon ?? "apps"
|
|
||||||
size: parent.iconSize * 0.7
|
|
||||||
color: root.isSelected ? Theme.primary : Theme.surfaceText
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
visible: root.item?.iconType === "unicode"
|
|
||||||
text: root.item?.icon ?? ""
|
|
||||||
font.pixelSize: parent.iconSize * 0.7
|
|
||||||
color: root.isSelected ? Theme.primary : Theme.surfaceText
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
anchors.fill: parent
|
|
||||||
visible: root.item?.iconType === "composite"
|
|
||||||
|
|
||||||
Image {
|
|
||||||
anchors.fill: parent
|
|
||||||
asynchronous: true
|
|
||||||
source: {
|
|
||||||
if (!root.item || root.item.iconType !== "composite")
|
|
||||||
return "";
|
|
||||||
var iconFull = root.item.iconFull || "";
|
|
||||||
if (iconFull.startsWith("svg+corner:")) {
|
|
||||||
var parts = iconFull.substring(11).split("|");
|
|
||||||
return parts[0] || "";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
sourceSize.width: parent.width
|
|
||||||
sourceSize.height: parent.height
|
|
||||||
fillMode: Image.PreserveAspectFit
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
width: 16
|
|
||||||
height: 16
|
|
||||||
radius: 8
|
|
||||||
color: Theme.surfaceContainer
|
|
||||||
|
|
||||||
DankIcon {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
name: {
|
|
||||||
if (!root.item || root.item.iconType !== "composite")
|
|
||||||
return "";
|
|
||||||
var iconFull = root.item.iconFull || "";
|
|
||||||
if (iconFull.startsWith("svg+corner:")) {
|
|
||||||
var parts = iconFull.substring(11).split("|");
|
|
||||||
return parts[1] || "";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
size: 12
|
|
||||||
color: root.isSelected ? Theme.primary : Theme.surfaceText
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
|
|||||||
@@ -16,6 +16,23 @@ Rectangle {
|
|||||||
signal clicked
|
signal clicked
|
||||||
signal rightClicked(real mouseX, real mouseY)
|
signal rightClicked(real mouseX, real mouseY)
|
||||||
|
|
||||||
|
readonly property string iconValue: {
|
||||||
|
if (!item)
|
||||||
|
return "";
|
||||||
|
switch (item.iconType) {
|
||||||
|
case "material":
|
||||||
|
case "nerd":
|
||||||
|
return "material:" + (item.icon || "apps");
|
||||||
|
case "unicode":
|
||||||
|
return "unicode:" + (item.icon || "");
|
||||||
|
case "composite":
|
||||||
|
return item.iconFull || "";
|
||||||
|
case "image":
|
||||||
|
default:
|
||||||
|
return item.icon || "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
width: parent?.width ?? 200
|
width: parent?.width ?? 200
|
||||||
height: 52
|
height: 52
|
||||||
color: isSelected ? Theme.primaryPressed : isHovered ? Theme.primaryPressed : "transparent"
|
color: isSelected ? Theme.primaryPressed : isHovered ? Theme.primaryPressed : "transparent"
|
||||||
@@ -27,86 +44,14 @@ Rectangle {
|
|||||||
anchors.rightMargin: Theme.spacingM
|
anchors.rightMargin: Theme.spacingM
|
||||||
spacing: Theme.spacingM
|
spacing: Theme.spacingM
|
||||||
|
|
||||||
Item {
|
AppIconRenderer {
|
||||||
width: 36
|
width: 36
|
||||||
height: 36
|
height: 36
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
iconValue: root.iconValue
|
||||||
Image {
|
iconSize: 36
|
||||||
id: appIcon
|
fallbackText: (root.item?.name?.length > 0) ? root.item.name.charAt(0).toUpperCase() : "?"
|
||||||
anchors.fill: parent
|
materialIconSizeAdjustment: 12
|
||||||
visible: root.item?.iconType === "image"
|
|
||||||
asynchronous: true
|
|
||||||
source: root.item?.iconType === "image" ? "image://icon/" + (root.item?.icon || "application-x-executable") : ""
|
|
||||||
sourceSize.width: 36
|
|
||||||
sourceSize.height: 36
|
|
||||||
fillMode: Image.PreserveAspectFit
|
|
||||||
cache: false
|
|
||||||
}
|
|
||||||
|
|
||||||
DankIcon {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
visible: root.item?.iconType === "material" || root.item?.iconType === "nerd"
|
|
||||||
name: root.item?.icon ?? "apps"
|
|
||||||
size: 24
|
|
||||||
color: Theme.surfaceText
|
|
||||||
}
|
|
||||||
|
|
||||||
StyledText {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
visible: root.item?.iconType === "unicode"
|
|
||||||
text: root.item?.icon ?? ""
|
|
||||||
font.pixelSize: 24
|
|
||||||
color: Theme.surfaceText
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
anchors.fill: parent
|
|
||||||
visible: root.item?.iconType === "composite"
|
|
||||||
|
|
||||||
Image {
|
|
||||||
anchors.fill: parent
|
|
||||||
asynchronous: true
|
|
||||||
source: {
|
|
||||||
if (!root.item || root.item.iconType !== "composite")
|
|
||||||
return "";
|
|
||||||
var iconFull = root.item.iconFull || "";
|
|
||||||
if (iconFull.startsWith("svg+corner:")) {
|
|
||||||
var parts = iconFull.substring(11).split("|");
|
|
||||||
return parts[0] || "";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
sourceSize.width: 36
|
|
||||||
sourceSize.height: 36
|
|
||||||
fillMode: Image.PreserveAspectFit
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
width: 16
|
|
||||||
height: 16
|
|
||||||
radius: 8
|
|
||||||
color: Theme.surfaceContainer
|
|
||||||
|
|
||||||
DankIcon {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
name: {
|
|
||||||
if (!root.item || root.item.iconType !== "composite")
|
|
||||||
return "";
|
|
||||||
var iconFull = root.item.iconFull || "";
|
|
||||||
if (iconFull.startsWith("svg+corner:")) {
|
|
||||||
var parts = iconFull.substring(11).split("|");
|
|
||||||
return parts[1] || "";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
size: 12
|
|
||||||
color: Theme.surfaceText
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
|
|||||||
@@ -35,7 +35,23 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
readonly property bool useImage: imageSource.length > 0
|
readonly property bool useImage: imageSource.length > 0
|
||||||
readonly property bool useIconProvider: !useImage && item?.iconType === "image"
|
|
||||||
|
readonly property string iconValue: {
|
||||||
|
if (!item || useImage)
|
||||||
|
return "";
|
||||||
|
switch (item.iconType) {
|
||||||
|
case "material":
|
||||||
|
case "nerd":
|
||||||
|
return "material:" + (item.icon || "image");
|
||||||
|
case "unicode":
|
||||||
|
return "unicode:" + (item.icon || "");
|
||||||
|
case "composite":
|
||||||
|
return item.iconFull || "";
|
||||||
|
case "image":
|
||||||
|
default:
|
||||||
|
return item.icon || "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function isImageFile(path) {
|
function isImageFile(path) {
|
||||||
if (!path)
|
if (!path)
|
||||||
@@ -62,32 +78,15 @@ Rectangle {
|
|||||||
maxCacheSize: 256
|
maxCacheSize: 256
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
AppIconRenderer {
|
||||||
id: iconImage
|
|
||||||
anchors.fill: parent
|
|
||||||
visible: root.useIconProvider
|
|
||||||
source: root.useIconProvider ? "image://icon/" + (root.item?.icon || "application-x-executable") : ""
|
|
||||||
sourceSize.width: parent.width * 2
|
|
||||||
sourceSize.height: parent.height * 2
|
|
||||||
fillMode: Image.PreserveAspectCrop
|
|
||||||
cache: false
|
|
||||||
asynchronous: true
|
|
||||||
}
|
|
||||||
|
|
||||||
DankIcon {
|
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
visible: !root.useImage && !root.useIconProvider && root.item?.iconType !== "unicode"
|
visible: !root.useImage
|
||||||
name: root.item?.icon ?? "image"
|
width: Math.min(parent.width, parent.height) * 0.6
|
||||||
size: Math.min(parent.width, parent.height) * 0.4
|
height: width
|
||||||
color: Theme.surfaceVariantText
|
iconValue: root.iconValue
|
||||||
}
|
iconSize: width
|
||||||
|
fallbackText: (root.item?.name?.length > 0) ? root.item.name.charAt(0).toUpperCase() : "?"
|
||||||
StyledText {
|
materialIconSizeAdjustment: width * 0.3
|
||||||
anchors.centerIn: parent
|
|
||||||
visible: root.item?.iconType === "unicode"
|
|
||||||
text: root.item?.icon ?? ""
|
|
||||||
font.pixelSize: Math.min(parent.width, parent.height) * 0.4
|
|
||||||
color: Theme.surfaceVariantText
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ Item {
|
|||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
source: root.iconPath
|
source: root.iconPath
|
||||||
smooth: true
|
backer.sourceSize: Qt.size(root.iconSize, root.iconSize)
|
||||||
|
mipmap: true
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
visible: !root.isMaterial && !root.isUnicode && !root.isSvg && !root.isSvgCorner && root.iconPath !== "" && status === Image.Ready
|
visible: !root.isMaterial && !root.isUnicode && !root.isSvg && !root.isSvgCorner && root.iconPath !== "" && status === Image.Ready
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user