Skip to content

Commit

Permalink
Improve the look of the keyboard settings tab (#20595)
Browse files Browse the repository at this point in the history
* First cut of new keyboard shortcuts

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>

* i18n

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
  • Loading branch information
SimonBrandner authored Jan 24, 2022
1 parent 06fa4f4 commit 03e776d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 29 deletions.
3 changes: 2 additions & 1 deletion src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"Dismiss": "Dismiss",
"Switch to space by number": "Switch to space by number",
"Open user settings": "Open user settings",
"Previous/next recently visited room or community": "Previous/next recently visited room or community",
"Previous recently visited room or community": "Previous recently visited room or community",

This comment has been minimized.

Copy link
@libexus

libexus Jan 25, 2022

Contributor

@SimonBrandner Sorry for the ping, but is it intentionally "Community" instead of Spaces?

This comment has been minimized.

Copy link
@SimonBrandner

SimonBrandner Jan 25, 2022

Author Contributor

I don't think this shortcut works with spaces and is a leftover from the communities days, so we should probably remove that

I've opened #20755

"Next recently visited room or community": "Next recently visited room or community",
"%(brand)s Desktop (%(platformName)s)": "%(brand)s Desktop (%(platformName)s)",
"Go to your browser to complete Sign In": "Go to your browser to complete Sign In",
"Unknown device": "Unknown device",
Expand Down
62 changes: 34 additions & 28 deletions src/vector/platform/ElectronPlatform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Copyright 2016 Aviral Dasgupta
Copyright 2016 OpenMarket Ltd
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
Copyright 2018 - 2021 New Vector Ltd
Copyright 2022 Šimon Brandner <simon.bra.ag@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,10 +35,8 @@ import Modal from "matrix-react-sdk/src/Modal";
import InfoDialog from "matrix-react-sdk/src/components/views/dialogs/InfoDialog";
import Spinner from "matrix-react-sdk/src/components/views/elements/Spinner";
import {
Categories,
CMD_OR_CTRL,
CategoryName,
DIGITS,
Modifiers,
registerShortcut,
} from "matrix-react-sdk/src/accessibility/KeyboardShortcuts";
import { isOnlyCtrlOrCmdKeyEvent, Key } from "matrix-react-sdk/src/Keyboard";
Expand Down Expand Up @@ -287,43 +286,50 @@ export default class ElectronPlatform extends VectorBasePlatform {
});

// register OS-specific shortcuts
registerShortcut(Categories.NAVIGATION, {
keybinds: [{
modifiers: [CMD_OR_CTRL],
registerShortcut("KeyBinding.switchToSpaceByNumber", CategoryName.NAVIGATION, {
default: {
ctrlOrCmdKey: true,
key: DIGITS,
}],
description: _td("Switch to space by number"),
},
displayName: _td("Switch to space by number"),
});

if (isMac) {
registerShortcut(Categories.NAVIGATION, {
keybinds: [{
modifiers: [Modifiers.COMMAND],
registerShortcut("KeyBinding.openUserSettings", CategoryName.NAVIGATION, {
default: {
commandKey: true,
key: Key.COMMA,
}],
description: _td("Open user settings"),
},
displayName: _td("Open user settings"),
});

registerShortcut(Categories.NAVIGATION, {
keybinds: [{
modifiers: [Modifiers.COMMAND],
registerShortcut("KeyBinding.previousVisitedRoomOrCommunity", CategoryName.NAVIGATION, {
default: {
commandKey: true,
key: Key.SQUARE_BRACKET_LEFT,
}, {
modifiers: [Modifiers.COMMAND],
},
displayName: _td("Previous recently visited room or community"),
});
registerShortcut("KeyBinding.nextVisitedRoomOrCommunity", CategoryName.NAVIGATION, {
default: {
commandKey: true,
key: Key.SQUARE_BRACKET_RIGHT,
}],
description: _td("Previous/next recently visited room or community"),
},
displayName: _td("Next recently visited room or community"),
});
} else {
registerShortcut(Categories.NAVIGATION, {
keybinds: [{
modifiers: [Modifiers.ALT],
registerShortcut("KeyBinding.previousVisitedRoomOrCommunity", CategoryName.NAVIGATION, {
default: {
altKey: true,
key: Key.ARROW_LEFT,
}, {
modifiers: [Modifiers.ALT],
},
displayName: _td("Previous recently visited room or community"),
});
registerShortcut("KeyBinding.nextVisitedRoomOrCommunity", CategoryName.NAVIGATION, {
default: {
altKey: true,
key: Key.ARROW_RIGHT,
}],
description: _td("Previous/next recently visited room or community"),
},
displayName: _td("Next recently visited room or community"),
});
}

Expand Down

0 comments on commit 03e776d

Please sign in to comment.