Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions lib/models/settings/client_settings_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,24 @@ class Vector2 {
static Vector2 fromPosition(Offset windowPosition) => Vector2(x: windowPosition.dx, y: windowPosition.dy);
}

Map<GlobalHotKeys, KeyCombination> get _defaultGlobalHotKeys => {
for (var hotKey in GlobalHotKeys.values)
hotKey: switch (hotKey) {
GlobalHotKeys.toggleSideBar => KeyCombination(key: LogicalKeyboardKey.keyQ),
GlobalHotKeys.search =>
KeyCombination(key: LogicalKeyboardKey.keyK, modifier: LogicalKeyboardKey.controlLeft),
GlobalHotKeys.exit => KeyCombination(key: LogicalKeyboardKey.keyQ, modifier: LogicalKeyboardKey.controlLeft),
Map<GlobalHotKeys, KeyCombination> get _defaultGlobalHotKeys => switch (defaultTargetPlatform) {
TargetPlatform.macOS => {
for (var hotKey in GlobalHotKeys.values)
hotKey: switch (hotKey) {
GlobalHotKeys.toggleSideBar => KeyCombination(key: LogicalKeyboardKey.keyQ),
GlobalHotKeys.search =>
KeyCombination(key: LogicalKeyboardKey.keyK, modifier: LogicalKeyboardKey.superKey),
GlobalHotKeys.exit => KeyCombination(key: LogicalKeyboardKey.keyQ, modifier: LogicalKeyboardKey.superKey),
},
},
_ => {
for (var hotKey in GlobalHotKeys.values)
hotKey: switch (hotKey) {
GlobalHotKeys.toggleSideBar => KeyCombination(key: LogicalKeyboardKey.keyQ),
GlobalHotKeys.search =>
KeyCombination(key: LogicalKeyboardKey.keyK, modifier: LogicalKeyboardKey.controlLeft),
GlobalHotKeys.exit =>
KeyCombination(key: LogicalKeyboardKey.keyQ, modifier: LogicalKeyboardKey.controlLeft),
},
}
};
26 changes: 25 additions & 1 deletion lib/models/settings/key_combinations.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:convert';

import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'package:freezed_annotation/freezed_annotation.dart';
Expand Down Expand Up @@ -105,7 +106,30 @@ class LogicalKeyboardSerializer extends JsonConverter<LogicalKeyboardKey, String

extension LogicalKeyExtension on LogicalKeyboardKey {
String get label {
return switch (this) { LogicalKeyboardKey.space => "Space", _ => keyLabel };
return switch (this) {
LogicalKeyboardKey.space => "Space",

// macOS-style modifier symbols
LogicalKeyboardKey.meta ||
LogicalKeyboardKey.metaLeft ||
LogicalKeyboardKey.metaRight ||
LogicalKeyboardKey.superKey =>
defaultTargetPlatform == TargetPlatform.macOS ? "⌘" : "Super",
LogicalKeyboardKey.alt ||
LogicalKeyboardKey.altLeft ||
LogicalKeyboardKey.altRight =>
defaultTargetPlatform == TargetPlatform.macOS ? "⌥" : "Alt",
LogicalKeyboardKey.control ||
LogicalKeyboardKey.controlLeft ||
LogicalKeyboardKey.controlRight =>
defaultTargetPlatform == TargetPlatform.macOS ? "⌃" : "Ctrl",
LogicalKeyboardKey.shift || LogicalKeyboardKey.shiftLeft || LogicalKeyboardKey.shiftRight => "Shift ⇧",
LogicalKeyboardKey.arrowUp => "↑",
LogicalKeyboardKey.arrowDown => "↓",
LogicalKeyboardKey.arrowLeft => "←",
LogicalKeyboardKey.arrowRight => "→",
_ => keyLabel.isNotEmpty ? keyLabel : (debugName ?? ""),
};
}
}

Expand Down
5 changes: 4 additions & 1 deletion lib/screens/settings/widgets/key_listener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,10 @@ class KeyListenerWidgetState extends ConsumerState<KeyListenerWidget> {
),
Text(
currentHotKey?.label ?? "+",
style: Theme.of(context).textTheme.bodyMedium?.copyWith(fontWeight: FontWeight.bold),
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.bold,
fontSize: 15,
),
),
],
),
Expand Down
Loading