mirror of
https://github.com/onyx-and-iris/voicemeeter-compact.git
synced 2024-11-23 13:20:55 +00:00
userconfigs now returns target.configs
patch bump
This commit is contained in:
parent
e4068277f7
commit
6d46d9a9a5
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "voicemeeter-compact"
|
name = "voicemeeter-compact"
|
||||||
version = "1.8.3"
|
version = "1.8.4"
|
||||||
description = "A Compact Voicemeeter Remote App"
|
description = "A Compact Voicemeeter Remote App"
|
||||||
authors = ["onyx-and-iris <code@onyxandiris.online>"]
|
authors = ["onyx-and-iris <code@onyxandiris.online>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
@ -145,7 +145,7 @@ class App(tk.Tk):
|
|||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def userconfigs(self):
|
def userconfigs(self):
|
||||||
self._configs = loader(self.kind.name)
|
self._configs = loader(self.kind.name, self.target)
|
||||||
return self._configs
|
return self._configs
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,13 +10,19 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
configuration = {}
|
configuration = {}
|
||||||
|
|
||||||
|
|
||||||
|
def get_configpath():
|
||||||
configpaths = [
|
configpaths = [
|
||||||
Path.cwd() / "configs",
|
Path.cwd() / "configs",
|
||||||
Path.home() / ".config" / "vm-compact" / "configs",
|
Path.home() / ".config" / "vm-compact" / "configs",
|
||||||
Path.home() / "Documents" / "Voicemeeter" / "configs",
|
Path.home() / "Documents" / "Voicemeeter" / "configs",
|
||||||
]
|
]
|
||||||
for configpath in configpaths:
|
for configpath in configpaths:
|
||||||
if configpath.is_dir():
|
if configpath.exists():
|
||||||
|
return configpath
|
||||||
|
|
||||||
|
|
||||||
|
if configpath := get_configpath():
|
||||||
filepaths = list(configpath.glob("*.toml"))
|
filepaths = list(configpath.glob("*.toml"))
|
||||||
if any(f.stem in ("app", "vban") for f in filepaths):
|
if any(f.stem in ("app", "vban") for f in filepaths):
|
||||||
configs = {}
|
configs = {}
|
||||||
@ -29,9 +35,7 @@ for configpath in configpaths:
|
|||||||
logger.info(f"configuration: {filename} loaded into memory")
|
logger.info(f"configuration: {filename} loaded into memory")
|
||||||
except tomllib.TOMLDecodeError:
|
except tomllib.TOMLDecodeError:
|
||||||
logger.error(f"Invalid TOML config: configs/{filename.stem}")
|
logger.error(f"Invalid TOML config: configs/{filename.stem}")
|
||||||
|
|
||||||
configuration |= configs
|
configuration |= configs
|
||||||
break
|
|
||||||
|
|
||||||
_defaults = {
|
_defaults = {
|
||||||
"configs": {
|
"configs": {
|
||||||
@ -75,9 +79,10 @@ def get_configuration(key):
|
|||||||
return configuration[key]
|
return configuration[key]
|
||||||
|
|
||||||
|
|
||||||
def loader(kind_id):
|
def loader(kind_id, target):
|
||||||
configs = {}
|
configs = {"reset": target.configs["reset"]}
|
||||||
userconfigpath = Path.home() / ".config" / "vm-compact" / "configs" / kind_id
|
if configpath := get_configpath():
|
||||||
|
userconfigpath = configpath / kind_id
|
||||||
if userconfigpath.exists():
|
if userconfigpath.exists():
|
||||||
filepaths = list(userconfigpath.glob("*.toml"))
|
filepaths = list(userconfigpath.glob("*.toml"))
|
||||||
for filepath in filepaths:
|
for filepath in filepaths:
|
||||||
@ -88,4 +93,6 @@ def loader(kind_id):
|
|||||||
logger.info(f"loader: {identifier} loaded into memory")
|
logger.info(f"loader: {identifier} loaded into memory")
|
||||||
except tomllib.TOMLDecodeError:
|
except tomllib.TOMLDecodeError:
|
||||||
logger.error(f"Invalid TOML config: configs/{filename.stem}")
|
logger.error(f"Invalid TOML config: configs/{filename.stem}")
|
||||||
return configs
|
|
||||||
|
target.configs = configs
|
||||||
|
return target.configs
|
||||||
|
@ -85,24 +85,16 @@ class Menus(tk.Menu):
|
|||||||
self.menu_configs_load = tk.Menu(self.menu_configs, tearoff=0)
|
self.menu_configs_load = tk.Menu(self.menu_configs, tearoff=0)
|
||||||
self.menu_configs.add_cascade(menu=self.menu_configs_load, label="Load config")
|
self.menu_configs.add_cascade(menu=self.menu_configs_load, label="Load config")
|
||||||
self.config_defaults = {"reset"}
|
self.config_defaults = {"reset"}
|
||||||
if len(self.target.configs) > len(self.config_defaults) and all(
|
if len(self.parent.userconfigs) > len(self.config_defaults) and all(
|
||||||
key in self.target.configs for key in self.config_defaults
|
key in self.parent.userconfigs for key in self.config_defaults
|
||||||
):
|
):
|
||||||
[
|
[
|
||||||
self.menu_configs_load.add_command(
|
self.menu_configs_load.add_command(
|
||||||
label=profile, command=partial(self.load_profile, profile)
|
label=profile, command=partial(self.load_profile, profile)
|
||||||
)
|
)
|
||||||
for profile in self.target.configs.keys()
|
for profile in self.parent.userconfigs.keys()
|
||||||
if profile not in self.config_defaults
|
if profile not in self.config_defaults
|
||||||
]
|
]
|
||||||
elif self.parent.userconfigs:
|
|
||||||
[
|
|
||||||
self.menu_configs_load.add_command(
|
|
||||||
label=name, command=partial(self.load_custom_profile, data)
|
|
||||||
)
|
|
||||||
for name, data in self.parent.userconfigs.items()
|
|
||||||
if name not in self.config_defaults
|
|
||||||
]
|
|
||||||
else:
|
else:
|
||||||
self.menu_configs.entryconfig(0, state="disabled")
|
self.menu_configs.entryconfig(0, state="disabled")
|
||||||
self.menu_configs.add_command(
|
self.menu_configs.add_command(
|
||||||
@ -315,19 +307,11 @@ class Menus(tk.Menu):
|
|||||||
|
|
||||||
def menu_teardown(self, i):
|
def menu_teardown(self, i):
|
||||||
# remove config load menus
|
# remove config load menus
|
||||||
removed = []
|
if len(self.parent.userconfigs) > len(self.config_defaults):
|
||||||
for key in self.target.configs.keys():
|
for profile in self.parent.userconfigs:
|
||||||
if key not in self.config_defaults:
|
if profile not in self.config_defaults:
|
||||||
try:
|
try:
|
||||||
self.menu_configs_load.delete(key)
|
self.menu_configs_load.delete(profile)
|
||||||
removed.append(key)
|
|
||||||
except tk._tkinter.tclError as e:
|
|
||||||
self.logger.warning(f"{type(e).__name__}: {e}")
|
|
||||||
|
|
||||||
for key in self.parent.userconfigs.keys():
|
|
||||||
if key not in self.config_defaults and key not in removed:
|
|
||||||
try:
|
|
||||||
self.menu_configs_load.delete(key)
|
|
||||||
except tk._tkinter.tclError as e:
|
except tk._tkinter.tclError as e:
|
||||||
self.logger.warning(f"{type(e).__name__}: {e}")
|
self.logger.warning(f"{type(e).__name__}: {e}")
|
||||||
|
|
||||||
@ -338,24 +322,13 @@ class Menus(tk.Menu):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def menu_setup(self):
|
def menu_setup(self):
|
||||||
if len(self.target.configs) > len(self.config_defaults) and all(
|
if len(self.parent.userconfigs) > len(self.config_defaults):
|
||||||
key in self.target.configs for key in self.config_defaults
|
for profile in self.parent.userconfigs:
|
||||||
):
|
if profile not in self.config_defaults:
|
||||||
[
|
|
||||||
self.menu_configs_load.add_command(
|
self.menu_configs_load.add_command(
|
||||||
label=profile, command=partial(self.load_profile, profile)
|
label=profile, command=partial(self.load_profile, profile)
|
||||||
)
|
)
|
||||||
for profile in self.target.configs.keys()
|
self.menu_configs.entryconfig(0, state="normal")
|
||||||
if profile not in self.config_defaults
|
|
||||||
]
|
|
||||||
elif self.parent.userconfigs:
|
|
||||||
[
|
|
||||||
self.menu_configs_load.add_command(
|
|
||||||
label=name, command=partial(self.load_custom_profile, data)
|
|
||||||
)
|
|
||||||
for name, data in self.parent.userconfigs.items()
|
|
||||||
if name not in self.config_defaults
|
|
||||||
]
|
|
||||||
else:
|
else:
|
||||||
self.menu_configs.entryconfig(0, state="disabled")
|
self.menu_configs.entryconfig(0, state="disabled")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user