mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Created the profiles.py session attribute for things to forgot
each time Anki restarted and set to only fill the find and replace dialogs when they were filled on the actual session.
This commit is contained in:
parent
4bc895f7df
commit
b23b404f68
2 changed files with 13 additions and 7 deletions
|
@ -76,6 +76,8 @@ class AnkiRestart(SystemExit):
|
||||||
|
|
||||||
class ProfileManager:
|
class ProfileManager:
|
||||||
def __init__(self, base=None):
|
def __init__(self, base=None):
|
||||||
|
## Settings which should be forgotten each Anki restart
|
||||||
|
self.session = {}
|
||||||
self.name = None
|
self.name = None
|
||||||
self.db = None
|
self.db = None
|
||||||
self.profile: Optional[Dict] = None
|
self.profile: Optional[Dict] = None
|
||||||
|
|
|
@ -484,15 +484,15 @@ def restoreIsChecked(widget, key: str):
|
||||||
def saveComboIndex(widget: QComboBox, key: str):
|
def saveComboIndex(widget: QComboBox, key: str):
|
||||||
textKey = key + "ComboActiveText"
|
textKey = key + "ComboActiveText"
|
||||||
indexKey = key + "ComboActiveIndex"
|
indexKey = key + "ComboActiveIndex"
|
||||||
aqt.mw.pm.profile[textKey] = widget.currentText()
|
aqt.mw.pm.session[textKey] = widget.currentText()
|
||||||
aqt.mw.pm.profile[indexKey] = widget.currentIndex()
|
aqt.mw.pm.session[indexKey] = widget.currentIndex()
|
||||||
|
|
||||||
|
|
||||||
def restoreComboIndex(widget: QComboBox, history: List[str], key: str):
|
def restoreComboIndex(widget: QComboBox, history: List[str], key: str):
|
||||||
textKey = key + "ComboActiveText"
|
textKey = key + "ComboActiveText"
|
||||||
indexKey = key + "ComboActiveIndex"
|
indexKey = key + "ComboActiveIndex"
|
||||||
text = aqt.mw.pm.profile.get(textKey)
|
text = aqt.mw.pm.session.get(textKey)
|
||||||
index = aqt.mw.pm.profile.get(indexKey)
|
index = aqt.mw.pm.session.get(indexKey)
|
||||||
if text is not None and index is not None:
|
if text is not None and index is not None:
|
||||||
if index < len(history) and history[index] == text:
|
if index < len(history) and history[index] == text:
|
||||||
widget.setCurrentIndex(index)
|
widget.setCurrentIndex(index)
|
||||||
|
@ -507,6 +507,7 @@ def saveComboHistory(comboBox: QComboBox, history: List[str], name: str):
|
||||||
history = history[:50]
|
history = history[:50]
|
||||||
comboBox.clear()
|
comboBox.clear()
|
||||||
comboBox.addItems(history)
|
comboBox.addItems(history)
|
||||||
|
aqt.mw.pm.session[name] = text_input
|
||||||
aqt.mw.pm.profile[name] = history
|
aqt.mw.pm.profile[name] = history
|
||||||
return text_input
|
return text_input
|
||||||
|
|
||||||
|
@ -514,9 +515,12 @@ def saveComboHistory(comboBox: QComboBox, history: List[str], name: str):
|
||||||
def restoreComboHistory(comboBox: QComboBox, name: str):
|
def restoreComboHistory(comboBox: QComboBox, name: str):
|
||||||
name += "BoxHistory"
|
name += "BoxHistory"
|
||||||
history = aqt.mw.pm.profile.get(name, [])
|
history = aqt.mw.pm.profile.get(name, [])
|
||||||
comboBox.addItems(history)
|
comboBox.addItems([""] + history)
|
||||||
comboBox.lineEdit().setText(history[0] if history else "")
|
if history:
|
||||||
comboBox.lineEdit().selectAll()
|
session_input = aqt.mw.pm.session.get(name)
|
||||||
|
if session_input and session_input == history[0]:
|
||||||
|
comboBox.lineEdit().setText(session_input)
|
||||||
|
comboBox.lineEdit().selectAll()
|
||||||
return history
|
return history
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue