copy hash from collection tool

pull/53/head
Zlatin Balevsky 2020-11-02 01:16:25 +00:00
parent a082dc2dfd
commit a9ea0de16c
No known key found for this signature in database
GPG Key ID: A72832072D525E41
2 changed files with 17 additions and 0 deletions

View File

@ -6,6 +6,9 @@ import griffon.inject.MVCMember
import griffon.metadata.ArtifactProviderFor
import net.i2p.data.Base64
import java.awt.Toolkit
import java.awt.datatransfer.StringSelection
import javax.annotation.Nonnull
import com.muwire.core.SharedFile
@ -62,4 +65,17 @@ class CollectionsToolController {
params['text'] = DataUtil.readi18nString(Base64.decode(sf.getComment()))
mvcGroup.createMVCGroup("show-comment", params)
}
@ControllerAction
void copyHash() {
int row = view.selectedCollectionRow()
if (row < 0)
return
FileCollection collection = model.collections.get(row)
String b64 = Base64.encode(collection.getInfoHash().getRoot())
StringSelection selection = new StringSelection(b64)
def clipboard = Toolkit.getDefaultToolkit().getSystemClipboard()
clipboard.setContents(selection, null)
}
}

View File

@ -69,6 +69,7 @@ class CollectionsToolView {
}
panel(constraints : BorderLayout.SOUTH) {
button(text : trans("VIEW_COMMENT"), enabled : bind {model.viewCommentButtonEnabled}, viewCommentAction)
button(text : trans("COPY_HASH_TO_CLIPBOARD"), enabled : bind {model.deleteButtonEnabled}, copyHashAction)
button(text : trans("DELETE"), enabled : bind {model.deleteButtonEnabled}, deleteAction)
}
}