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 + } } } }