mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-28 23:42:51 -05:00
Consolidate launcher (#615)
* refactor: Consolidate Icon Renderer for launcher Launcher icons are built on 2 places Spotlight and AppDrawer This duplicates the maintanance effort, every time something changes on one place must be replicated on the other. This commit consolidates the Icon renderer in a shared component. * refactor: Consolidate Launcher list and grid List and GRid builders were split in 2 components. this commit adds separate delegates to be reused as shared components.
This commit is contained in:
committed by
GitHub
parent
ed0b80008f
commit
3abee7f2f5
80
Widgets/AppIconRenderer.qml
Normal file
80
Widgets/AppIconRenderer.qml
Normal file
@@ -0,0 +1,80 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import Quickshell
|
||||
import Quickshell.Widgets
|
||||
import qs.Common
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
required property string iconValue
|
||||
required property int iconSize
|
||||
property string fallbackText: "A"
|
||||
property color iconColor: Theme.surfaceText
|
||||
property color fallbackBackgroundColor: Theme.surfaceLight
|
||||
property color fallbackTextColor: Theme.primary
|
||||
property real materialIconSizeAdjustment: Theme.spacingM
|
||||
property real unicodeIconScale: 0.7
|
||||
property real fallbackTextScale: 0.4
|
||||
property alias iconMargins: iconImg.anchors.margins
|
||||
property real fallbackLeftMargin: 0
|
||||
property real fallbackRightMargin: 0
|
||||
property real fallbackTopMargin: 0
|
||||
property real fallbackBottomMargin: 0
|
||||
|
||||
property bool isMaterial: iconValue.indexOf("material:") === 0
|
||||
property bool isUnicode: iconValue.indexOf("unicode:") === 0
|
||||
property string materialName: isMaterial ? iconValue.substring(9) : ""
|
||||
property string unicodeChar: isUnicode ? iconValue.substring(8) : ""
|
||||
|
||||
visible: iconValue !== undefined && iconValue !== ""
|
||||
|
||||
DankIcon {
|
||||
anchors.centerIn: parent
|
||||
name: root.materialName
|
||||
size: root.iconSize - root.materialIconSizeAdjustment
|
||||
color: root.iconColor
|
||||
visible: root.isMaterial
|
||||
}
|
||||
|
||||
StyledText {
|
||||
anchors.centerIn: parent
|
||||
text: root.unicodeChar
|
||||
font.pixelSize: root.iconSize * root.unicodeIconScale
|
||||
color: root.iconColor
|
||||
visible: root.isUnicode
|
||||
}
|
||||
|
||||
IconImage {
|
||||
id: iconImg
|
||||
|
||||
anchors.fill: parent
|
||||
source: root.isMaterial || root.isUnicode ? "" : Quickshell.iconPath(root.iconValue, true)
|
||||
smooth: true
|
||||
asynchronous: true
|
||||
visible: !root.isMaterial && !root.isUnicode && status === Image.Ready
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: fallbackRect
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: root.fallbackLeftMargin
|
||||
anchors.rightMargin: root.fallbackRightMargin
|
||||
anchors.topMargin: root.fallbackTopMargin
|
||||
anchors.bottomMargin: root.fallbackBottomMargin
|
||||
visible: !root.isMaterial && !root.isUnicode && iconImg.status !== Image.Ready
|
||||
color: root.fallbackBackgroundColor
|
||||
radius: Theme.cornerRadius
|
||||
border.width: 0
|
||||
border.color: Theme.primarySelected
|
||||
|
||||
StyledText {
|
||||
anchors.centerIn: parent
|
||||
text: root.fallbackText
|
||||
font.pixelSize: root.iconSize * root.fallbackTextScale
|
||||
color: root.fallbackTextColor
|
||||
font.weight: Font.Bold
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user