mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
launcher v2: support ScreenCopy in tiles
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import Quickshell.Wayland
|
||||
import qs.Common
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
Rectangle {
|
||||
@@ -21,9 +23,22 @@ Rectangle {
|
||||
border.width: isSelected ? 2 : 0
|
||||
border.color: Theme.primary
|
||||
|
||||
readonly property string toplevelId: item?.data?.toplevelId ?? ""
|
||||
readonly property var waylandToplevel: {
|
||||
if (!toplevelId || !item?.pluginId)
|
||||
return null;
|
||||
const pluginInstance = PluginService.pluginInstances[item.pluginId];
|
||||
if (!pluginInstance?.getToplevelById)
|
||||
return null;
|
||||
return pluginInstance.getToplevelById(toplevelId);
|
||||
}
|
||||
readonly property bool hasScreencopy: waylandToplevel !== null
|
||||
|
||||
readonly property string iconValue: {
|
||||
if (!item)
|
||||
return "";
|
||||
if (hasScreencopy)
|
||||
return "";
|
||||
var data = item.data;
|
||||
if (data?.imageUrl)
|
||||
return "image:" + data.imageUrl;
|
||||
@@ -63,12 +78,26 @@ Rectangle {
|
||||
color: Theme.surfaceContainerHigh
|
||||
clip: true
|
||||
|
||||
ScreencopyView {
|
||||
id: screencopyView
|
||||
anchors.fill: parent
|
||||
captureSource: root.waylandToplevel
|
||||
live: root.hasScreencopy
|
||||
visible: root.hasScreencopy
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: root.isHovered ? Theme.withAlpha(Theme.surfaceVariant, 0.2) : "transparent"
|
||||
}
|
||||
}
|
||||
|
||||
AppIconRenderer {
|
||||
anchors.fill: parent
|
||||
iconValue: root.iconValue
|
||||
iconSize: Math.min(parent.width, parent.height)
|
||||
fallbackText: (root.item?.name?.length > 0) ? root.item.name.charAt(0).toUpperCase() : "?"
|
||||
materialIconSizeAdjustment: iconSize * 0.3
|
||||
visible: !root.hasScreencopy
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -110,16 +139,26 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
Rectangle {
|
||||
id: attributionBadge
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.margins: Theme.spacingXS
|
||||
width: 40
|
||||
height: 16
|
||||
fillMode: Image.PreserveAspectFit
|
||||
source: root.item?.data?.attribution || ""
|
||||
visible: source !== ""
|
||||
opacity: 0.9
|
||||
width: root.hasScreencopy ? 28 : 40
|
||||
height: root.hasScreencopy ? 28 : 16
|
||||
radius: root.hasScreencopy ? 14 : 4
|
||||
color: root.hasScreencopy ? Theme.surfaceContainer : "transparent"
|
||||
visible: attributionImage.status === Image.Ready
|
||||
opacity: 0.95
|
||||
|
||||
Image {
|
||||
id: attributionImage
|
||||
anchors.fill: parent
|
||||
anchors.margins: root.hasScreencopy ? 4 : 0
|
||||
fillMode: Image.PreserveAspectFit
|
||||
source: root.item?.data?.attribution || ""
|
||||
mipmap: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user