From 78271a3738eb05dc7594868131c13eec6e2e0f78 Mon Sep 17 00:00:00 2001 From: James Graham Date: Mon, 4 Mar 2024 20:09:22 +0000 Subject: [PATCH] Add highlight and copy button to code component --- src/qml/CodeComponent.qml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/qml/CodeComponent.qml b/src/qml/CodeComponent.qml index b5850bd28..2554670b1 100644 --- a/src/qml/CodeComponent.qml +++ b/src/qml/CodeComponent.qml @@ -108,8 +108,32 @@ QQC2.Control { } } + QQC2.Button { + anchors { + top: parent.top + topMargin: Kirigami.Units.smallSpacing + right: parent.right + rightMargin: Kirigami.Units.smallSpacing + } + visible: root.hovered + icon.name: "edit-copy" + text: i18n("Copy to clipboard") + display: QQC2.AbstractButton.IconOnly + + onClicked: Clipboard.saveText(root.display); + + QQC2.ToolTip.text: text + QQC2.ToolTip.visible: hovered + QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay + } + background: Rectangle { color: Kirigami.Theme.backgroundColor radius: Kirigami.Units.smallSpacing + border { + width: root.hovered ? 1 : 0 + color: Kirigami.Theme.highlightColor + } + } }