Fixed the menu, remember transmission should be there now.
This commit is contained in:
@@ -55,8 +55,8 @@ agcenabled = true
|
||||
```
|
||||
|
||||
To restore the last transmit state after reconnecting or restarting Barnard,
|
||||
enable the option in `barnard-ui` under **Settings**, or set it directly in
|
||||
`~/.barnard.toml`:
|
||||
open the F10 **Actions** menu, choose **Audio settings**, and toggle **Remember
|
||||
transmission state**. You can also set it directly in `~/.barnard.toml`:
|
||||
|
||||
```toml
|
||||
remembertransmissionstate = true
|
||||
|
||||
@@ -194,6 +194,7 @@ func (b *Barnard) OpenKeyboardHelp() {
|
||||
func (b *Barnard) audioSettingsItems() []uiterm.TreeItem {
|
||||
agc := enabledLabel(b.UserConfig.GetAGCEnabled())
|
||||
noiseSuppression := enabledLabel(b.UserConfig.GetNoiseSuppressionEnabled())
|
||||
rememberTransmissionState := enabledLabel(b.UserConfig.GetRememberTransmissionState())
|
||||
micVolume := b.UserConfig.GetMicVolume()
|
||||
return []uiterm.TreeItem{
|
||||
adminItem{label: "Automatic gain control: " + agc + "; Enter toggles", applicationAction: true, action: func() {
|
||||
@@ -206,6 +207,15 @@ func (b *Barnard) audioSettingsItems() []uiterm.TreeItem {
|
||||
b.AddOutputLine("Settings: noise suppression " + enabledLabel(enabled))
|
||||
b.UpdateGeneralStatus("Noise suppression: "+enabledLabel(enabled), false)
|
||||
}},
|
||||
adminItem{label: "Remember transmission state: " + rememberTransmissionState + "; Enter toggles", applicationAction: true, action: func() {
|
||||
enabled := !b.UserConfig.GetRememberTransmissionState()
|
||||
if err := b.UserConfig.SetRememberTransmissionState(enabled); err != nil {
|
||||
b.AddOutputLine("Settings: could not save remember transmission state: " + err.Error())
|
||||
return
|
||||
}
|
||||
b.AddOutputLine("Settings: remember transmission state " + enabledLabel(enabled))
|
||||
b.UpdateGeneralStatus("Remember transmission state: "+enabledLabel(enabled), false)
|
||||
}},
|
||||
adminItem{label: fmt.Sprintf("Microphone level: %.0f percent", micVolume*100)},
|
||||
adminItem{label: "Increase microphone level by 10 percent", applicationAction: true, action: func() {
|
||||
volume := b.adjustMicVolume(0.1)
|
||||
|
||||
@@ -14,8 +14,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"git.stormux.org/storm/barnard/config"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -446,32 +444,6 @@ func (app *App) remove_server() error {
|
||||
return app.ui.message("Removed server " + name)
|
||||
}
|
||||
|
||||
func settings_menu_options(rememberTransmissionState bool) []string {
|
||||
state := "Off"
|
||||
if rememberTransmissionState {
|
||||
state = "On"
|
||||
}
|
||||
return []string{
|
||||
"Remember transmission state: " + state,
|
||||
"Go Back",
|
||||
}
|
||||
}
|
||||
|
||||
func (app *App) manage_settings() error {
|
||||
cfg := config.NewConfig(&app.paths.BarnardTOML)
|
||||
for {
|
||||
options := settings_menu_options(cfg.GetRememberTransmissionState())
|
||||
selection, cancelled, err := app.ui.menu(options)
|
||||
if err != nil || cancelled || selection == len(options)-1 {
|
||||
return err
|
||||
}
|
||||
enabled := !cfg.GetRememberTransmissionState()
|
||||
if err := cfg.SetRememberTransmissionState(enabled); err != nil {
|
||||
return app.ui.message("Could not save settings: " + err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func config_has_value(path, wantedKey string) bool {
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
@@ -628,8 +600,6 @@ func (app *App) run() error {
|
||||
err = app.manage_certificate()
|
||||
case "Logs":
|
||||
err = app.manage_logs()
|
||||
case "Settings":
|
||||
err = app.manage_settings()
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -644,7 +614,6 @@ func main_menu_options() []string {
|
||||
"Remove server",
|
||||
"Manage Certificate",
|
||||
"Logs",
|
||||
"Settings",
|
||||
"Exit",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,16 +209,4 @@ func TestProgramIdentityAndMainMenuUseBarnardUI(t *testing.T) {
|
||||
t.Fatalf("legacy go-ui name remains in main menu: %q", option)
|
||||
}
|
||||
}
|
||||
if !slices.Contains(options, "Settings") {
|
||||
t.Fatalf("main menu does not contain Settings: %v", options)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSettingsMenuReportsRememberTransmissionState(t *testing.T) {
|
||||
if got := settings_menu_options(false)[0]; got != "Remember transmission state: Off" {
|
||||
t.Fatalf("disabled setting label = %q", got)
|
||||
}
|
||||
if got := settings_menu_options(true)[0]; got != "Remember transmission state: On" {
|
||||
t.Fatalf("enabled setting label = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -32,7 +32,7 @@ func TestAudioSettingsExposeCurrentValuesAndPersistMicChanges(t *testing.T) {
|
||||
labels = append(labels, item.String())
|
||||
}
|
||||
joined := strings.Join(labels, "\n")
|
||||
for _, wanted := range []string{"Automatic gain control: on", "Noise suppression: off", "Microphone level: 100 percent"} {
|
||||
for _, wanted := range []string{"Automatic gain control: on", "Noise suppression: off", "Remember transmission state: off", "Microphone level: 100 percent"} {
|
||||
if !strings.Contains(joined, wanted) {
|
||||
t.Errorf("settings did not include %q:\n%s", wanted, joined)
|
||||
}
|
||||
@@ -40,6 +40,7 @@ func TestAudioSettingsExposeCurrentValuesAndPersistMicChanges(t *testing.T) {
|
||||
|
||||
items[0].(adminItem).action()
|
||||
items[1].(adminItem).action()
|
||||
items[2].(adminItem).action()
|
||||
reloaded := config.NewConfig(&configPath)
|
||||
if reloaded.GetAGCEnabled() {
|
||||
t.Fatal("settings action did not persist disabled automatic gain control")
|
||||
@@ -47,6 +48,9 @@ func TestAudioSettingsExposeCurrentValuesAndPersistMicChanges(t *testing.T) {
|
||||
if !reloaded.GetNoiseSuppressionEnabled() {
|
||||
t.Fatal("settings action did not persist enabled noise suppression")
|
||||
}
|
||||
if !reloaded.GetRememberTransmissionState() {
|
||||
t.Fatal("settings action did not persist enabled transmission-state remembering")
|
||||
}
|
||||
|
||||
if got := b.adjustMicVolume(-0.1); got < 0.899 || got > 0.901 {
|
||||
t.Fatalf("adjusted microphone level = %v, want 0.9", got)
|
||||
|
||||
Reference in New Issue
Block a user