mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-05-12 19:06:13 +02:00
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
7 changed files with 91 additions and 93 deletions
|
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_hbb/common.dart';
|
import 'package:flutter_hbb/common.dart';
|
||||||
import 'package:flutter_hbb/consts.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:flutter_hbb/models/platform_model.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
@ -204,3 +205,35 @@ List<Widget> ServerConfigImportExportWidgets(
|
||||||
icon: Icon(Icons.copy, color: Colors.grey), onPressed: export))
|
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 option = 'allow_swap_key';
|
||||||
final value =
|
final value =
|
||||||
bind.sessionGetToggleOptionSync(sessionId: sessionId, arg: option);
|
bind.sessionGetToggleOptionSync(sessionId: sessionId, arg: option);
|
||||||
v.add(TToggleMenu(
|
onChanged(bool? value) {
|
||||||
value: value,
|
|
||||||
onChanged: (value) {
|
|
||||||
if (value == null) return;
|
if (value == null) return;
|
||||||
bind.sessionToggleOption(sessionId: sessionId, value: option);
|
bind.sessionToggleOption(sessionId: sessionId, value: option);
|
||||||
},
|
}
|
||||||
|
|
||||||
|
final enabled = !ffi.ffiModel.viewOnly;
|
||||||
|
v.add(TToggleMenu(
|
||||||
|
value: value,
|
||||||
|
onChanged: enabled ? onChanged : null,
|
||||||
child: Text(translate('Swap control-command key'))));
|
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
|
// swap left right mouse
|
||||||
if (!isMobile && ffiModel.keyboard) {
|
if (ffiModel.keyboard) {
|
||||||
final option = 'swap-left-right-mouse';
|
final option = 'swap-left-right-mouse';
|
||||||
final value =
|
final value =
|
||||||
bind.sessionGetToggleOptionSync(sessionId: sessionId, arg: option);
|
bind.sessionGetToggleOptionSync(sessionId: sessionId, arg: option);
|
||||||
v.add(TToggleMenu(
|
onChanged(bool? value) {
|
||||||
value: value,
|
|
||||||
onChanged: (value) {
|
|
||||||
if (value == null) return;
|
if (value == null) return;
|
||||||
bind.sessionToggleOption(sessionId: sessionId, value: option);
|
bind.sessionToggleOption(sessionId: sessionId, value: option);
|
||||||
},
|
}
|
||||||
|
|
||||||
|
final enabled = !ffi.ffiModel.viewOnly;
|
||||||
|
v.add(TToggleMenu(
|
||||||
|
value: value,
|
||||||
|
onChanged: enabled ? onChanged : null,
|
||||||
child: Text(translate('swap-left-right-mouse'))));
|
child: Text(translate('swap-left-right-mouse'))));
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
|
|
|
@ -1059,8 +1059,7 @@ class _NetworkState extends State<_Network> with AutomaticKeepAliveClientMixin {
|
||||||
// Simple temp wrapper for PR check
|
// Simple temp wrapper for PR check
|
||||||
tmpWrapper() {
|
tmpWrapper() {
|
||||||
// Setting page is not modal, oldOptions should only be used when getting options, never when setting.
|
// Setting page is not modal, oldOptions should only be used when getting options, never when setting.
|
||||||
Map<String, dynamic> oldOptions =
|
Map<String, dynamic> oldOptions = jsonDecode(bind.mainGetOptionsSync());
|
||||||
jsonDecode(bind.mainGetOptionsSync());
|
|
||||||
old(String key) {
|
old(String key) {
|
||||||
return (oldOptions[key] ?? '').trim();
|
return (oldOptions[key] ?? '').trim();
|
||||||
}
|
}
|
||||||
|
@ -1348,28 +1347,8 @@ class _DisplayState extends State<_Display> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget other(BuildContext context) {
|
Widget other(BuildContext context) {
|
||||||
final children = [
|
final children =
|
||||||
otherRow('View Mode', 'view_only'),
|
otherDefaultSettings().map((e) => otherRow(e.$1, e.$2)).toList();
|
||||||
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));
|
|
||||||
}
|
|
||||||
return _Card(title: 'Other Default Options', children: children);
|
return _Card(title: 'Other Default Options', children: children);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1613,7 +1613,6 @@ class _KeyboardMenu extends StatelessWidget {
|
||||||
Divider(),
|
Divider(),
|
||||||
viewMode(),
|
viewMode(),
|
||||||
Divider(),
|
Divider(),
|
||||||
reverseMouseWheel(),
|
|
||||||
...toolbarToggles,
|
...toolbarToggles,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -1738,30 +1737,6 @@ class _KeyboardMenu extends StatelessWidget {
|
||||||
ffi: ffi,
|
ffi: ffi,
|
||||||
child: Text(translate('View Mode')));
|
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 {
|
class _ChatMenu extends StatefulWidget {
|
||||||
|
|
|
@ -789,23 +789,14 @@ class __DisplayPageState extends State<_DisplayPage> {
|
||||||
),
|
),
|
||||||
SettingsSection(
|
SettingsSection(
|
||||||
title: Text(translate('Other Default Options')),
|
title: Text(translate('Other Default Options')),
|
||||||
tiles: [
|
tiles:
|
||||||
otherRow('Show remote cursor', 'show_remote_cursor'),
|
otherDefaultSettings().map((e) => otherRow(e.$1, e.$2)).toList(),
|
||||||
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'),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
otherRow(String label, String key) {
|
SettingsTile otherRow(String label, String key) {
|
||||||
final value = bind.mainGetUserDefaultOption(key: key) == 'Y';
|
final value = bind.mainGetUserDefaultOption(key: key) == 'Y';
|
||||||
return SettingsTile.switchTile(
|
return SettingsTile.switchTile(
|
||||||
initialValue: value,
|
initialValue: value,
|
||||||
|
|
|
@ -1214,26 +1214,19 @@ impl PeerConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_default_options(mp: &mut HashMap<String, String>) {
|
fn insert_default_options(mp: &mut HashMap<String, String>) {
|
||||||
let mut key = "codec-preference";
|
[
|
||||||
if !mp.contains_key(key) {
|
"codec-preference",
|
||||||
mp.insert(key.to_owned(), UserDefaultConfig::read().get(key));
|
"custom-fps",
|
||||||
}
|
"zoom-cursor",
|
||||||
key = "custom-fps";
|
"touch-mode",
|
||||||
if !mp.contains_key(key) {
|
"i444",
|
||||||
mp.insert(key.to_owned(), UserDefaultConfig::read().get(key));
|
"swap-left-right-mouse",
|
||||||
}
|
]
|
||||||
key = "zoom-cursor";
|
.map(|key| {
|
||||||
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) {
|
if !mp.contains_key(key) {
|
||||||
mp.insert(key.to_owned(), UserDefaultConfig::read().get(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> {
|
pub fn session_get_reverse_mouse_wheel_sync(session_id: SessionID) -> SyncReturn<Option<String>> {
|
||||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
let res = if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||||
Some(session.get_reverse_mouse_wheel())
|
Some(session.get_reverse_mouse_wheel())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
};
|
||||||
|
SyncReturn(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn session_set_reverse_mouse_wheel(session_id: SessionID, value: String) {
|
pub fn session_set_reverse_mouse_wheel(session_id: SessionID, value: String) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue