add ability to choose the incompletes location

This commit is contained in:
Zlatin Balevsky
2019-10-20 18:16:07 +01:00
parent d954387e41
commit ab323db62a
7 changed files with 44 additions and 5 deletions

View File

@@ -93,6 +93,9 @@ class OptionsController {
String downloadLocation = model.downloadLocation
settings.downloadLocation = new File(downloadLocation)
String incompleteLocation = model.incompleteLocation
settings.incompleteLocation = new File(incompleteLocation)
if (settings.embeddedRouter) {
text = view.inBwField.text
@@ -174,7 +177,18 @@ class OptionsController {
int rv = chooser.showOpenDialog(null)
if (rv == JFileChooser.APPROVE_OPTION)
model.downloadLocation = chooser.getSelectedFile().getAbsolutePath()
}
}
@ControllerAction
void incompleteLocation() {
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.incompleteLocation = chooser.getSelectedFile().getAbsolutePath()
}
@ControllerAction
void automaticFontAction() {

View File

@@ -45,9 +45,12 @@ class Ready extends AbstractLifecycleHandler {
props.load(it)
}
props = new MuWireSettings(props)
if (props.incompleteLocation == null)
props.incompleteLocation = new File(home, "incompletes")
} else {
log.info("creating new properties")
props = new MuWireSettings()
props.incompleteLocation = new File(home, "incompletes")
props.embeddedRouter = Boolean.parseBoolean(System.getProperties().getProperty("embeddedRouter"))
props.updateType = System.getProperty("updateType","jar")
def nickname

View File

@@ -15,6 +15,7 @@ class OptionsModel {
@Observable boolean shareDownloadedFiles
@Observable boolean shareHiddenFiles
@Observable String downloadLocation
@Observable String incompleteLocation
@Observable boolean searchComments
@Observable boolean browseFiles
@@ -56,6 +57,7 @@ class OptionsModel {
shareDownloadedFiles = settings.shareDownloadedFiles
shareHiddenFiles = settings.shareHiddenFiles
downloadLocation = settings.downloadLocation.getAbsolutePath()
incompleteLocation = settings.incompleteLocation.getAbsolutePath()
searchComments = settings.searchComments
browseFiles = settings.browseFiles

View File

@@ -100,6 +100,10 @@ class OptionsView {
label(text : "Save downloaded files to:", constraints: gbc(gridx:0, gridy:7))
button(text : "Choose", constraints : gbc(gridx : 1, gridy:7), downloadLocationAction)
label(text : bind {model.downloadLocation}, constraints: gbc(gridx:0, gridy:8, gridwidth:2))
label(text : "Store incomplete files in:", constraints: gbc(gridx:0, gridy:9))
button(text : "Choose", constraints : gbc(gridx : 1, gridy:9), incompleteLocationAction)
label(text : bind {model.incompleteLocation}, constraints: gbc(gridx:0, gridy:10, gridwidth:2))
}
i = builder.panel {