Add mnemonic mute controls

This commit is contained in:
Storm Dragon
2026-09-05 00:57:37 -04:00
parent ef19a558d2
commit 97fcde7e96
13 changed files with 232 additions and 17 deletions
+28 -6
View File
@@ -3,6 +3,7 @@ package main
import (
"crypto/tls"
"sync"
"unicode"
"git.stormux.org/storm/barnard/config"
"git.stormux.org/storm/barnard/fileplayback"
@@ -251,6 +252,13 @@ func (b *Barnard) StopTransmission() {
}
func (b *Barnard) TreeItemCharacter(ui *uiterm.Ui, tree *uiterm.Tree, item uiterm.TreeItem, ch rune) {
if b.Hotkeys != nil && matchesCharacterHotkey(b.Hotkeys.MuteToggle, ch) {
b.TreeItemKeyPress(ui, tree, item, *b.Hotkeys.MuteToggle)
}
}
func matchesCharacterHotkey(configured *uiterm.Key, ch rune) bool {
return configured != nil && uiterm.Key(unicode.ToLower(ch)) == *configured
}
func matchesVolumeResetKey(configured *uiterm.Key, pressed uiterm.Key) bool {
@@ -308,6 +316,11 @@ func (b *Barnard) TreeItemKeyPress(ui *uiterm.Ui, tree *uiterm.Tree, item uiterm
// Update channel mute state
b.setChannelMuted(treeItem.Channel.ID, channelWillBeMuted)
state := "unmuted"
if channelWillBeMuted {
state = "muted"
}
b.AddOutputLine("Locally " + state + " channel " + treeItem.Channel.Name)
if channelWillBeMuted && b.Client.Self.Channel.ID == treeItem.Channel.ID && b.isTransmitting() {
b.StopTransmission()
}
@@ -329,13 +342,22 @@ func (b *Barnard) TreeItemKeyPress(ui *uiterm.Ui, tree *uiterm.Tree, item uiterm
if treeItem.User != nil {
if key == *b.Hotkeys.MuteToggle {
// Toggle mute for single user
if err := b.UserConfig.ToggleMute(treeItem.User); err != nil {
b.AddOutputLine("Mute: could not save setting: " + err.Error())
if b.Client.Self != nil && treeItem.User.Session == b.Client.Self.Session {
b.toggleSelfMute()
} else {
// Other users are muted only in this Barnard client.
if err := b.UserConfig.ToggleMute(treeItem.User); err != nil {
b.AddOutputLine("Mute: could not save setting: " + err.Error())
}
b.updateUserGain(treeItem.User)
state := "unmuted"
if treeItem.User.LocallyMuted() {
state = "muted"
}
b.AddOutputLine("Locally " + state + " " + treeItem.User.Name)
b.RebuildUserChannelTreePreservingSelection()
b.Ui.Refresh()
}
b.updateUserGain(treeItem.User)
b.RebuildUserChannelTreePreservingSelection()
b.Ui.Refresh()
}
if key == *b.Hotkeys.VolumeDown {
b.changeVolume([]*gumble.User{treeItem.User}, -0.1)