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,22 +32,14 @@ class OptionsController {
def i2pProps = core.i2pOptions
text = view.inboundLengthField.text
model.inboundLength = text
i2pProps["inbound.length"] = text
text = view.inboundQuantityField.text
model.inboundQuantity = text
i2pProps["inbound.quantity"] = text
text = view.outboundQuantityField.text
model.outboundQuantity = text
i2pProps["outbound.quantity"] = text
text = view.outboundLengthField.text
model.outboundLength = text
i2pProps["outbound.length"] = text
int tunnelLength = view.tunnelLengthSlider.value
i2pProps["inbound.length"] = String.valueOf(tunnelLength)
i2pProps["outbound.length"] = String.valueOf(tunnelLength)
int tunnelQuantity = view.tunnelQuantitySlider.value
i2pProps["inbound.quantity"] = String.valueOf(tunnelQuantity)
i2pProps["outbound.quantity"] = String.valueOf(tunnelQuantity)
if (settings.embeddedRouter) {
text = view.i2pNTCPPortField.text
model.i2pNTCPPort = text

View File

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

View File

@ -6,7 +6,9 @@ import griffon.metadata.ArtifactProviderFor
import groovy.swing.factory.TitledBorderFactory
import javax.swing.JDialog
import javax.swing.JLabel
import javax.swing.JPanel
import javax.swing.JSlider
import javax.swing.JTabbedPane
import javax.swing.SwingConstants
import javax.swing.border.TitledBorder
@ -48,10 +50,8 @@ class OptionsView {
def totalUploadSlotsField
def uploadSlotsPerUserField
def inboundLengthField
def inboundQuantityField
def outboundLengthField
def outboundQuantityField
def tunnelLengthSlider
def tunnelQuantitySlider
def i2pUDPPortField
def i2pNTCPPortField
@ -168,19 +168,24 @@ class OptionsView {
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,
constraints : gbc(gridx: 0, gridy: 1, fill : GridBagConstraints.HORIZONTAL, weightx : 100))) {
gridBagLayout()
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,
anchor : GridBagConstraints.LINE_END))
label(text : "Inbound quantity", constraints : gbc(gridx:0, gridy:1, anchor : GridBagConstraints.LINE_START, weightx : 100))
inboundQuantityField = textField(text : bind {model.inboundQuantity}, columns : 2, constraints : gbc(gridx:1, gridy:1,
anchor : GridBagConstraints.LINE_END))
label(text : "Outbound length", constraints : gbc(gridx:0, gridy:2, anchor : GridBagConstraints.LINE_START, weightx : 100))
outboundLengthField = textField(text : bind {model.outboundLength}, columns : 2, constraints : gbc(gridx:1, gridy:2,
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,
anchor : GridBagConstraints.LINE_END))
gridLayout(rows:4, cols:1)
label(text : "Speed vs Anonymity")
def lengthTable = new Hashtable()
lengthTable.put(1, new JLabel("Max Speed"))
lengthTable.put(3, new JLabel("Max Anonymity"))
tunnelLengthSlider = slider(minimum : 1, maximum : 3, value : bind {model.tunnelLength},
majorTickSpacing : 1, snapToTicks: true, paintTicks: true, labelTable : lengthTable,
paintLabels : true)
label(text: "Reliability vs Resource Usage")
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")