add options for search history
This commit is contained in:
@@ -10,6 +10,7 @@ import java.util.logging.Level
|
||||
|
||||
import javax.annotation.Nonnull
|
||||
import javax.swing.JFileChooser
|
||||
import javax.swing.JOptionPane
|
||||
|
||||
import com.muwire.core.Core
|
||||
import com.muwire.core.MuWireSettings
|
||||
@@ -20,12 +21,14 @@ class OptionsController {
|
||||
OptionsModel model
|
||||
@MVCMember @Nonnull
|
||||
OptionsView view
|
||||
|
||||
Core core
|
||||
MuWireSettings settings
|
||||
UISettings uiSettings
|
||||
|
||||
@ControllerAction
|
||||
void save() {
|
||||
String text
|
||||
Core core = application.context.get("core")
|
||||
MuWireSettings settings = application.context.get("muwire-settings")
|
||||
|
||||
def i2pProps = core.i2pOptions
|
||||
|
||||
@@ -141,7 +144,6 @@ class OptionsController {
|
||||
|
||||
// UI Setttings
|
||||
|
||||
UISettings uiSettings = application.context.get("ui-settings")
|
||||
text = view.lnfField.text
|
||||
model.lnf = text
|
||||
uiSettings.lnf = text
|
||||
@@ -169,16 +171,24 @@ class OptionsController {
|
||||
model.clearUploads = clearUploads
|
||||
uiSettings.clearUploads = clearUploads
|
||||
|
||||
boolean storeSearchHistory = view.storeSearchHistoryCheckbox.model.isSelected()
|
||||
model.storeSearchHistory = storeSearchHistory
|
||||
uiSettings.storeSearchHistory = storeSearchHistory
|
||||
|
||||
uiSettings.exitOnClose = model.exitOnClose
|
||||
if (model.closeDecisionMade)
|
||||
uiSettings.closeWarning = false
|
||||
|
||||
saveUISettings()
|
||||
|
||||
cancel()
|
||||
}
|
||||
|
||||
private void saveUISettings() {
|
||||
File uiSettingsFile = new File(core.home, "gui.properties")
|
||||
uiSettingsFile.withOutputStream {
|
||||
uiSettings.write(it)
|
||||
}
|
||||
|
||||
cancel()
|
||||
}
|
||||
|
||||
@ControllerAction
|
||||
@@ -231,4 +241,11 @@ class OptionsController {
|
||||
model.exitOnClose = false
|
||||
model.closeDecisionMade = true
|
||||
}
|
||||
|
||||
@ControllerAction
|
||||
void clearHistory() {
|
||||
uiSettings.searchHistory.clear()
|
||||
saveUISettings()
|
||||
JOptionPane.showMessageDialog(null, "Search history has been cleared")
|
||||
}
|
||||
}
|
@@ -21,6 +21,7 @@ class OptionsModel {
|
||||
@Observable int speedSmoothSeconds
|
||||
@Observable int totalUploadSlots
|
||||
@Observable int uploadSlotsPerUser
|
||||
@Observable boolean storeSearchHistory
|
||||
|
||||
// i2p options
|
||||
@Observable String inboundLength
|
||||
@@ -90,6 +91,7 @@ class OptionsModel {
|
||||
showSearchHashes = uiSettings.showSearchHashes
|
||||
clearUploads = uiSettings.clearUploads
|
||||
exitOnClose = uiSettings.exitOnClose
|
||||
storeSearchHistory = uiSettings.storeSearchHistory
|
||||
|
||||
if (core.router != null) {
|
||||
inBw = String.valueOf(settings.inBw)
|
||||
|
@@ -96,7 +96,13 @@ class MainFrameView {
|
||||
menuItem("Exit", actionPerformed : {closeApplication()})
|
||||
}
|
||||
menu (text : "Options") {
|
||||
menuItem("Configuration", actionPerformed : {mvcGroup.createMVCGroup("Options")})
|
||||
menuItem("Configuration", actionPerformed : {
|
||||
def params = [:]
|
||||
params['core'] = application.context.get("core")
|
||||
params['settings'] = params['core'].muOptions
|
||||
params['uiSettings'] = settings
|
||||
mvcGroup.createMVCGroup("Options", params)
|
||||
})
|
||||
}
|
||||
menu (text : "Status") {
|
||||
menuItem("MuWire", actionPerformed : {mvcGroup.createMVCGroup("mu-wire-status")})
|
||||
|
@@ -61,6 +61,7 @@ class OptionsView {
|
||||
def excludeLocalResultCheckbox
|
||||
def showSearchHashesCheckbox
|
||||
def clearUploadsCheckbox
|
||||
def storeSearchHistoryCheckbox
|
||||
|
||||
def inBwField
|
||||
def outBwField
|
||||
@@ -196,8 +197,17 @@ class OptionsView {
|
||||
constraints : gbc(gridx : 3, gridy : 2, anchor : GridBagConstraints.LINE_END))
|
||||
|
||||
}
|
||||
panel (border : titledBorder(title : "Other Settings", border : etchedBorder(), titlePosition : TitledBorder.TOP),
|
||||
panel (border : titledBorder(title : "Search Settings", border : etchedBorder(), titlePosition : TitledBorder.TOP),
|
||||
constraints : gbc(gridx : 0, gridy : 1, fill : GridBagConstraints.HORIZONTAL, weightx : 100)) {
|
||||
gridBagLayout()
|
||||
label(text : "Remember search history", constraints: gbc(gridx: 0, gridy:0, anchor : GridBagConstraints.LINE_START, weightx: 100))
|
||||
storeSearchHistoryCheckbox = checkBox(selected : bind {model.storeSearchHistory},
|
||||
constraints : gbc(gridx : 1, gridy:0, anchor : GridBagConstraints.LINE_END))
|
||||
button(text : "Clear history", constraints : gbc(gridx : 1, gridy : 1, anchor : GridBagConstraints.LINE_END), clearHistoryAction)
|
||||
|
||||
}
|
||||
panel (border : titledBorder(title : "Other Settings", border : etchedBorder(), titlePosition : TitledBorder.TOP),
|
||||
constraints : gbc(gridx : 0, gridy : 2, fill : GridBagConstraints.HORIZONTAL, weightx : 100)) {
|
||||
gridBagLayout()
|
||||
label(text : "Automatically clear cancelled downloads", constraints: gbc(gridx: 0, gridy:0, anchor : GridBagConstraints.LINE_START, weightx: 100))
|
||||
clearCancelledDownloadsCheckbox = checkBox(selected : bind {model.clearCancelledDownloads},
|
||||
@@ -221,7 +231,7 @@ class OptionsView {
|
||||
radioButton(text : "Exit", selected : bind {model.exitOnClose}, buttonGroup : closeBehaviorGroup, exitOnCloseAction)
|
||||
}
|
||||
}
|
||||
panel (constraints : gbc(gridx: 0, gridy: 2, weighty: 100))
|
||||
panel (constraints : gbc(gridx: 0, gridy: 3, weighty: 100))
|
||||
}
|
||||
bandwidth = builder.panel {
|
||||
gridBagLayout()
|
||||
|
Reference in New Issue
Block a user