mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
Moved restoreComboHistory closer to restoreComboIndex on utils.py
This commit is contained in:
parent
6047c6ecc0
commit
f27ad0c524
1 changed files with 22 additions and 22 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue