mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-05-08 15:18:13 +03:00
feat(keyboard): shortcuts, color of "Reset to defaults"
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -37,11 +37,14 @@ class _DesktopKeyboardShortcutsPageState
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final foregroundColor =
|
||||||
|
AppBarTheme.of(context).titleTextStyle?.color ?? Colors.white;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(translate('Keyboard Shortcuts')),
|
title: Text(translate('Keyboard Shortcuts')),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton.icon(
|
TextButton.icon(
|
||||||
|
style: TextButton.styleFrom(foregroundColor: foregroundColor),
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
_bodyKey.currentState?.resetToDefaultsWithConfirm(),
|
_bodyKey.currentState?.resetToDefaultsWithConfirm(),
|
||||||
icon: const Icon(Icons.restore),
|
icon: const Icon(Icons.restore),
|
||||||
|
|||||||
@@ -58,6 +58,39 @@ void main() {
|
|||||||
['primary', 'ctrl', 'alt', 'shift']);
|
['primary', 'ctrl', 'alt', 'shift']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('shortcutBindingMapsFrom ignores malformed bindings', () {
|
||||||
|
expect(shortcutBindingMapsFrom('not a list'), isEmpty);
|
||||||
|
|
||||||
|
final bindings = shortcutBindingMapsFrom([
|
||||||
|
{
|
||||||
|
'action': kShortcutActionScreenshot,
|
||||||
|
'mods': ['primary'],
|
||||||
|
'key': 'p',
|
||||||
|
},
|
||||||
|
'bad',
|
||||||
|
1,
|
||||||
|
{
|
||||||
|
'action': kShortcutActionToggleMute,
|
||||||
|
'mods': ['alt'],
|
||||||
|
'key': 's',
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
expect(bindings, hasLength(2));
|
||||||
|
expect(bindings.map((binding) => binding['action']), [
|
||||||
|
kShortcutActionScreenshot,
|
||||||
|
kShortcutActionToggleMute,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('shortcutModSetFrom ignores malformed modifiers', () {
|
||||||
|
expect(shortcutModSetFrom('not a list'), isEmpty);
|
||||||
|
expect(shortcutModSetFrom(['primary', 1, 'alt', null, 'primary']), {
|
||||||
|
'primary',
|
||||||
|
'alt',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('non-desktop defaults exclude desktop-only and tab shortcuts', () {
|
test('non-desktop defaults exclude desktop-only and tab shortcuts', () {
|
||||||
final defaults = [
|
final defaults = [
|
||||||
{
|
{
|
||||||
@@ -85,6 +118,11 @@ void main() {
|
|||||||
'mods': ['primary', 'alt', 'shift'],
|
'mods': ['primary', 'alt', 'shift'],
|
||||||
'key': 'right_bracket',
|
'key': 'right_bracket',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'action': kShortcutActionToggleRelativeMouseMode,
|
||||||
|
'mods': ['primary', 'alt', 'shift'],
|
||||||
|
'key': 'g',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
final filtered = filterDefaultBindingsForPlatform(
|
final filtered = filterDefaultBindingsForPlatform(
|
||||||
@@ -158,6 +196,7 @@ void main() {
|
|||||||
final ids = idSet(groups);
|
final ids = idSet(groups);
|
||||||
// Desktop-only actions are stripped.
|
// Desktop-only actions are stripped.
|
||||||
expect(ids, isNot(contains(kShortcutActionToggleFullscreen)));
|
expect(ids, isNot(contains(kShortcutActionToggleFullscreen)));
|
||||||
|
expect(ids, isNot(contains(kShortcutActionToggleRelativeMouseMode)));
|
||||||
expect(ids, isNot(contains(kShortcutActionScreenshot)));
|
expect(ids, isNot(contains(kShortcutActionScreenshot)));
|
||||||
expect(ids, isNot(contains(kShortcutActionToggleToolbar)));
|
expect(ids, isNot(contains(kShortcutActionToggleToolbar)));
|
||||||
expect(ids, isNot(contains(kShortcutActionCloseTab)));
|
expect(ids, isNot(contains(kShortcutActionCloseTab)));
|
||||||
|
|||||||
Reference in New Issue
Block a user