simplify copy button

This commit is contained in:
end-4
2025-11-14 11:44:25 +01:00
parent 5bec659486
commit c16cff52b8
@@ -171,6 +171,9 @@ OverlayBackground {
onHeightChanged: root.scheduleCopylistUpdate(true) onHeightChanged: root.scheduleCopylistUpdate(true)
onContentHeightChanged: root.scheduleCopylistUpdate(true) onContentHeightChanged: root.scheduleCopylistUpdate(true)
onCursorPositionChanged: root.scheduleCopylistUpdate()
onSelectionStartChanged: root.scheduleCopylistUpdate()
onSelectionEndChanged: root.scheduleCopylistUpdate()
} }
Item { Item {
@@ -182,72 +185,33 @@ OverlayBackground {
model: ScriptModel { model: ScriptModel {
values: root.copyListEntries values: root.copyListEntries
} }
delegate: Item { delegate: RippleButton {
readonly property real lineHeight: Math.max(modelData.height, Appearance.font.pixelSize.normal + 6) id: copyButton
required property var modelData
readonly property real lineHeight: Math.min(Math.max(modelData.height, Appearance.font.pixelSize.normal + 6), 40)
readonly property real iconSizeLocal: Appearance.font.pixelSize.normal readonly property real iconSizeLocal: Appearance.font.pixelSize.normal
readonly property real hitPadding: 6 readonly property real hitPadding: 6
width: iconSizeLocal + hitPadding * 2 implicitHeight: lineHeight
height: lineHeight implicitWidth: lineHeight
buttonRadius: height / 2
y: modelData.y y: modelData.y
x: Math.max(stickypadInput.width - width - 8, 0) x: Math.max(stickypadInput.width - width - 16, 0)
z: 5 z: 5
Rectangle { onClicked: {
id: feedbackFlash Quickshell.clipboardText = copyButton.modelData.content;
anchors.centerIn: iconItem
width: iconSizeLocal + hitPadding
height: width
radius: width / 2
color: Appearance.colors.colLayer2
opacity: 0
z: 999
} }
MaterialSymbol { contentItem: Item {
id: iconItem
anchors.centerIn: parent anchors.centerIn: parent
text: "content_copy" MaterialSymbol {
iconSize: iconSizeLocal id: iconItem
color: Appearance.colors.colOnLayer1 anchors.centerIn: parent
opacity: mouseArea.containsMouse ? 1 : 0.85 text: "content_copy"
scale: 1 iconSize: copyButton.iconSizeLocal
Behavior on scale { color: Appearance.colors.colOnLayer1
NumberAnimation {
duration: 120
easing.type: Easing.OutQuad
}
} }
Behavior on opacity {
NumberAnimation {
duration: 120
}
}
}
MouseArea {
id: mouseArea
anchors.fill: parent
anchors.margins: hitPadding
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onPressed: iconItem.scale = 0.85
onReleased: iconItem.scale = 1
onCanceled: iconItem.scale = 1
onClicked: {
feedbackFlash.opacity = 0.6;
feedbackFade.restart();
Quickshell.clipboardText = modelData.content;
}
}
NumberAnimation {
id: feedbackFade
target: feedbackFlash
property: "opacity"
to: 0
duration: 200
easing.type: Easing.OutQuad
} }
} }
} }