voicemeeter-compact/vmcompact/data.py

71 lines
2.0 KiB
Python
Raw Normal View History

2022-04-11 18:35:28 +01:00
from dataclasses import dataclass
from voicemeeterlib import kinds
2022-04-11 18:35:28 +01:00
from .configurations import get_configuration
2025-01-15 20:56:37 +00:00
configuration = get_configuration('app')
class SingletonMeta(type):
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
instance = super().__call__(*args, **kwargs)
cls._instances[cls] = instance
return cls._instances[cls]
2022-04-11 18:35:28 +01:00
@dataclass
class Configurations(metaclass=SingletonMeta):
# is the gui extended
2025-01-15 20:56:37 +00:00
extended: bool = configuration['extends']['extended']
# direction the gui extends
2025-01-15 20:56:37 +00:00
extends_horizontal: bool = configuration['extends']['extends_horizontal']
# are themes enabled
2025-01-15 20:56:37 +00:00
themes_enabled: bool = configuration['theme']['enabled']
# light or dark
2025-01-15 20:56:37 +00:00
theme_mode: str = configuration['theme']['mode']
# size of mousewheel scroll step
2025-01-15 20:56:37 +00:00
mwscroll_step: int = configuration['mwscroll_step']['size']
# bus assigned as current submix
2025-01-15 20:56:37 +00:00
submixes: int = configuration['submixes']['default']
# width of a single channel labelframe
2025-01-15 20:56:37 +00:00
channel_width: int = configuration['channel']['width']
# height of a single channel labelframe
2025-01-15 20:56:37 +00:00
channel_height: int = configuration['channel']['height']
# xpadding for a single channel labelframe
2025-01-15 20:56:37 +00:00
channel_xpadding: int = configuration['channel']['xpadding']
# do we grid the navigation frame?
2025-01-15 20:56:37 +00:00
navigation_show: bool = configuration['navigation']['show']
@property
def config(self):
2025-01-15 20:56:37 +00:00
if 'configs' in configuration:
return configuration['configs']['config']
@dataclass
class BaseValues(metaclass=SingletonMeta):
# pause updates after releasing scale
run_update: bool = False
2022-04-11 18:35:28 +01:00
# are we dragging main window with mouse 1
dragging: bool = False
# a vban connection established
vban_connected: bool = False
_base_values = BaseValues()
_configuration = Configurations()
2022-04-11 18:35:28 +01:00
_kinds = {kind.name: kind for kind in kinds.kinds_all}
2022-04-11 18:35:28 +01:00
_kinds_all = _kinds.values()
def kind_get(kind_id):
return _kinds[kind_id]