From 06cedb4f410318f4493adebed02d1e4cd8dd3e6b Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Fri, 29 Nov 2019 02:19:47 +0000 Subject: [PATCH] add buttons to copy short and full nickname to clipboard --- .../com/muwire/gui/MainFrameController.groovy | 18 ++++++++++++++++++ .../views/com/muwire/gui/MainFrameView.groovy | 6 +++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy index cb28df50..bfa188df 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy @@ -14,6 +14,8 @@ import net.i2p.data.Signature import net.i2p.data.SigningPrivateKey import java.awt.Desktop +import java.awt.Toolkit +import java.awt.datatransfer.StringSelection import java.awt.event.ActionEvent import java.nio.charset.StandardCharsets @@ -485,6 +487,22 @@ class MainFrameController { startChat(p) } + @ControllerAction + void copyShort() { + copy(model.core.me.getHumanReadableName()) + } + + @ControllerAction + void copyFull() { + copy(model.core.me.toBase64()) + } + + private void copy(String s) { + StringSelection selection = new StringSelection(s) + def clipboard = Toolkit.getDefaultToolkit().getSystemClipboard() + clipboard.setContents(selection, null) + } + void startChat(Persona p) { if (!mvcGroup.getChildrenGroups().containsKey(p.getHumanReadableName())) { def params = [:] diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index b5808229..9783fb8a 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -499,7 +499,11 @@ class MainFrameView { } panel (border: etchedBorder(), constraints : BorderLayout.SOUTH) { borderLayout() - label(text : bind {model.me}, constraints: BorderLayout.CENTER) + panel (constraints : BorderLayout.WEST) { + label(text : bind {model.me}) + button(text : "Copy Short", copyShortAction) + button(text : "Copy Full", copyFullAction) + } panel (constraints : BorderLayout.EAST) { label("Connections:") label(text : bind {model.connections})