nosignal-shell/modules/launcher/items/AppItem.qml
2026-04-11 21:24:16 +10:00

90 lines
2.4 KiB
QML

import QtQuick
import Quickshell
import Quickshell.Widgets
import qs.components
import qs.services
import Caelestia.Config
import qs.utils
import qs.modules.launcher.services
Item {
id: root
required property DesktopEntry modelData
required property DrawerVisibilities visibilities
implicitHeight: Tokens.sizes.launcher.itemHeight
anchors.left: parent?.left
anchors.right: parent?.right
StateLayer {
function onClicked(): void {
Apps.launch(root.modelData);
root.visibilities.launcher = false;
}
radius: Tokens.rounding.normal
}
Item {
anchors.fill: parent
anchors.leftMargin: Tokens.padding.larger
anchors.rightMargin: Tokens.padding.larger
anchors.margins: Tokens.padding.smaller
IconImage {
id: icon
asynchronous: true
source: Quickshell.iconPath(root.modelData?.icon, "image-missing")
implicitSize: parent.height * 0.8
anchors.verticalCenter: parent.verticalCenter
}
Item {
anchors.left: icon.right
anchors.leftMargin: Tokens.spacing.normal
anchors.verticalCenter: icon.verticalCenter
implicitWidth: parent.width - icon.width - favouriteIcon.width
implicitHeight: name.implicitHeight + comment.implicitHeight
StyledText {
id: name
text: root.modelData?.name ?? ""
font.pointSize: Tokens.font.size.normal
}
StyledText {
id: comment
text: (root.modelData?.comment || root.modelData?.genericName || root.modelData?.name) ?? ""
font.pointSize: Tokens.font.size.small
color: Colours.palette.m3outline
elide: Text.ElideRight
width: root.width - icon.width - favouriteIcon.width - Tokens.rounding.normal * 2
anchors.top: name.bottom
}
}
Loader {
id: favouriteIcon
asynchronous: true
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
active: root.modelData && Strings.testRegexList(Config.launcher.favouriteApps, root.modelData.id)
sourceComponent: MaterialIcon {
text: "favorite"
fill: 1
color: Colours.palette.m3primary
}
}
}
}