Attempt to make modifier key changes take affect when the dialogue closes. This means you don't have to restart Fenrir to apply them.
This commit is contained in:
1 parent
15e04aa8f8
commit
22f6df6af9
23 files changed
+454
-58
No files matched your search
@@ -19,6 +19,7 @@ package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
@@ -26,16 +27,19 @@ import (
|
||||
"git.stormux.org/storm/fenrir/internal/speech"
|
||||
)
|
||||
|
||||
type modifierSettings struct{ fenrirKeys, scriptKeys []string }
|
||||
|
||||
// applicationSettings separates the effective configuration from the save draft.
|
||||
// The draft retains next-launch menu choices; session mute, automatic reading,
|
||||
// and attribute overrides are not implicitly copied into it.
|
||||
type applicationSettings struct {
|
||||
live config.Settings
|
||||
saveDraft config.Settings
|
||||
resetBase config.Settings // Last loaded or successfully saved settings.
|
||||
remoteFields map[string]uint64
|
||||
remoteRevision uint64
|
||||
speechAvailable bool // The startup connection cannot be enabled by a remote setting.
|
||||
pendingModifiers *modifierSettings
|
||||
live config.Settings
|
||||
saveDraft config.Settings
|
||||
resetBase config.Settings // Last loaded or successfully saved settings.
|
||||
remoteFields map[string]uint64
|
||||
remoteRevision uint64
|
||||
speechAvailable bool // The startup connection cannot be enabled by a remote setting.
|
||||
}
|
||||
|
||||
// configure_reader applies startup settings, including next-launch-only fields.
|
||||
@@ -77,6 +81,11 @@ func (a *application) apply_saved_settings(saved config.Settings, speechApplied
|
||||
if speechApplied {
|
||||
copy_speech_selection(&a.settings.live.Presentation.Speech, saved.Presentation.Speech)
|
||||
}
|
||||
if !slices.Equal(saved.Keyboard.FenrirKeys, a.settings.live.Keyboard.FenrirKeys) || !slices.Equal(saved.General.ScriptKeys, a.settings.live.General.ScriptKeys) {
|
||||
a.settings.pendingModifiers = &modifierSettings{fenrirKeys: slices.Clone(saved.Keyboard.FenrirKeys), scriptKeys: slices.Clone(saved.General.ScriptKeys)}
|
||||
} else {
|
||||
a.settings.pendingModifiers = nil
|
||||
}
|
||||
a.settings.saveDraft = saved
|
||||
a.settings.resetBase = saved
|
||||
a.settings.live.InternalUI = saved.InternalUI
|
||||
@@ -120,6 +129,27 @@ func (a *application) apply_saved_settings(saved config.Settings, speechApplied
|
||||
a.clipboards.configure(saved.Clipboard)
|
||||
}
|
||||
|
||||
// apply_pending_modifiers runs on the event loop after menu closure. Native
|
||||
// adapters defer while keys are held; failure leaves the prior runtime intact.
|
||||
func (a *application) apply_pending_modifiers() {
|
||||
pending := a.settings.pendingModifiers
|
||||
if pending == nil || a.ui.active {
|
||||
return
|
||||
}
|
||||
applied, err := a.keyboards.Update_modifiers(pending.fenrirKeys, pending.scriptKeys)
|
||||
if err != nil {
|
||||
a.settings.pendingModifiers = nil
|
||||
a.voice.Say(i18n.Format("Settings saved, but key changes could not be applied: {0}. Previous keys remain active.", err.Error()))
|
||||
return
|
||||
}
|
||||
if !applied {
|
||||
return
|
||||
}
|
||||
a.settings.live.Keyboard.FenrirKeys = pending.fenrirKeys
|
||||
a.settings.live.General.ScriptKeys = pending.scriptKeys
|
||||
a.settings.pendingModifiers = nil
|
||||
}
|
||||
|
||||
// Quick commands have already changed live values and configured speech when
|
||||
// needed. Refresh the reader without copying session overrides into the draft.
|
||||
func (a *application) apply_quick_settings() {
|
||||
|
||||
Reference in new issue
Block a user