From f8f7cfe8361afdc372e5b665c14c807f39e78cc8 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Fri, 14 Jun 2019 12:51:27 +0100 Subject: [PATCH] UI options panel --- .../com/muwire/gui/OptionsController.groovy | 28 +++++++++++++++++++ .../models/com/muwire/gui/OptionsModel.groovy | 14 ++++++++++ .../views/com/muwire/gui/OptionsView.groovy | 27 ++++++++++++++++-- .../groovy/com/muwire/gui/UISettings.groovy | 10 ++++++- gui/src/main/resources/trust.html | 7 +++++ 5 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 gui/src/main/resources/trust.html diff --git a/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy b/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy index a7d12c28..e7c13369 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/OptionsController.groovy @@ -66,6 +66,34 @@ class OptionsController { settings.write(it) } + // UI Setttings + + UISettings uiSettings = application.context.get("ui-settings") + text = view.lnfField.text + model.lnf = text + uiSettings.lnf = text + + text = view.fontField.text + model.font = text + uiSettings.font = text + + boolean showMonitor = view.monitorCheckbox.model.isSelected() + model.showMonitor = showMonitor + uiSettings.showMonitor = showMonitor + + boolean clearCancelledDownloads = view.clearCancelledDownloadsCheckbox.model.isSelected() + model.clearCancelledDownloads = clearCancelledDownloads + uiSettings.clearCancelledDownloads = clearCancelledDownloads + + boolean clearFinishedDownloads = view.clearFinishedDownloadsCheckbox.model.isSelected() + model.clearFinishedDownloads = clearFinishedDownloads + uiSettings.clearFinishedDownloads = clearFinishedDownloads + + File uiSettingsFile = new File(core.home, "gui.properties") + uiSettingsFile.withOutputStream { + uiSettings.write(it) + } + cancel() } diff --git a/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy b/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy index 5627d1ca..814efc19 100644 --- a/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy +++ b/gui/griffon-app/models/com/muwire/gui/OptionsModel.groovy @@ -20,6 +20,13 @@ class OptionsModel { @Observable String outboundLength @Observable String outboundQuantity + // gui options + @Observable boolean showMonitor + @Observable String lnf + @Observable String font + @Observable boolean clearCancelledDownloads + @Observable boolean clearFinishedDownloads + void mvcGroupInit(Map args) { MuWireSettings settings = application.context.get("muwire-settings") downloadRetryInterval = settings.downloadRetryInterval @@ -32,5 +39,12 @@ class OptionsModel { inboundQuantity = core.i2pOptions["inbound.quantity"] outboundLength = core.i2pOptions["outbound.length"] outboundQuantity = core.i2pOptions["outbound.quantity"] + + UISettings uiSettings = application.context.get("ui-settings") + showMonitor = uiSettings.showMonitor + lnf = uiSettings.lnf + font = uiSettings.font + clearCancelledDownloads = uiSettings.clearCancelledDownloads + clearFinishedDownloads = uiSettings.clearFinishedDownloads } } \ No newline at end of file diff --git a/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy b/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy index e0dc9a88..ae15dd13 100644 --- a/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/OptionsView.groovy @@ -25,6 +25,8 @@ class OptionsView { def d def p def i + def u + def retryField def updateField def allowUntrustedCheckbox @@ -35,6 +37,12 @@ class OptionsView { def outboundLengthField def outboundQuantityField + def lnfField + def monitorCheckbox + def fontField + def clearCancelledDownloadsCheckbox + def clearFinishedDownloadsCheckbox + def buttonsPanel def mainFrame @@ -72,6 +80,20 @@ class OptionsView { label(text : "Outbound Quantity", constraints : gbc(gridx:0, gridy:4)) outboundQuantityField = textField(text : bind {model.outboundQuantity}, columns : 2, constraints : gbc(gridx:1, gridy:4)) } + u = builder.panel { + gridBagLayout() + label(text : "Changing these settings requires a restart", constraints : gbc(gridx : 0, gridy : 0, gridwidth: 2)) + label(text : "Look And Feel", constraints : gbc(gridx: 0, gridy:1)) + lnfField = textField(text : bind {model.lnf}, columns : 4, constraints : gbc(gridx : 1, gridy : 1)) + label(text : "Font", constraints : gbc(gridx: 0, gridy : 2)) + fontField = textField(text : bind {model.font}, columns : 4, constraints : gbc(gridx : 1, gridy:2)) + label(text : "Show Monitor", constraints : gbc(gridx :0, gridy: 3)) + monitorCheckbox = checkBox(selected : bind {model.showMonitor}, constraints : gbc(gridx : 1, gridy: 3)) + label(text : "Clear Cancelled Downloads", constraints: gbc(gridx: 0, gridy:4)) + 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)) + } buttonsPanel = builder.panel { gridBagLayout() button(text : "Save", constraints : gbc(gridx : 1, gridy: 2), saveAction) @@ -81,8 +103,9 @@ class OptionsView { void mvcGroupInit(Map args) { def tabbedPane = new JTabbedPane() - tabbedPane.addTab("MuWire Options", p) - tabbedPane.addTab("I2P Options", i) + tabbedPane.addTab("MuWire", p) + tabbedPane.addTab("I2P", i) + tabbedPane.addTab("GUI", u) JPanel panel = new JPanel() panel.setLayout(new BorderLayout()) diff --git a/gui/src/main/groovy/com/muwire/gui/UISettings.groovy b/gui/src/main/groovy/com/muwire/gui/UISettings.groovy index 514ba193..c539ec5e 100644 --- a/gui/src/main/groovy/com/muwire/gui/UISettings.groovy +++ b/gui/src/main/groovy/com/muwire/gui/UISettings.groovy @@ -5,19 +5,27 @@ class UISettings { String lnf boolean showMonitor String font + boolean clearCancelledDownloads + boolean clearFinishedDownloads UISettings(Properties props) { lnf = props.getProperty("lnf", "system") showMonitor = Boolean.parseBoolean(props.getProperty("showMonitor", "true")) font = props.getProperty("font",null) + clearCancelledDownloads = Boolean.parseBoolean(props.getProperty("clearCancelledDownloads","false")) + clearFinishedDownloads = Boolean.parseBoolean(props.getProperty("clearFinishedDownloads","false")) } void write(OutputStream out) throws IOException { Properties props = new Properties() props.setProperty("lnf", lnf) - props.setProperty("showMonitor", showMonitor) + props.setProperty("showMonitor", String.valueOf(showMonitor)) + props.setProperty("clearCancelledDownloads", String.valueOf(clearCancelledDownloads)) + props.setProperty("clearFinishedDownloads", String.valueOf(clearFinishedDownloads)) if (font != null) props.setProperty("font", font) + + props.store(out, "UI Properties") } } diff --git a/gui/src/main/resources/trust.html b/gui/src/main/resources/trust.html new file mode 100644 index 00000000..d72ee6ba --- /dev/null +++ b/gui/src/main/resources/trust.html @@ -0,0 +1,7 @@ + +Some html goes here +
    +
  • 1
  • +
  • 2
  • +
+