diff --git a/flutter/lib/common/widgets/toolbar.dart b/flutter/lib/common/widgets/toolbar.dart index 05cb84f8d..3ea8e5371 100644 --- a/flutter/lib/common/widgets/toolbar.dart +++ b/flutter/lib/common/widgets/toolbar.dart @@ -486,21 +486,6 @@ Future> toolbarDisplayToggle( }, child: Text(translate('Lock after session end')))); } - // swap key - if (ffiModel.keyboard && - ((Platform.isMacOS && pi.platform != kPeerPlatformMacOS) || - (!Platform.isMacOS && pi.platform == kPeerPlatformMacOS))) { - final option = 'allow_swap_key'; - final value = - bind.sessionGetToggleOptionSync(sessionId: sessionId, arg: option); - v.add(TToggleMenu( - value: value, - onChanged: (value) { - if (value == null) return; - bind.sessionToggleOption(sessionId: sessionId, value: option); - }, - child: Text(translate('Swap control-command key')))); - } if (useTextureRender && pi.isSupportMultiDisplay && @@ -552,17 +537,8 @@ Future> toolbarDisplayToggle( child: Text(translate('True color (4:4:4)')))); } - if (ffiModel.keyboard) { - final option = 'swap-left-right-mouse'; - final value = - bind.sessionGetToggleOptionSync(sessionId: sessionId, arg: option); - v.add(TToggleMenu( - value: value, - onChanged: (value) { - if (value == null) return; - bind.sessionToggleOption(sessionId: sessionId, value: option); - }, - child: Text(translate('swap-left-right-mouse')))); + if (isMobile) { + v.addAll(toolbarKeyboardToggles(ffi)); } return v; @@ -633,3 +609,41 @@ List toolbarPrivacyMode( }).toList(); } } + +List toolbarKeyboardToggles(FFI ffi) { + final ffiModel = ffi.ffiModel; + final pi = ffiModel.pi; + final sessionId = ffi.sessionId; + List v = []; + + // swap key + if (ffiModel.keyboard && + ((Platform.isMacOS && pi.platform != kPeerPlatformMacOS) || + (!Platform.isMacOS && pi.platform == kPeerPlatformMacOS))) { + final option = 'allow_swap_key'; + final value = + bind.sessionGetToggleOptionSync(sessionId: sessionId, arg: option); + v.add(TToggleMenu( + value: value, + onChanged: (value) { + if (value == null) return; + bind.sessionToggleOption(sessionId: sessionId, value: option); + }, + child: Text(translate('Swap control-command key')))); + } + + // swap left right mouse + if (!isMobile && ffiModel.keyboard) { + final option = 'swap-left-right-mouse'; + final value = + bind.sessionGetToggleOptionSync(sessionId: sessionId, arg: option); + v.add(TToggleMenu( + value: value, + onChanged: (value) { + if (value == null) return; + bind.sessionToggleOption(sessionId: sessionId, value: option); + }, + child: Text(translate('swap-left-right-mouse')))); + } + return v; +} diff --git a/flutter/lib/desktop/widgets/remote_toolbar.dart b/flutter/lib/desktop/widgets/remote_toolbar.dart index efb58075d..208fafc5f 100644 --- a/flutter/lib/desktop/widgets/remote_toolbar.dart +++ b/flutter/lib/desktop/widgets/remote_toolbar.dart @@ -1596,6 +1596,10 @@ class _KeyboardMenu extends StatelessWidget { modeOnly = kKeyLegacyMode; } } + final toolbarToggles = toolbarKeyboardToggles(ffi) + .map((e) => CkbMenuButton( + value: e.value, onChanged: e.onChanged, child: e.child, ffi: ffi)) + .toList(); return _IconSubmenuButton( tooltip: 'Keyboard Settings', svg: "assets/keyboard.svg", @@ -1610,6 +1614,7 @@ class _KeyboardMenu extends StatelessWidget { viewMode(), Divider(), reverseMouseWheel(), + ...toolbarToggles, ]); } diff --git a/src/lang/cn.rs b/src/lang/cn.rs index 417b0fc58..8244351e2 100644 --- a/src/lang/cn.rs +++ b/src/lang/cn.rs @@ -576,7 +576,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("input_source_1_tip", "输入源 1"), ("input_source_2_tip", "输入源 2"), ("capture_display_elevated_connections_tip", "用户提权后,不能显示多个显示器。若要控制多显示器,请安装后再试。"), - ("Swap control-command key", ""), - ("swap-left-right-mouse", ""), + ("Swap control-command key", "交换Control键和Command键"), + ("swap-left-right-mouse", "交换鼠标左右键"), ].iter().cloned().collect(); }