tmp commit

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-11-28 23:57:48 +08:00
parent 19e8ca6c06
commit f11104fcb5
49 changed files with 296 additions and 46 deletions

View File

@@ -1585,7 +1585,7 @@ class _KeyboardMenu extends StatelessWidget {
// If use flutter to grab keys, we can only use one mode.
// Map mode and Legacy mode, at least one of them is supported.
String? modeOnly;
if (stateGlobal.grabKeyboard) {
if (isInputSourceFlutter) {
if (bind.sessionIsKeyboardModeSupported(
sessionId: ffi.sessionId, mode: kKeyMapMode)) {
modeOnly = kKeyMapMode;
@@ -1604,6 +1604,8 @@ class _KeyboardMenu extends StatelessWidget {
keyboardMode(modeOnly),
localKeyboardType(),
Divider(),
inputSource(),
Divider(),
viewMode(),
Divider(),
reverseMouseWheel(),
@@ -1678,6 +1680,39 @@ class _KeyboardMenu extends StatelessWidget {
);
}
inputSource() {
final supportedInputSource = bind.mainSupportedInputSource();
if (supportedInputSource.isEmpty) return Offstage();
late final List<dynamic> supportedInputSourceList;
try {
supportedInputSourceList = jsonDecode(supportedInputSource);
} catch (e) {
debugPrint('Failed to decode $supportedInputSource, $e');
return;
}
if (supportedInputSourceList.length < 2) return Offstage();
final inputSource = stateGlobal.getInputSource();
final enabled = !ffi.ffiModel.viewOnly;
return Column(
children: supportedInputSourceList.map((e) {
final d = e as List<dynamic>;
return RdoMenuButton<String>(
child: Text(translate(d[1] as String)),
value: d[0] as String,
groupValue: inputSource,
onChanged: enabled
? (e) {
if (e != null) {
stateGlobal.setInputSource(e);
}
}
: null,
ffi: ffi,
);
}).toList(),
);
}
viewMode() {
final ffiModel = ffi.ffiModel;
final enabled = versionCmp(pi.version, '1.2.0') >= 0 && ffiModel.keyboard;