From 2c29fcc0b64fb6b131151562afe63491196a3465 Mon Sep 17 00:00:00 2001 From: vybe Date: Sun, 17 May 2026 23:00:22 +0000 Subject: [PATCH] feat: add click-to-copy for peer hostname and IP (#6)\n\n- Use Process (copyProcess) instead of unimported Quickshell.execDetached\n- MouseArea on hostname and IP in peer list delegate\n- Toast confirmation on copy --- tailscalectl/TailscaleWidget.qml | 50 +++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/tailscalectl/TailscaleWidget.qml b/tailscalectl/TailscaleWidget.qml index 28cd499..da6b6ca 100644 --- a/tailscalectl/TailscaleWidget.qml +++ b/tailscalectl/TailscaleWidget.qml @@ -35,6 +35,10 @@ PluginComponent { } } + Process { + id: copyProcess + } + Process { id: statusCheck @@ -84,6 +88,12 @@ PluginComponent { toggleProcess.running = true } + function copyToClipboard(text) { + copyProcess.command = ["sh", "-c", "printf '%s' '" + text.replace(/'/g, "'\\''") + "' | wl-copy"] + copyProcess.running = true + ToastService.showInfo("tailscalectl", "Copied: " + text) + } + popoutContent: Component { PopoutComponent { headerText: "Tailscale" @@ -161,16 +171,40 @@ PluginComponent { spacing: Theme.spacingS anchors.verticalCenter: parent.verticalCenter - StyledText { - text: modelData.hostname - font.pixelSize: Theme.fontSizeSmall - color: modelData.online ? Theme.primary : Theme.surfaceVariantText + MouseArea { + cursorShape: Qt.PointingHandCursor + hoverEnabled: true + anchors.verticalCenter: parent.verticalCenter + width: peerHostnameText.implicitWidth + height: peerHostnameText.implicitHeight + onClicked: { + root.copyToClipboard(modelData.hostname) + } + + StyledText { + id: peerHostnameText + text: modelData.hostname + font.pixelSize: Theme.fontSizeSmall + color: modelData.online ? Theme.primary : Theme.surfaceVariantText + } } - StyledText { - text: modelData.ip - font.pixelSize: Theme.fontSizeSmall - color: Theme.surfaceVariantText + MouseArea { + cursorShape: Qt.PointingHandCursor + hoverEnabled: true + anchors.verticalCenter: parent.verticalCenter + width: peerIpText.implicitWidth + height: peerIpText.implicitHeight + onClicked: { + root.copyToClipboard(modelData.ip) + } + + StyledText { + id: peerIpText + text: modelData.ip + font.pixelSize: Theme.fontSizeSmall + color: Theme.surfaceVariantText + } } } }