mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00
Added some type checking to utils.py QComboBox restore functions
# Conflicts: # qt/aqt/utils.py
This commit is contained in:
parent
f27ad0c524
commit
bf55ebbd8a
1 changed files with 11 additions and 11 deletions
|
@ -8,7 +8,7 @@ import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from typing import TYPE_CHECKING, Any, Optional, Union
|
from typing import TYPE_CHECKING, Any, List, Optional, Union
|
||||||
|
|
||||||
import anki
|
import anki
|
||||||
import aqt
|
import aqt
|
||||||
|
@ -409,7 +409,7 @@ def getSaveFile(parent, title, dir_description, key, ext, fname=None):
|
||||||
return file
|
return file
|
||||||
|
|
||||||
|
|
||||||
def saveGeom(widget, key):
|
def saveGeom(widget, key: str):
|
||||||
key += "Geom"
|
key += "Geom"
|
||||||
if isMac and widget.windowState() & Qt.WindowFullScreen:
|
if isMac and widget.windowState() & Qt.WindowFullScreen:
|
||||||
geom = None
|
geom = None
|
||||||
|
@ -418,7 +418,7 @@ def saveGeom(widget, key):
|
||||||
aqt.mw.pm.profile[key] = geom
|
aqt.mw.pm.profile[key] = geom
|
||||||
|
|
||||||
|
|
||||||
def restoreGeom(widget, key, offset=None, adjustSize=False):
|
def restoreGeom(widget, key: str, offset=None, adjustSize=False):
|
||||||
key += "Geom"
|
key += "Geom"
|
||||||
if aqt.mw.pm.profile.get(key):
|
if aqt.mw.pm.profile.get(key):
|
||||||
widget.restoreGeometry(aqt.mw.pm.profile[key])
|
widget.restoreGeometry(aqt.mw.pm.profile[key])
|
||||||
|
@ -459,36 +459,36 @@ def ensureWidgetInScreenBoundaries(widget):
|
||||||
widget.move(x, y)
|
widget.move(x, y)
|
||||||
|
|
||||||
|
|
||||||
def saveState(widget, key):
|
def saveState(widget, key: str):
|
||||||
key += "State"
|
key += "State"
|
||||||
aqt.mw.pm.profile[key] = widget.saveState()
|
aqt.mw.pm.profile[key] = widget.saveState()
|
||||||
|
|
||||||
|
|
||||||
def restoreState(widget, key):
|
def restoreState(widget, key: str):
|
||||||
key += "State"
|
key += "State"
|
||||||
if aqt.mw.pm.profile.get(key):
|
if aqt.mw.pm.profile.get(key):
|
||||||
widget.restoreState(aqt.mw.pm.profile[key])
|
widget.restoreState(aqt.mw.pm.profile[key])
|
||||||
|
|
||||||
|
|
||||||
def saveIsChecked(widget, key):
|
def saveIsChecked(widget, key: str):
|
||||||
key += "IsChecked"
|
key += "IsChecked"
|
||||||
aqt.mw.pm.profile[key] = widget.isChecked()
|
aqt.mw.pm.profile[key] = widget.isChecked()
|
||||||
|
|
||||||
|
|
||||||
def restoreIsChecked(widget, key):
|
def restoreIsChecked(widget, key: str):
|
||||||
key += "IsChecked"
|
key += "IsChecked"
|
||||||
if aqt.mw.pm.profile.get(key) is not None:
|
if aqt.mw.pm.profile.get(key) is not None:
|
||||||
widget.setChecked(aqt.mw.pm.profile[key])
|
widget.setChecked(aqt.mw.pm.profile[key])
|
||||||
|
|
||||||
|
|
||||||
def saveComboIndex(widget, key):
|
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.profile[textKey] = widget.currentText()
|
||||||
aqt.mw.pm.profile[indexKey] = widget.currentIndex()
|
aqt.mw.pm.profile[indexKey] = widget.currentIndex()
|
||||||
|
|
||||||
|
|
||||||
def restoreComboIndex(widget, history, key):
|
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.profile.get(textKey)
|
||||||
|
@ -498,7 +498,7 @@ def restoreComboIndex(widget, history, key):
|
||||||
widget.setCurrentIndex(index)
|
widget.setCurrentIndex(index)
|
||||||
|
|
||||||
|
|
||||||
def restoreComboHistory(comboBox, name):
|
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)
|
||||||
|
@ -507,7 +507,7 @@ def restoreComboHistory(comboBox, name):
|
||||||
return history
|
return history
|
||||||
|
|
||||||
|
|
||||||
def saveComboHistory(comboBox, history, name):
|
def saveComboHistory(comboBox: QComboBox, history: List[str], name: str):
|
||||||
name += "BoxHistory"
|
name += "BoxHistory"
|
||||||
text_input = comboBox.lineEdit().text()
|
text_input = comboBox.lineEdit().text()
|
||||||
if text_input in history:
|
if text_input in history:
|
||||||
|
|
Loading…
Reference in a new issue