Moved restoreComboHistory closer to restoreComboIndex on utils.py

This commit is contained in:
evandrocoan 2020-05-31 17:30:14 -03:00
parent 6047c6ecc0
commit f27ad0c524

View File

@ -338,28 +338,6 @@ def getTag(parent, deck, question, tags="user", **kwargs):
return ret
def restoreComboHistory(comboBox, name):
name += "BoxHistory"
history = aqt.mw.pm.profile.get(name, [])
comboBox.addItems(history)
comboBox.lineEdit().setText(history[0] if history else "")
comboBox.lineEdit().selectAll()
return history
def saveComboHistory(comboBox, history, name):
name += "BoxHistory"
text_input = comboBox.lineEdit().text()
if text_input in history:
history.remove(text_input)
history.insert(0, text_input)
history = history[:50]
comboBox.clear()
comboBox.addItems(history)
aqt.mw.pm.profile[name] = history
return text_input
# File handling
######################################################################
@ -520,6 +498,28 @@ def restoreComboIndex(widget, history, key):
widget.setCurrentIndex(index)
def restoreComboHistory(comboBox, name):
name += "BoxHistory"
history = aqt.mw.pm.profile.get(name, [])
comboBox.addItems(history)
comboBox.lineEdit().setText(history[0] if history else "")
comboBox.lineEdit().selectAll()
return history
def saveComboHistory(comboBox, history, name):
name += "BoxHistory"
text_input = comboBox.lineEdit().text()
if text_input in history:
history.remove(text_input)
history.insert(0, text_input)
history = history[:50]
comboBox.clear()
comboBox.addItems(history)
aqt.mw.pm.profile[name] = history
return text_input
def saveSplitter(widget, key):
key += "Splitter"
aqt.mw.pm.profile[key] = widget.saveState()