mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Load previously loaded profile (#1960)
* added option to load the last loaded profile * add formatting changes for tests * fix comments - integrate as new functionality rather than as an option, fix type hinting and remove bug if profile is deleted
This commit is contained in:
parent
d7d9f51b68
commit
662586765b
2 changed files with 11 additions and 0 deletions
|
@ -282,8 +282,12 @@ class AnkiQt(QMainWindow):
|
|||
if not self.pm.name:
|
||||
# if there's a single profile, load it automatically
|
||||
profs = self.pm.profiles()
|
||||
name = self.pm.last_loaded_profile_name()
|
||||
if len(profs) == 1:
|
||||
self.pm.load(profs[0])
|
||||
elif name in profs:
|
||||
self.pm.load(name)
|
||||
|
||||
if not self.pm.name:
|
||||
self.showProfileManager()
|
||||
else:
|
||||
|
|
|
@ -220,6 +220,7 @@ class ProfileManager:
|
|||
print("resetting corrupt profile")
|
||||
self.profile = profileConf.copy()
|
||||
self.save()
|
||||
self.set_last_loaded_profile_name(name)
|
||||
return True
|
||||
|
||||
def save(self) -> None:
|
||||
|
@ -544,6 +545,12 @@ create table if not exists profiles
|
|||
def set_new_import_export(self, enabled: bool) -> None:
|
||||
self.meta["new_import_export"] = enabled
|
||||
|
||||
def last_loaded_profile_name(self) -> str | None:
|
||||
return self.meta.get("last_loaded_profile_name")
|
||||
|
||||
def set_last_loaded_profile_name(self, name: str) -> None:
|
||||
self.meta["last_loaded_profile_name"] = name
|
||||
|
||||
# Profile-specific
|
||||
######################################################################
|
||||
|
||||
|
|
Loading…
Reference in a new issue