fix(ui): harden settings focus and semantics

This commit is contained in:
edde746
2026-07-24 03:46:50 +02:00
parent f8bfecf57d
commit b41fb4fe75
159 changed files with 12054 additions and 2050 deletions
+16 -15
View File
@@ -304,13 +304,19 @@ Map<String, HotKey> _defaultKeyboardHotkeys() => {
'screenshot': const HotKey(key: PhysicalKeyboardKey.keyS, modifiers: [HotKeyModifier.control]),
};
Map<String, HotKey> _decodeKeyboardHotkeys(dynamic raw) {
final result = <String, HotKey>{};
Map<String, HotKey?> _decodeKeyboardHotkeys(dynamic raw) {
final result = <String, HotKey?>{};
for (final entry in (raw as Map<String, dynamic>).entries) {
final hk = SettingsService.deserializeHotKey(entry.value as Map<String, dynamic>);
if (hk != null) result[entry.key] = hk;
final value = entry.value;
if (value is! Map<String, dynamic>) continue;
if (value['disabled'] == true) {
result[entry.key] = null;
continue;
}
final hotkey = SettingsService.deserializeHotKey(value);
if (hotkey != null) result[entry.key] = hotkey;
}
return {..._defaultKeyboardHotkeys(), ...result};
return <String, HotKey?>{..._defaultKeyboardHotkeys(), ...result};
}
class SettingsService extends BaseSharedPreferencesService {
@@ -500,10 +506,12 @@ class SettingsService extends BaseSharedPreferencesService {
);
static const mpvConfigText = _MpvConfigTextPref();
static final keyboardHotkeys = JsonPref<Map<String, HotKey>>(
static final keyboardHotkeys = JsonPref<Map<String, HotKey?>>(
'keyboard_hotkeys',
defaultValue: _defaultKeyboardHotkeys(),
encode: (v) => json.encode(v.map((k, hk) => MapEntry(k, SettingsService.serializeHotKey(hk)))),
defaultValue: <String, HotKey?>{..._defaultKeyboardHotkeys()},
encode: (values) => json.encode(
values.map((key, hotkey) => MapEntry(key, hotkey == null ? const {'disabled': true} : serializeHotKey(hotkey))),
),
decode: _decodeKeyboardHotkeys,
);
static final mediaVersionPreferences = JsonPref<Map<String, MediaVersionPreference>>(
@@ -672,13 +680,6 @@ class SettingsService extends BaseSharedPreferencesService {
await write(mpvPresets, presets);
}
/// Load a preset (replaces current config text).
Future<void> loadMpvPreset(String name) async {
final presets = read(mpvPresets);
final preset = presets.firstWhere((p) => p.name == name, orElse: () => throw Exception('Preset not found: $name'));
await write(mpvConfigText, preset.text);
}
static const _modifierMap = <String, HotKeyModifier>{
'alt': HotKeyModifier.alt,
'control': HotKeyModifier.control,