use sliders instead of fields in I2P settings

pull/53/head
Zlatin Balevsky 2020-05-18 14:39:16 +01:00
parent ec41985d31
commit 017454c4b3
No known key found for this signature in database
GPG Key ID: A72832072D525E41
3 changed files with 34 additions and 41 deletions

View File

@ -32,21 +32,13 @@ class OptionsController {
def i2pProps = core.i2pOptions def i2pProps = core.i2pOptions
text = view.inboundLengthField.text int tunnelLength = view.tunnelLengthSlider.value
model.inboundLength = text i2pProps["inbound.length"] = String.valueOf(tunnelLength)
i2pProps["inbound.length"] = text i2pProps["outbound.length"] = String.valueOf(tunnelLength)
text = view.inboundQuantityField.text int tunnelQuantity = view.tunnelQuantitySlider.value
model.inboundQuantity = text i2pProps["inbound.quantity"] = String.valueOf(tunnelQuantity)
i2pProps["inbound.quantity"] = text i2pProps["outbound.quantity"] = String.valueOf(tunnelQuantity)
text = view.outboundQuantityField.text
model.outboundQuantity = text
i2pProps["outbound.quantity"] = text
text = view.outboundLengthField.text
model.outboundLength = text
i2pProps["outbound.length"] = text
if (settings.embeddedRouter) { if (settings.embeddedRouter) {
text = view.i2pNTCPPortField.text text = view.i2pNTCPPortField.text

View File

@ -25,10 +25,8 @@ class OptionsModel {
@Observable boolean storeSearchHistory @Observable boolean storeSearchHistory
// i2p options // i2p options
@Observable String inboundLength @Observable int tunnelLength
@Observable String inboundQuantity @Observable int tunnelQuantity
@Observable String outboundLength
@Observable String outboundQuantity
@Observable String i2pUDPPort @Observable String i2pUDPPort
@Observable String i2pNTCPPort @Observable String i2pNTCPPort
@ -90,10 +88,8 @@ class OptionsModel {
uploadSlotsPerUser = settings.uploadSlotsPerUser uploadSlotsPerUser = settings.uploadSlotsPerUser
Core core = application.context.get("core") Core core = application.context.get("core")
inboundLength = core.i2pOptions["inbound.length"] tunnelLength = Math.max(Integer.parseInt(core.i2pOptions["inbound.length"]), Integer.parseInt(core.i2pOptions['outbound.length']))
inboundQuantity = core.i2pOptions["inbound.quantity"] tunnelQuantity = Math.max(Integer.parseInt(core.i2pOptions["inbound.quantity"]), Integer.parseInt(core.i2pOptions['outbound.quantity']))
outboundLength = core.i2pOptions["outbound.length"]
outboundQuantity = core.i2pOptions["outbound.quantity"]
i2pUDPPort = core.i2pOptions["i2np.udp.port"] i2pUDPPort = core.i2pOptions["i2np.udp.port"]
i2pNTCPPort = core.i2pOptions["i2np.ntcp.port"] i2pNTCPPort = core.i2pOptions["i2np.ntcp.port"]

View File

@ -6,7 +6,9 @@ import griffon.metadata.ArtifactProviderFor
import groovy.swing.factory.TitledBorderFactory import groovy.swing.factory.TitledBorderFactory
import javax.swing.JDialog import javax.swing.JDialog
import javax.swing.JLabel
import javax.swing.JPanel import javax.swing.JPanel
import javax.swing.JSlider
import javax.swing.JTabbedPane import javax.swing.JTabbedPane
import javax.swing.SwingConstants import javax.swing.SwingConstants
import javax.swing.border.TitledBorder import javax.swing.border.TitledBorder
@ -48,10 +50,8 @@ class OptionsView {
def totalUploadSlotsField def totalUploadSlotsField
def uploadSlotsPerUserField def uploadSlotsPerUserField
def inboundLengthField def tunnelLengthSlider
def inboundQuantityField def tunnelQuantitySlider
def outboundLengthField
def outboundQuantityField
def i2pUDPPortField def i2pUDPPortField
def i2pNTCPPortField def i2pNTCPPortField
@ -168,19 +168,24 @@ class OptionsView {
label(text : "Changing any I2P settings requires a restart", constraints : gbc(gridx:0, gridy : 0)) label(text : "Changing any I2P settings requires a restart", constraints : gbc(gridx:0, gridy : 0))
panel (border : titledBorder(title : "Tunnel Settings", border : etchedBorder(), titlePosition: TitledBorder.TOP, panel (border : titledBorder(title : "Tunnel Settings", border : etchedBorder(), titlePosition: TitledBorder.TOP,
constraints : gbc(gridx: 0, gridy: 1, fill : GridBagConstraints.HORIZONTAL, weightx : 100))) { constraints : gbc(gridx: 0, gridy: 1, fill : GridBagConstraints.HORIZONTAL, weightx : 100))) {
gridBagLayout() gridLayout(rows:4, cols:1)
label(text : "Inbound length", constraints : gbc(gridx:0, gridy:0, anchor : GridBagConstraints.LINE_START, weightx : 100))
inboundLengthField = textField(text : bind {model.inboundLength}, columns : 2, constraints : gbc(gridx:1, gridy:0, label(text : "Speed vs Anonymity")
anchor : GridBagConstraints.LINE_END)) def lengthTable = new Hashtable()
label(text : "Inbound quantity", constraints : gbc(gridx:0, gridy:1, anchor : GridBagConstraints.LINE_START, weightx : 100)) lengthTable.put(1, new JLabel("Max Speed"))
inboundQuantityField = textField(text : bind {model.inboundQuantity}, columns : 2, constraints : gbc(gridx:1, gridy:1, lengthTable.put(3, new JLabel("Max Anonymity"))
anchor : GridBagConstraints.LINE_END)) tunnelLengthSlider = slider(minimum : 1, maximum : 3, value : bind {model.tunnelLength},
label(text : "Outbound length", constraints : gbc(gridx:0, gridy:2, anchor : GridBagConstraints.LINE_START, weightx : 100)) majorTickSpacing : 1, snapToTicks: true, paintTicks: true, labelTable : lengthTable,
outboundLengthField = textField(text : bind {model.outboundLength}, columns : 2, constraints : gbc(gridx:1, gridy:2, paintLabels : true)
anchor : GridBagConstraints.LINE_END))
label(text : "Outbound quantity", constraints : gbc(gridx:0, gridy:3, anchor : GridBagConstraints.LINE_START, weightx : 100))
outboundQuantityField = textField(text : bind {model.outboundQuantity}, columns : 2, constraints : gbc(gridx:1, gridy:3, label(text: "Reliability vs Resource Usage")
anchor : GridBagConstraints.LINE_END)) def quantityTable = new Hashtable()
quantityTable.put(1, new JLabel("Min Resources"))
quantityTable.put(6, new JLabel("Max Reliability"))
tunnelQuantitySlider = slider(minimum : 1, maximum : 6, value : bind {model.tunnelQuantity},
majorTickSpacing : 1, snapToTicks : true, paintTicks: true, labelTable : quantityTable,
paintLabels : true)
} }
Core core = application.context.get("core") Core core = application.context.get("core")