Files
qbz/crates/qbz-qt/qml/controls/QbzClipboard.qml
T
vicrodh 27be9a8143 feat(qt): a selectable text control and one shared clipboard carrier
QbzSelectableText is a Text-shaped label the user can select and copy: a
read-only TextEdit with mouse and keyboard selection, the right-click Copy
menu, and a rich-text link for fields that navigate; its `raised` arm keeps
a plain shadowed Text for hosts on the ambient field. QbzClipboard is the
off-screen TextEdit copy carrier CommandBlock, SandboxSettings and the
lyrics flyout each grew on their own, as one primitive. QbzScrollBar gains
`alwaysShown` for surfaces that must read as scrollable.

cc
2026-09-13 20:03:36 -06:00

35 lines
897 B
QML

// QbzClipboard — the one clipboard write QML offers without a C++ seam: an
// off-screen TextEdit's copy(). Mount one where a copy action lives and call
// `copy(text)`; the carrier is emptied right after, so the text never lingers
// in an invisible editor. One primitive instead of the carriers CommandBlock,
// SandboxSettings and the lyrics flyout each grew on their own.
import QtQuick
Item {
id: root
visible: false
width: 0
height: 0
/// Put `text` on the system clipboard. False for an empty text.
function copy(text) {
var s = String(text || "")
if (s === "")
return false
carrier.text = s
carrier.selectAll()
carrier.copy()
carrier.deselect()
carrier.text = ""
return true
}
TextEdit {
id: carrier
visible: false
width: 0
height: 0
}
}