removes the spinbox from the rename popup

updates README

fixes #12

b1 bump
This commit is contained in:
onyx-and-iris 2023-09-20 18:24:24 +01:00
parent a19aab3936
commit 22bf109499
4 changed files with 41 additions and 46 deletions

View File

@ -106,7 +106,7 @@ All sliders may be controlled in three different ways:
- `Shift + Left|Right arrow` to move a slider by 0.1 steps. - `Shift + Left|Right arrow` to move a slider by 0.1 steps.
- `Control + Left|Right arrow` to move a slider by 3 steps. - `Control + Left|Right arrow` to move a slider by 3 steps.
To rename a strip/bus channel navigate to the relevant tab, then press `F2`. This will open a popup window where you can set the channel index (with a spinbox) and set the new label using a text input box. To rename a strip/bus channel focus on the channel in question and press `F2`. Then enter the new channel name into the text input widget and press the `Ok` button.
Pressing the `OK` button with an empty text input will clear the label. In this case the label will be read as a default value for that channel. For example, if the leftmost Strip label were cleared, the screen reader will now read `Hardware Input 1`. Pressing the `OK` button with an empty text input will clear the label. In this case the label will be read as a default value for that channel. For example, if the leftmost Strip label were cleared, the screen reader will now read `Hardware Input 1`.

View File

