Files
skygqts/overview/WindowCard.qml
T
2026-09-14 13:19:41 -04:00

77 lines
2.0 KiB
QML

import QtQuick
import Quickshell
import Quickshell.Wayland
Rectangle {
id: root
required property var theme
required property var toplevel
required property bool selected
required property bool live
signal activated()
signal hovered()
readonly property real aspect: {
const size = root.toplevel ? root.toplevel.size : null;
return (size && size[0] > 0 && size[1] > 0) ? size[0] / size[1] : (16 / 9);
}
width: Math.min(height * aspect, theme.cardHeight * 2.2)
height: theme.cardHeight
radius: theme.cornerRadius
color: theme.cardBg
border.width: selected ? 3 : 1
border.color: selected ? theme.selectedBorder : theme.cardBorder
clip: true
ScreencopyView {
id: preview
anchors.fill: parent
anchors.margins: 3
captureSource: root.live && root.toplevel ? root.toplevel.wayland : null
live: root.live
paintCursor: false
constraintSize: Qt.size(root.width - 6, root.height - 6)
}
Image {
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.margins: 6
width: 20
height: 20
source: Quickshell.iconPath(root.toplevel ? root.toplevel.appClass : "", "application-x-executable")
sourceSize: Qt.size(20, 20)
}
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
height: title.implicitHeight + 8
color: "#99000000"
Text {
id: title
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 30
anchors.rightMargin: 6
anchors.verticalCenter: parent.verticalCenter
elide: Text.ElideRight
color: theme.textColor
text: root.toplevel ? root.toplevel.title : ""
font.pixelSize: 12
}
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: root.activated()
onEntered: root.hovered()
}
}