From 69b4f0b54768ec1cd29e4d118cdd6cc818ecd039 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Sun, 7 Jul 2019 15:31:21 +0100 Subject: [PATCH] Add trust/distrust action from monitor window. Thanks Aegon --- .../com/muwire/gui/MainFrameController.groovy | 18 ++++++++++++++++++ .../views/com/muwire/gui/MainFrameView.groovy | 10 +++++++++- 2 files changed, 27 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 be9dd602..40fbe79f 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy @@ -165,6 +165,24 @@ class MainFrameController { core.eventBus.publish( new TrustEvent(persona : result.sender, level : TrustLevel.DISTRUSTED)) } + @ControllerAction + void trustPersonaFromSearch() { + int selected = builder.getVariable("searches-table").getSelectedRow() + if (selected < 0) + return + Persona p = model.searches[selected].originator + core.eventBus.publish( new TrustEvent(persona : p, level : TrustLevel.TRUSTED) ) + } + + @ControllerAction + void distrustPersonaFromSearch() { + int selected = builder.getVariable("searches-table").getSelectedRow() + if (selected < 0) + return + Persona p = model.searches[selected].originator + core.eventBus.publish( new TrustEvent(persona : p, level : TrustLevel.DISTRUSTED) ) + } + @ControllerAction void cancel() { def downloader = model.downloads[selectedDownload()].downloader diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index b936ccca..89e4b088 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -26,7 +26,6 @@ import com.muwire.core.MuWireSettings import com.muwire.core.download.Downloader import com.muwire.core.files.FileSharedEvent import com.muwire.core.trust.RemoteTrustList - import java.awt.BorderLayout import java.awt.CardLayout import java.awt.FlowLayout @@ -456,9 +455,18 @@ class MainFrameView { // searches table def searchesTable = builder.getVariable("searches-table") JPopupMenu searchTableMenu = new JPopupMenu() + JMenuItem copySearchToClipboard = new JMenuItem("Copy search to clipboard") copySearchToClipboard.addActionListener({mvcGroup.view.copySearchToClipboard(searchesTable)}) + JMenuItem trustSearcher = new JMenuItem("Trust searcher") + trustSearcher.addActionListener({mvcGroup.controller.trustPersonaFromSearch()}) + JMenuItem distrustSearcher = new JMenuItem("Distrust searcher") + distrustSearcher.addActionListener({mvcGroup.controller.distrustPersonaFromSearch()}) + searchTableMenu.add(copySearchToClipboard) + searchTableMenu.add(trustSearcher) + searchTableMenu.add(distrustSearcher) + searchesTable.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) {