@ -1,6 +1,6 @@
[project] [project]
name = "nvda_voicemeeter" name = "nvda_voicemeeter"
version = "0.3.0" version = "0.3.0b1"
description = "A Voicemeeter app compatible with NVDA" description = "A Voicemeeter app compatible with NVDA"
authors = [ authors = [
{ name = "onyx-and-iris", email = "code@onyxandiris.online" }, { name = "onyx-and-iris", email = "code@onyxandiris.online" },

View File

@ -11,6 +11,7 @@ logger = logging.getLogger(__name__)
class Popup: class Popup:
def __init__(self, window): def __init__(self, window):
self.window = window self.window = window
self.kind = self.window.kind
self.logger = logger.getChild(type(self).__name__) self.logger = logger.getChild(type(self).__name__)
def save_as(self, message, title=None, initial_folder=None): def save_as(self, message, title=None, initial_folder=None):
@ -46,28 +47,27 @@ class Popup:
if filepath: if filepath:
return Path(filepath) return Path(filepath)
def rename(self, message, title=None, tab=None): def rename(self, message, index, title=None, tab=None):
if tab == "Physical Strip": if "Strip" in tab:
upper = self.window.kind.phys_in + 1 if index < self.kind.phys_in:
elif tab == "Virtual Strip": title += f" Physical Strip {index + 1}"
upper = self.window.kind.virt_in + 1 else:
elif tab == "Buses": title += f" Virtual Strip {index - self.kind.phys_in + 1}"
upper = self.window.kind.num_bus + 1 else:
if index < self.kind.phys_out:
title += f" Physical Bus {index + 1}"
else:
title += f" Virtual Bus {index - self.kind.phys_out + 1}"
layout = [ layout = [
[psg.Text(message)], [psg.Text(message)],
[ [
[ [
psg.Spin(
list(range(1, upper)), initial_value=1, size=2, enable_events=True, key=f"Index", readonly=True
),
psg.Input(key="Edit"), psg.Input(key="Edit"),
], ],
[psg.Button("Ok"), psg.Button("Cancel")], [psg.Button("Ok"), psg.Button("Cancel")],
], ],
] ]
popup = psg.Window(title, layout, finalize=True) popup = psg.Window(title, layout, finalize=True)
popup["Index"].bind("<FocusIn>", "||FOCUS IN")
popup["Edit"].bind("<FocusIn>", "||FOCUS IN") popup["Edit"].bind("<FocusIn>", "||FOCUS IN")
popup["Ok"].bind("<FocusIn>", "||FOCUS IN") popup["Ok"].bind("<FocusIn>", "||FOCUS IN")
popup["Ok"].bind("<Return>", "||KEY ENTER") popup["Ok"].bind("<Return>", "||KEY ENTER")
@ -81,15 +81,8 @@ class Popup:
if event in (psg.WIN_CLOSED, "Cancel"): if event in (psg.WIN_CLOSED, "Cancel"):
break break
match parsed_cmd := self.window.parser.match.parseString(event): match parsed_cmd := self.window.parser.match.parseString(event):
case ["Index"]:
val = values["Index"]
self.window.nvda.speak(f"Index {val}")
case [[button], ["FOCUS", "IN"]]: case [[button], ["FOCUS", "IN"]]:
if button == "Index": self.window.nvda.speak(button)
val = values["Index"]
self.window.nvda.speak(f"Index {val}")
else:
self.window.nvda.speak(button)
case [[button], ["KEY", "ENTER"]]: case [[button], ["KEY", "ENTER"]]:
popup.find_element_with_focus().click() popup.find_element_with_focus().click()
case ["Ok"]: case ["Ok"]:

View File

@ -393,30 +393,32 @@ class NVDAVMWindow(psg.Window):
case ["F2:113"]: case ["F2:113"]:
tab = values["tabgroup"].split("||")[1] tab = values["tabgroup"].split("||")[1]
if tab in ("Physical Strip", "Virtual Strip", "Buses"): if tab in ("Physical Strip", "Virtual Strip", "Buses"):
data = self.popup.rename("Label", title=f"Rename {tab}", tab=tab) if focus := self.find_element_with_focus():
if not data: # cancel was pressed identifier, partial = focus.Key.split("||")
continue _, index = identifier.split()
index = int(data["Index"]) - 1 index = int(index)
match tab: data = self.popup.rename("Label", index, title=f"Rename", tab=tab)
case "Physical Strip": if not data: # cancel was pressed
label = data.get("Edit", f"Hardware Input {index + 1}") continue
self.vm.strip[index].label = label match tab:
self[f"STRIP {index}||LABEL"].update(value=label) case "Physical Strip":
self.cache["labels"][f"STRIP {index}||LABEL"] = label label = data.get("Edit", f"Hardware Input {int(index) + 1}")
case "Virtual Strip": self.vm.strip[int(index)].label = label
index += self.kind.phys_in self[f"STRIP {index}||LABEL"].update(value=label)
label = data.get("Edit", f"Virtual Input {index - self.kind.phys_in + 1}") self.cache["labels"][f"STRIP {index}||LABEL"] = label
self.vm.strip[index].label = label case "Virtual Strip":
self[f"STRIP {index}||LABEL"].update(value=label) label = data.get("Edit", f"Virtual Input {int(index) + 1}")
self.cache["labels"][f"STRIP {index}||LABEL"] = label self.vm.strip[int(index)].label = label
case "Buses": self[f"STRIP {index}||LABEL"].update(value=label)
if index < self.kind.phys_out: self.cache["labels"][f"STRIP {index}||LABEL"] = label
label = data.get("Edit", f"Physical Bus {index + 1}") case "Buses":
else: if index < self.kind.phys_out:
label = data.get("Edit", f"Virtual Bus {index - self.kind.phys_out + 1}") label = data.get("Edit", f"Physical Bus {int(index) + 1}")
self.vm.bus[index].label = label else:
self[f"BUS {index}||LABEL"].update(value=label) label = data.get("Edit", f"Virtual Bus {int(index) - self.kind.phys_out + 1}")
self.cache["labels"][f"BUS {index}||LABEL"] = label self.vm.bus[int(index)].label = label
self[f"BUS {index}||LABEL"].update(value=label)
self.cache["labels"][f"BUS {index}||LABEL"] = label
# Menus # Menus
case [["Restart", "Audio", "Engine"], ["MENU"]]: case [["Restart", "Audio", "Engine"], ["MENU"]]: