diff --git a/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy b/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy index 364bfa35..493b27c8 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy @@ -5,6 +5,7 @@ import griffon.core.controller.ControllerAction import griffon.inject.MVCMember import griffon.metadata.ArtifactProviderFor import javax.annotation.Nonnull +import javax.swing.JFileChooser import com.muwire.core.Core @@ -60,6 +61,9 @@ class OptionsController { boolean shareDownloaded = view.shareDownloadedCheckbox.model.isSelected() model.shareDownloadedFiles = shareDownloaded settings.shareDownloadedFiles = shareDownloaded + + String downloadLocation = model.downloadLocation + settings.downloadLocation = new File(downloadLocation) File settingsFile = new File(core.home, "MuWire.properties") settingsFile.withOutputStream { @@ -110,4 +114,15 @@ class OptionsController { view.d.setVisible(false) mvcGroup.destroy() } + + @ControllerAction + void downloadLocation() { + def chooser = new JFileChooser() + chooser.setFileHidingEnabled(false) + chooser.setDialogTitle("Select location for downloaded files") + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY) + int rv = chooser.showOpenDialog(null) + if (rv == JFileChooser.APPROVE_OPTION) + model.downloadLocation = chooser.getSelectedFile().getAbsolutePath() + } } \ No newline at end of file diff --git a/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy b/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy index f8e6281d..af993f86 100644 --- a/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy @@ -13,6 +13,7 @@ class OptionsModel { @Observable String updateCheckInterval @Observable boolean onlyTrusted @Observable boolean shareDownloadedFiles + @Observable String downloadLocation // i2p options @Observable String inboundLength @@ -35,6 +36,7 @@ class OptionsModel { updateCheckInterval = settings.updateCheckInterval onlyTrusted = !settings.allowUntrusted() shareDownloadedFiles = settings.shareDownloadedFiles + downloadLocation = settings.downloadLocation.getAbsolutePath() Core core = application.context.get("core") inboundLength = core.i2pOptions["inbound.length"] diff --git a/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy b/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy index 4ca319d9..a8a1bcd3 100644 --- a/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy @@ -68,6 +68,10 @@ class OptionsView { label(text : "Share downloaded files", constraints : gbc(gridx : 0, gridy:3)) shareDownloadedCheckbox = checkBox(selected : bind {model.shareDownloadedFiles}, constraints : gbc(gridx :1, gridy:3)) + + label(text : "Save downloaded files to:", constraints: gbc(gridx:0, gridy:4, gridwidth : 2)) + label(text : bind {model.downloadLocation}, constraints: gbc(gridx:0, gridy:5)) + button(text : "Choose", constraints : gbc(gridx : 1, gridy:5), downloadLocationAction) } i = builder.panel {