diff --git a/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy b/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy index e7c13369..2a85a853 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy @@ -89,6 +89,10 @@ class OptionsController { model.clearFinishedDownloads = clearFinishedDownloads uiSettings.clearFinishedDownloads = clearFinishedDownloads + boolean excludeLocalResult = view.excludeLocalResultCheckbox.model.isSelected() + model.excludeLocalResult = excludeLocalResult + uiSettings.excludeLocalResult = excludeLocalResult + File uiSettingsFile = new File(core.home, "gui.properties") uiSettingsFile.withOutputStream { uiSettings.write(it) diff --git a/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy b/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy index 814efc19..f9a55bc5 100644 --- a/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy @@ -26,6 +26,7 @@ class OptionsModel { @Observable String font @Observable boolean clearCancelledDownloads @Observable boolean clearFinishedDownloads + @Observable boolean excludeLocalResult void mvcGroupInit(Map args) { MuWireSettings settings = application.context.get("muwire-settings") @@ -46,5 +47,6 @@ class OptionsModel { font = uiSettings.font clearCancelledDownloads = uiSettings.clearCancelledDownloads clearFinishedDownloads = uiSettings.clearFinishedDownloads + excludeLocalResult = uiSettings.excludeLocalResult } } \ No newline at end of file diff --git a/gui/griffon-app/models/com/muwire/gui/SearchTabModel.groovy b/gui/griffon-app/models/com/muwire/gui/SearchTabModel.groovy index 7c274f06..06e1edef 100644 --- a/gui/griffon-app/models/com/muwire/gui/SearchTabModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/SearchTabModel.groovy @@ -19,6 +19,7 @@ class SearchTabModel { FactoryBuilderSupport builder Core core + UISettings uiSettings String uuid def results = [] def hashBucket = [:] @@ -26,6 +27,7 @@ class SearchTabModel { void mvcGroupInit(Map args) { core = mvcGroup.parentGroup.model.core + uiSettings = application.context.get("ui-settings") mvcGroup.parentGroup.model.results[UUID.fromString(uuid)] = mvcGroup } @@ -34,6 +36,9 @@ class SearchTabModel { } void handleResult(UIResultEvent e) { + if (uiSettings.excludeLocalResult && + e.sender == core.me) + return runInsideUIAsync { def bucket = hashBucket.get(e.infohash) if (bucket == null) { diff --git a/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy b/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy index ae15dd13..61e89cd4 100644 --- a/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy @@ -42,6 +42,7 @@ class OptionsView { def fontField def clearCancelledDownloadsCheckbox def clearFinishedDownloadsCheckbox + def excludeLocalResultCheckbox def buttonsPanel @@ -93,6 +94,8 @@ class OptionsView { clearCancelledDownloadsCheckbox = checkBox(selected : bind {model.clearCancelledDownloads}, constraints : gbc(gridx : 1, gridy:4)) label(text : "Clear Finished Downloads", constraints: gbc(gridx: 0, gridy:5)) clearFinishedDownloadsCheckbox = checkBox(selected : bind {model.clearFinishedDownloads}, constraints : gbc(gridx : 1, gridy:5)) + label(text : "Exclude Local Files From Results", constraints: gbc(gridx:0, gridy:6)) + excludeLocalResultCheckbox = checkBox(selected : bind {model.excludeLocalResult}, constraints : gbc(gridx: 1, gridy : 6)) } buttonsPanel = builder.panel { gridBagLayout() diff --git a/gui/src/main/groovy/com/muwire/gui/UISettings.groovy b/gui/src/main/groovy/com/muwire/gui/UISettings.groovy index c539ec5e..a19ea4cd 100644 --- a/gui/src/main/groovy/com/muwire/gui/UISettings.groovy +++ b/gui/src/main/groovy/com/muwire/gui/UISettings.groovy @@ -7,6 +7,7 @@ class UISettings { String font boolean clearCancelledDownloads boolean clearFinishedDownloads + boolean excludeLocalResult UISettings(Properties props) { lnf = props.getProperty("lnf", "system") @@ -14,6 +15,7 @@ class UISettings { font = props.getProperty("font",null) clearCancelledDownloads = Boolean.parseBoolean(props.getProperty("clearCancelledDownloads","false")) clearFinishedDownloads = Boolean.parseBoolean(props.getProperty("clearFinishedDownloads","false")) + excludeLocalResult = Boolean.parseBoolean(props.getProperty("excludeLocalResult","false")) } void write(OutputStream out) throws IOException { @@ -22,6 +24,7 @@ class UISettings { props.setProperty("showMonitor", String.valueOf(showMonitor)) props.setProperty("clearCancelledDownloads", String.valueOf(clearCancelledDownloads)) props.setProperty("clearFinishedDownloads", String.valueOf(clearFinishedDownloads)) + props.setProperty("excludeLocalResult", String.valueOf(excludeLocalResult)) if (font != null) props.setProperty("font", font)