mirror of
https://github.com/onyx-and-iris/nvda-voicemeeter.git
synced 2026-04-07 18:03:35 +00:00
Compare commits
2 Commits
add-patch-
...
v0.5.7b1
| Author | SHA1 | Date | |
|---|---|---|---|
| 36003fe73f | |||
| cb82033e1c |
12
README.md
12
README.md
@@ -131,9 +131,11 @@ For Gate BP Sidechain, Attack, Hold, Release you may use:
|
||||
|
||||
To reset a slider back to its default value you may use `Control + Shift + R`.
|
||||
|
||||
#### `Menu`
|
||||
### Menu
|
||||
|
||||
A single menu item `Voicemeeter` can be opened using `Alt` and then `v`. The menu allows you to:
|
||||
#### `Voicemeeter`
|
||||
|
||||
The `Voicemeeter` menu can be opened using `Alt` and then `v`. It offers the following options:
|
||||
|
||||
- Restart Voicemeeter audio engine
|
||||
- Save/Load current settings (as an xml file)
|
||||
@@ -143,7 +145,11 @@ The `Save Settings` option opens a popup window with two buttons, `Browse` and `
|
||||
|
||||
`Load Settings` and `Load on Startup` both open an Open dialog box immediately.
|
||||
|
||||
### `Quick access binds`
|
||||
#### `Themes`
|
||||
|
||||
The `Themes` menu can be opened using `Alt` and then `t`. Use this menu to select from a list of coloured themes. Some themes offer higher contrast colours. An application restart is required to load a new theme. Once a theme is selected it will become the default for future startups.
|
||||
|
||||
### Quick access binds
|
||||
|
||||
There are a number of quick binds available to assist with faster navigation and general use.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "nvda_voicemeeter"
|
||||
version = "0.5.6"
|
||||
version = "0.5.7b1"
|
||||
description = "A Voicemeeter app compatible with NVDA"
|
||||
authors = [
|
||||
{ name = "onyx-and-iris", email = "code@onyxandiris.online" },
|
||||
|
||||
@@ -92,6 +92,8 @@ class Builder:
|
||||
return [[menu], [tab_group]]
|
||||
|
||||
def make_menu(self) -> psg.Menu:
|
||||
themes = [f"{theme}::MENU THEME" for theme in util.get_themes_list()]
|
||||
themes.append("Default::MENU THEME")
|
||||
menu_def = [
|
||||
[
|
||||
"&Voicemeeter",
|
||||
@@ -102,6 +104,7 @@ class Builder:
|
||||
"Load Settings on Startup ::MENU",
|
||||
],
|
||||
],
|
||||
["&Theme", themes],
|
||||
]
|
||||
return psg.Menu(menu_def, key="menus")
|
||||
|
||||
|
||||
34
src/nvda_voicemeeter/configuration.py
Normal file
34
src/nvda_voicemeeter/configuration.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
SETTINGS = Path.cwd() / "settings.json"
|
||||
|
||||
|
||||
def config_from_json():
|
||||
data = {}
|
||||
if not SETTINGS.exists():
|
||||
return data
|
||||
with open(SETTINGS, "r") as f:
|
||||
data = json.load(f)
|
||||
return data
|
||||
|
||||
|
||||
config = config_from_json()
|
||||
|
||||
|
||||
def get(key, default=None):
|
||||
if key in config:
|
||||
return config[key]
|
||||
return default
|
||||
|
||||
|
||||
def set(key, value):
|
||||
config[key] = value
|
||||
with open(SETTINGS, "w") as f:
|
||||
json.dump(config, f)
|
||||
|
||||
|
||||
def delete(key):
|
||||
del config[key]
|
||||
with open(SETTINGS, "w") as f:
|
||||
json.dump(config, f)
|
||||
@@ -1,5 +1,7 @@
|
||||
from typing import Iterable
|
||||
|
||||
import PySimpleGUI as psg
|
||||
|
||||
|
||||
def get_asio_input_spinbox_index(channel, num) -> int:
|
||||
if channel == 0:
|
||||
@@ -196,3 +198,27 @@ def get_slider_modes() -> Iterable:
|
||||
|
||||
def _get_bus_assignments(kind) -> list:
|
||||
return [f"A{i}" for i in range(1, kind.phys_out + 1)] + [f"B{i}" for i in range(1, kind.virt_out + 1)]
|
||||
|
||||
|
||||
def get_themes_list() -> list:
|
||||
return [
|
||||
"Bright Colors",
|
||||
"Dark Blue 14",
|
||||
"Dark Brown 2",
|
||||
"Dark Brown 3",
|
||||
"Dark Green 2",
|
||||
"Dark Grey 2",
|
||||
"Dark Teal1",
|
||||
"Dark Teal6",
|
||||
"Kayak",
|
||||
"Light Blue 2",
|
||||
"Light Brown 2",
|
||||
"Light Brown 5",
|
||||
"Light Green",
|
||||
"Light Green 3",
|
||||
"Light Grey 2",
|
||||
"Light Purple",
|
||||
"Neutral Blue",
|
||||
"Reds",
|
||||
"Sandy Beach",
|
||||
]
|
||||
|
||||
@@ -4,7 +4,7 @@ from pathlib import Path
|
||||
|
||||
import PySimpleGUI as psg
|
||||
|
||||
from . import models, util
|
||||
from . import configuration, models, util
|
||||
from .builder import Builder
|
||||
from .nvda import Nvda
|
||||
from .parser import Parser
|
||||
@@ -12,14 +12,12 @@ from .popup import Popup
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
psg.theme("Dark Blue 3")
|
||||
psg.theme(configuration.get("default_theme", "Dark Blue 3"))
|
||||
|
||||
|
||||
class NVDAVMWindow(psg.Window):
|
||||
"""Represents the main window of the Voicemeeter NVDA application"""
|
||||
|
||||
SETTINGS = "settings.json"
|
||||
|
||||
def __init__(self, title, vm):
|
||||
self.vm = vm
|
||||
self.kind = self.vm.kind
|
||||
@@ -63,12 +61,10 @@ class NVDAVMWindow(psg.Window):
|
||||
self["tabgroup"].set_focus()
|
||||
|
||||
def __enter__(self):
|
||||
settings_path = Path.cwd() / self.SETTINGS
|
||||
settings_path = configuration.SETTINGS
|
||||
if settings_path.exists():
|
||||
try:
|
||||
with open(settings_path, "r") as f:
|
||||
data = json.load(f)
|
||||
defaultconfig = Path(data["default_config"])
|
||||
defaultconfig = Path(configuration.get("default_config", "")) # coerce the type
|
||||
if defaultconfig.exists():
|
||||
self.vm.set("command.load", str(defaultconfig))
|
||||
self.logger.debug(f"config {defaultconfig} loaded")
|
||||
@@ -78,7 +74,7 @@ class NVDAVMWindow(psg.Window):
|
||||
f"config {defaultconfig.stem} has been loaded",
|
||||
)
|
||||
except json.JSONDecodeError:
|
||||
self.logger.debug("no data in settings.json. silently continuing...")
|
||||
self.logger.debug("no default_config in settings.json. silently continuing...")
|
||||
|
||||
self.vm.init_thread()
|
||||
self.vm.observer.add(self.on_pdirty)
|
||||
@@ -510,17 +506,27 @@ class NVDAVMWindow(psg.Window):
|
||||
file_types=(("XML", ".xml"),),
|
||||
):
|
||||
filepath = Path(filepath)
|
||||
with open(self.SETTINGS, "w") as f:
|
||||
json.dump({"default_config": str(filepath)}, f)
|
||||
configuration.set("default_settings", str(filepath))
|
||||
self.TKroot.after(
|
||||
200,
|
||||
self.nvda.speak,
|
||||
f"config {filepath.stem} set as default on startup",
|
||||
)
|
||||
else:
|
||||
with open(self.SETTINGS, "wb") as f:
|
||||
f.truncate()
|
||||
self.logger.debug("settings.json was truncated")
|
||||
configuration.delete("default_settings")
|
||||
self.logger.debug("default_settings removed from settings.json")
|
||||
|
||||
case [theme, ["MENU", "THEME"]]:
|
||||
chosen = " ".join(theme)
|
||||
if chosen == "Default":
|
||||
chosen = "Dark Blue 3"
|
||||
configuration.set("default_theme", chosen)
|
||||
self.TKroot.after(
|
||||
200,
|
||||
self.nvda.speak,
|
||||
f"theme {chosen} selected.",
|
||||
)
|
||||
self.logger.debug(f"theme {chosen} selected")
|
||||
|
||||
# Tabs
|
||||
case ["tabgroup"] | [["tabgroup"], ["FOCUS", "IN"]]:
|
||||
|
||||
Reference in New Issue
Block a user