mobile/desktop use same 'other default settings' (#6652)
1. mobile add 'reverse mouse wheel' default setting 2. change related menu position Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
c061eddf2a
commit
03c8d94024
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_hbb/common.dart';
|
||||
import 'package:flutter_hbb/consts.dart';
|
||||
import 'package:flutter_hbb/models/desktop_render_texture.dart';
|
||||
import 'package:flutter_hbb/models/platform_model.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
@ -204,3 +205,35 @@ List<Widget> ServerConfigImportExportWidgets(
|
||||
icon: Icon(Icons.copy, color: Colors.grey), onPressed: export))
|
||||
];
|
||||
}
|
||||
|
||||
List<(String, String)> otherDefaultSettings() {
|
||||
List<(String, String)> v = [
|
||||
('View Mode', 'view_only'),
|
||||
if (isDesktop) ('show_monitors_tip', kKeyShowMonitorsToolbar),
|
||||
if (isDesktop) ('Collapse toolbar', 'collapse_toolbar'),
|
||||
('Show remote cursor', 'show_remote_cursor'),
|
||||
if (isDesktop) ('Zoom cursor', 'zoom-cursor'),
|
||||
('Show quality monitor', 'show_quality_monitor'),
|
||||
('Mute', 'disable_audio'),
|
||||
if (isDesktop) ('Enable file copy and paste', 'enable_file_transfer'),
|
||||
('Disable clipboard', 'disable_clipboard'),
|
||||
('Lock after session end', 'lock_after_session_end'),
|
||||
('Privacy mode', 'privacy_mode'),
|
||||
if (isMobile) ('Touch mode', 'touch-mode'),
|
||||
('True color (4:4:4)', 'i444'),
|
||||
('Reverse mouse wheel', 'reverse_mouse_wheel'),
|
||||
('swap-left-right-mouse', 'swap-left-right-mouse'),
|
||||
if (isDesktop && useTextureRender)
|
||||
(
|
||||
'Show displays as individual windows',
|
||||
kKeyShowDisplaysAsIndividualWindows
|
||||
),
|
||||
if (isDesktop && useTextureRender)
|
||||
(
|
||||
'Use all my displays for the remote session',
|
||||
kKeyUseAllMyDisplaysForTheRemoteSession
|
||||
)
|
||||
];
|
||||
|
||||
return v;
|
||||
}
|
||||
|
@ -623,26 +623,52 @@ List<TToggleMenu> toolbarKeyboardToggles(FFI ffi) {
|
||||
final option = 'allow_swap_key';
|
||||
final value =
|
||||
bind.sessionGetToggleOptionSync(sessionId: sessionId, arg: option);
|
||||
onChanged(bool? value) {
|
||||
if (value == null) return;
|
||||
bind.sessionToggleOption(sessionId: sessionId, value: option);
|
||||
}
|
||||
|
||||
final enabled = !ffi.ffiModel.viewOnly;
|
||||
v.add(TToggleMenu(
|
||||
value: value,
|
||||
onChanged: (value) {
|
||||
if (value == null) return;
|
||||
bind.sessionToggleOption(sessionId: sessionId, value: option);
|
||||
},
|
||||
onChanged: enabled ? onChanged : null,
|
||||
child: Text(translate('Swap control-command key'))));
|
||||
}
|
||||
|
||||
// reverse mouse wheel
|
||||
if (ffiModel.keyboard) {
|
||||
var optionValue =
|
||||
bind.sessionGetReverseMouseWheelSync(sessionId: sessionId) ?? '';
|
||||
if (optionValue == '') {
|
||||
optionValue = bind.mainGetUserDefaultOption(key: 'reverse_mouse_wheel');
|
||||
}
|
||||
onChanged(bool? value) async {
|
||||
if (value == null) return;
|
||||
await bind.sessionSetReverseMouseWheel(
|
||||
sessionId: sessionId, value: value ? 'Y' : 'N');
|
||||
}
|
||||
|
||||
final enabled = !ffi.ffiModel.viewOnly;
|
||||
v.add(TToggleMenu(
|
||||
value: optionValue == 'Y',
|
||||
onChanged: enabled ? onChanged : null,
|
||||
child: Text(translate('Reverse mouse wheel'))));
|
||||
}
|
||||
|
||||
// swap left right mouse
|
||||
if (!isMobile && ffiModel.keyboard) {
|
||||
if (ffiModel.keyboard) {
|
||||
final option = 'swap-left-right-mouse';
|
||||
final value =
|
||||
bind.sessionGetToggleOptionSync(sessionId: sessionId, arg: option);
|
||||
onChanged(bool? value) {
|
||||
if (value == null) return;
|
||||
bind.sessionToggleOption(sessionId: sessionId, value: option);
|
||||
}
|
||||
|
||||
final enabled = !ffi.ffiModel.viewOnly;
|
||||
v.add(TToggleMenu(
|
||||
value: value,
|
||||
onChanged: (value) {
|
||||
if (value == null) return;
|
||||
bind.sessionToggleOption(sessionId: sessionId, value: option);
|
||||
},
|
||||
onChanged: enabled ? onChanged : null,
|
||||
child: Text(translate('swap-left-right-mouse'))));
|
||||
}
|
||||
return v;
|
||||
|
@ -1059,8 +1059,7 @@ class _NetworkState extends State<_Network> with AutomaticKeepAliveClientMixin {
|
||||
// Simple temp wrapper for PR check
|
||||
tmpWrapper() {
|
||||
// Setting page is not modal, oldOptions should only be used when getting options, never when setting.
|
||||
Map<String, dynamic> oldOptions =
|
||||
jsonDecode(bind.mainGetOptionsSync());
|
||||
Map<String, dynamic> oldOptions = jsonDecode(bind.mainGetOptionsSync());
|
||||
old(String key) {
|
||||
return (oldOptions[key] ?? '').trim();
|
||||
}
|
||||
@ -1348,28 +1347,8 @@ class _DisplayState extends State<_Display> {
|
||||
}
|
||||
|
||||
Widget other(BuildContext context) {
|
||||
final children = [
|
||||
otherRow('View Mode', 'view_only'),
|
||||
otherRow('show_monitors_tip', kKeyShowMonitorsToolbar),
|
||||
otherRow('Collapse toolbar', 'collapse_toolbar'),
|
||||
otherRow('Show remote cursor', 'show_remote_cursor'),
|
||||
otherRow('Zoom cursor', 'zoom-cursor'),
|
||||
otherRow('Show quality monitor', 'show_quality_monitor'),
|
||||
otherRow('Mute', 'disable_audio'),
|
||||
otherRow('Enable file copy and paste', 'enable_file_transfer'),
|
||||
otherRow('Disable clipboard', 'disable_clipboard'),
|
||||
otherRow('Lock after session end', 'lock_after_session_end'),
|
||||
otherRow('Privacy mode', 'privacy_mode'),
|
||||
otherRow('Reverse mouse wheel', 'reverse_mouse_wheel'),
|
||||
otherRow('True color (4:4:4)', 'i444'),
|
||||
otherRow('swap-left-right-mouse', 'swap-left-right-mouse'),
|
||||
];
|
||||
if (useTextureRender) {
|
||||
children.add(otherRow('Show displays as individual windows',
|
||||
kKeyShowDisplaysAsIndividualWindows));
|
||||
children.add(otherRow('Use all my displays for the remote session',
|
||||
kKeyUseAllMyDisplaysForTheRemoteSession));
|
||||
}
|
||||
final children =
|
||||
otherDefaultSettings().map((e) => otherRow(e.$1, e.$2)).toList();
|
||||
return _Card(title: 'Other Default Options', children: children);
|
||||
}
|
||||
}
|
||||
|
@ -1613,7 +1613,6 @@ class _KeyboardMenu extends StatelessWidget {
|
||||
Divider(),
|
||||
viewMode(),
|
||||
Divider(),
|
||||
reverseMouseWheel(),
|
||||
...toolbarToggles,
|
||||
]);
|
||||
}
|
||||
@ -1738,30 +1737,6 @@ class _KeyboardMenu extends StatelessWidget {
|
||||
ffi: ffi,
|
||||
child: Text(translate('View Mode')));
|
||||
}
|
||||
|
||||
reverseMouseWheel() {
|
||||
return futureBuilder(future: () async {
|
||||
final v =
|
||||
await bind.sessionGetReverseMouseWheel(sessionId: ffi.sessionId);
|
||||
if (v != null && v != '') {
|
||||
return v;
|
||||
}
|
||||
return bind.mainGetUserDefaultOption(key: 'reverse_mouse_wheel');
|
||||
}(), hasData: (data) {
|
||||
final enabled = !ffi.ffiModel.viewOnly;
|
||||
onChanged(bool? value) async {
|
||||
if (value == null) return;
|
||||
await bind.sessionSetReverseMouseWheel(
|
||||
sessionId: ffi.sessionId, value: value ? 'Y' : 'N');
|
||||
}
|
||||
|
||||
return CkbMenuButton(
|
||||
value: data == 'Y',
|
||||
onChanged: enabled ? onChanged : null,
|
||||
child: Text(translate('Reverse mouse wheel')),
|
||||
ffi: ffi);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class _ChatMenu extends StatefulWidget {
|
||||
|
@ -789,23 +789,14 @@ class __DisplayPageState extends State<_DisplayPage> {
|
||||
),
|
||||
SettingsSection(
|
||||
title: Text(translate('Other Default Options')),
|
||||
tiles: [
|
||||
otherRow('Show remote cursor', 'show_remote_cursor'),
|
||||
otherRow('Show quality monitor', 'show_quality_monitor'),
|
||||
otherRow('Mute', 'disable_audio'),
|
||||
otherRow('Disable clipboard', 'disable_clipboard'),
|
||||
otherRow('Lock after session end', 'lock_after_session_end'),
|
||||
otherRow('Privacy mode', 'privacy_mode'),
|
||||
otherRow('Touch mode', 'touch-mode'),
|
||||
otherRow('True color (4:4:4)', 'i444'),
|
||||
otherRow('swap-left-right-mouse', 'swap-left-right-mouse'),
|
||||
],
|
||||
tiles:
|
||||
otherDefaultSettings().map((e) => otherRow(e.$1, e.$2)).toList(),
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
otherRow(String label, String key) {
|
||||
SettingsTile otherRow(String label, String key) {
|
||||
final value = bind.mainGetUserDefaultOption(key: key) == 'Y';
|
||||
return SettingsTile.switchTile(
|
||||
initialValue: value,
|
||||
|
@ -1214,26 +1214,19 @@ impl PeerConfig {
|
||||
}
|
||||
|
||||
fn insert_default_options(mp: &mut HashMap<String, String>) {
|
||||
let mut key = "codec-preference";
|
||||
if !mp.contains_key(key) {
|
||||
mp.insert(key.to_owned(), UserDefaultConfig::read().get(key));
|
||||
}
|
||||
key = "custom-fps";
|
||||
if !mp.contains_key(key) {
|
||||
mp.insert(key.to_owned(), UserDefaultConfig::read().get(key));
|
||||
}
|
||||
key = "zoom-cursor";
|
||||
if !mp.contains_key(key) {
|
||||
mp.insert(key.to_owned(), UserDefaultConfig::read().get(key));
|
||||
}
|
||||
key = "touch-mode";
|
||||
if !mp.contains_key(key) {
|
||||
mp.insert(key.to_owned(), UserDefaultConfig::read().get(key));
|
||||
}
|
||||
key = "i444";
|
||||
if !mp.contains_key(key) {
|
||||
mp.insert(key.to_owned(), UserDefaultConfig::read().get(key));
|
||||
}
|
||||
[
|
||||
"codec-preference",
|
||||
"custom-fps",
|
||||
"zoom-cursor",
|
||||
"touch-mode",
|
||||
"i444",
|
||||
"swap-left-right-mouse",
|
||||
]
|
||||
.map(|key| {
|
||||
if !mp.contains_key(key) {
|
||||
mp.insert(key.to_owned(), UserDefaultConfig::read().get(key));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -340,12 +340,13 @@ pub fn session_set_keyboard_mode(session_id: SessionID, value: String) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_get_reverse_mouse_wheel(session_id: SessionID) -> Option<String> {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
pub fn session_get_reverse_mouse_wheel_sync(session_id: SessionID) -> SyncReturn<Option<String>> {
|
||||
let res = if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
Some(session.get_reverse_mouse_wheel())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
SyncReturn(res)
|
||||
}
|
||||
|
||||
pub fn session_set_reverse_mouse_wheel(session_id: SessionID, value: String) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user