mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix reloading of tts config not working till viewer restarted
This commit is contained in:
parent
c77e02487f
commit
693e61073a
@ -16,11 +16,13 @@ from calibre.utils.localization import canonicalize_lang
|
||||
|
||||
CONFIG_NAME = 'tts'
|
||||
TTS_EMBEDED_CONFIG = 'tts-embedded'
|
||||
conf_cache = {} # for some reason LRU cache doesn't work for this
|
||||
|
||||
|
||||
@lru_cache(2)
|
||||
def load_config(config_name=CONFIG_NAME) -> JSONConfig:
|
||||
return JSONConfig(config_name)
|
||||
if (ans := conf_cache.get(config_name)) is None:
|
||||
ans = conf_cache[config_name] = JSONConfig(config_name)
|
||||
return ans
|
||||
|
||||
|
||||
class TrackingCapability(Enum):
|
||||
@ -158,8 +160,9 @@ class EngineSpecificSettings(NamedTuple):
|
||||
|
||||
@classmethod
|
||||
def create_from_config(cls, engine_name: str, config_name: str = CONFIG_NAME) -> 'EngineSpecificSettings':
|
||||
prefs = load_config(config_name).get('engines', {}).get(engine_name, {})
|
||||
return cls.create_from_prefs(engine_name, prefs)
|
||||
prefs = load_config(config_name)
|
||||
val = prefs.get('engines', {}).get(engine_name, {})
|
||||
return cls.create_from_prefs(engine_name, val)
|
||||
|
||||
@property
|
||||
def as_dict(self) -> dict[str, object]:
|
||||
@ -183,7 +186,7 @@ class EngineSpecificSettings(NamedTuple):
|
||||
return ans
|
||||
|
||||
def save_to_config(self, prefs:JSONConfig | None = None, config_name: str = CONFIG_NAME):
|
||||
prefs = prefs or load_config(config_name)
|
||||
prefs = load_config(config_name) if prefs is None else prefs
|
||||
val = self.as_dict
|
||||
engines = prefs.get('engines', {})
|
||||
if not val:
|
||||
|
Loading…
x
Reference in New Issue
Block a user