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
This commit is contained in:
parent
3a8fa8abd1
commit
2c29fcc0b6
1 changed files with 42 additions and 8 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue