Moved restoreComboHistory closer to restoreComboIndex on utils.py
This commit is contained in:
parent
6047c6ecc0
commit
f27ad0c524
@ -338,28 +338,6 @@ def getTag(parent, deck, question, tags="user", **kwargs):
|
|||||||
return ret
|
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
|
# File handling
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
@ -520,6 +498,28 @@ def restoreComboIndex(widget, history, key):
|
|||||||
widget.setCurrentIndex(index)
|
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):
|
def saveSplitter(widget, key):
|
||||||
key += "Splitter"
|
key += "Splitter"
|
||||||
aqt.mw.pm.profile[key] = widget.saveState()
|
aqt.mw.pm.profile[key] = widget.saveState()
|
||||||
|
Loading…
Reference in New Issue
Block a user