Skip to content

TagSpaces is an offline, open source, document manager with tagging support

chore: improving key bindings

Ilian Sapundshieve99716efaaea
diff --git a/src/main/electron-tray-menu.ts b/src/main/electron-tray-menu.ts
index af320004a..813790dc5 100644
--- a/src/main/electron-tray-menu.ts
+++ b/src/main/electron-tray-menu.ts
@@ -30,7 +30,9 @@ const icon2xWhite =
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAACXBIWXMAAACjAAAAowHwx5rOAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAA+FJREFUWIW1mV2IVVUUx/93ZjLTCDM0sDIqKY2G7AMq+0ChlCh8GAkCwUj7xPKhD4ueBgp6KRA0iKSggsAHw/BxqCfJIEoxMjKRKCU11KwpR7vdXw9rTnPuae919pm75w+HuXPOXmv/zt5rr732vS1AU6B+SdskrcrlsC+Xo5JakrYqI6Q0NaBvSXo0t9PcoK9LejqzT0l5QTdKejmjvy61Mi2mJyS9LYvPkL6T9Feir0WSZvzvLtDrNQS0iet9oK+Bv69CTnqd+uWSPpKlo5B2SFonqVO615K0QNLtkmYm99TDSC4BRp2RHAHOr9jcAOwptRkDXkwZ0clCLgZOOZC7gQsrNrOAnyvtOuN/H5sK0GuBow7kPuDigN2TkfYd4Ps60KYxeoWkEUmXRp4flMXtqcCzhRGbImYHvI6bgM6VQc6PPD8s6T5JR0v3zit9PhCxQ9IhSW2398TpnkX3IqjqOLCoYtMPbAfeAwaA2cAvgWkHWF839SmQM4BdDuRvwM0Bu82lNjuAC4BbgP2l++eAYaDVK+h04FMH8k/gzoDdcKDtbuASbHRvBO7FRjkp4XuQA+MjEdNZYEXA7jbH5hvgMqfPO4jk5phBH/Ch02EbeMixfxb4J2J7BBgM2NyKhVFQsY42xwywBbDOsS2uIeBMxMdJ4K5S28XACafPQ6EOXnMMAF5IgCxmZRnxUToDrAKuw99AfgKuqjrfUAM5nAi5EfgEyxiDwOGIv7bzIoy/wEKgK48+wkReC2lLIuTDTMTnF8Ac4GrggOM7pGPA9YXfcjx5NeUHpNWUS7GKqKwfgGuw1PR5IuSvWKX1n28B92OpJqaPsVRVBzmbeEV1BMudM4HPaiBPYIury3+fpKckTXN22YskTXf3YdNJSWsljQWezZO0S9JKWWET02lJKyTtDe3104BtNW/5JRZrKTG61BlZbw2MAnfH/BYf+oF3amC/BS5PAJ2Dv9JjkPd4fsv/tAjv0WX9iBXOMYfrsWS+BJgH7E2AHMPWiTsAoZsb8KfoGHBTwG41E2lpFKsD5gO/O77OAg/UQcZABawB/nY6+AOrfor2D2IlWxViP3GdA1amQHqgGncS26vBpmwIy68pU1xWG9sYkiDrQIsVfLqmw7XAXODrBpCrm0CmgAorv447HXeA57HjsVdkF20fbwqZCipsz62eyat6FStEskM2ARVwJXb+now6dB/gphRUNIvFsp7rBXIyoMJicaQB5Cu9Qk4WVNjRd2cC5HAOyF5AhdUH7zqQb+aC7BVUWH3wRgByU07IHKDF9VIJcivd33xkuXJ9hy9Jz0galBXi2X9l+xc7opIKau8a2gAAAABJRU5ErkJggg==';
export default function buildTrayIconMenu(mainPageProps: any, i18n, isMacLike) {
- const cKey = isMacLike ? ' - ⌘' : ' - Ctrl';
+ const cKey = isMacLike ? ' - ⌘' : 'Ctrl';
+ const sKey = isMacLike ? '⇧' : 'Shift';
+ const pKey = isMacLike ? ' ' : ' + ';
function openNextFile() {
mainPageProps.openNextFile();
@@ -57,43 +59,44 @@ export default function buildTrayIconMenu(mainPageProps: any, i18n, isMacLike) {
type: 'separator',
},
{
- label: i18n.t('showTagSpaces') + cKey + '+Shift+W',
+ label: i18n.t('showTagSpaces') + cKey + pKey + sKey + pKey + 'W',
+ accelerator: 'Terd',
click: mainPageProps.showTagSpaces,
},
{
- label: i18n.t('showSearch') + cKey + '+Shift+F',
+ label: i18n.t('showSearch') + cKey + pKey + sKey + pKey + 'F',
click: mainPageProps.openSearch,
},
{
type: 'separator',
},
{
- label: i18n.t('newFileNote') + cKey + '+Shift+N',
+ label: i18n.t('newFileNote') + cKey + pKey + sKey + pKey + 'N',
click: mainPageProps.toggleNewFileDialog,
},
{
type: 'separator',
},
{
- label: i18n.t('openNextFileTooltip') + cKey + '+Shift+D',
+ label: i18n.t('openNextFileTooltip') + cKey + pKey + sKey + pKey + 'D',
click: openNextFile,
},
{
- label: i18n.t('openPrevFileTooltip') + cKey + '+Shift+A',
+ label: i18n.t('openPrevFileTooltip') + cKey + pKey + sKey + pKey + 'A',
click: openPrevFile,
},
{
type: 'separator',
},
{
- label: i18n.t('pauseResumePlayback') + cKey + '+Shift+P',
+ label: i18n.t('pauseResumePlayback') + cKey + pKey + sKey + pKey + 'P',
click: playResumePlayback,
},
{
type: 'separator',
},
{
- label: i18n.t('quitTagSpaces') + cKey + '+Q',
+ label: i18n.t('quitTagSpaces') + cKey + pKey + 'Q',
click: quitApp,
},
];
diff --git a/src/renderer/components/EntryContainer.tsx b/src/renderer/components/EntryContainer.tsx
index 72e9a95f7..d619bf699 100644
--- a/src/renderer/components/EntryContainer.tsx
+++ b/src/renderer/components/EntryContainer.tsx
@@ -747,7 +747,7 @@ function EntryContainer() {
title={
t('core:saveFile') +
' (' +
- (AppConfig.isMaclike ? '⌘' : 'CTRL') +
+ (AppConfig.isMacLike ? '⌘' : 'CTRL') +
' + S)'
}
>
diff --git a/src/renderer/components/FolderContainer.tsx b/src/renderer/components/FolderContainer.tsx
index c927a9219..187383bec 100644
--- a/src/renderer/components/FolderContainer.tsx
+++ b/src/renderer/components/FolderContainer.tsx
@@ -210,7 +210,7 @@ function FolderContainer(props: Props) {
};
const openSearchKeyBinding = AppConfig.isElectron
- ? ' (' + (AppConfig.isMaclike ? '⌘' : 'Ctrl') + '+Shift+F)'
+ ? ' (' + (AppConfig.isMacLike ? '⌘' : 'Ctrl') + '+Shift+F)'
: '';
// keyBindings['openSearch'].toUpperCase()
diff --git a/src/renderer/components/menus/FileMenu.tsx b/src/renderer/components/menus/FileMenu.tsx
index f96d59c11..144a1234b 100644
--- a/src/renderer/components/menus/FileMenu.tsx
+++ b/src/renderer/components/menus/FileMenu.tsx
@@ -49,6 +49,7 @@ import {
setFolderBackgroundPromise,
getRelativeEntryPath,
} from '-/services/utils-io';
+import { getKeyBindingObject } from '-/reducers/settings';
import { Pro } from '-/pro';
import { actions as AppActions, AppDispatch } from '-/reducers/app';
import { useSelector, useDispatch } from 'react-redux';
@@ -70,6 +71,7 @@ import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useNotificationContext } from '-/hooks/useNotificationContext';
import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
import { usePlatformFacadeContext } from '-/hooks/usePlatformFacadeContext';
+import MenuKeyBinding from '-/components/menus/MenuKeyBinding';
interface Props {
anchorEl: Element;
@@ -106,6 +108,7 @@ function FileMenu(props: Props) {
selectedFilePath,
} = props;
+ const keyBindings = useSelector(getKeyBindingObject);
const { t } = useTranslation();
const dispatch: AppDispatch = useDispatch();
const { selectedEntries } = useSelectedEntriesContext();
@@ -405,6 +408,7 @@ function FileMenu(props: Props) {
<AddRemoveTags />
</ListItemIcon>
<ListItemText primary={t('core:addRemoveTags')} />
+ <MenuKeyBinding keyBinding={keyBindings['addRemoveTags']} />
</MenuItem>,
);
if (reorderTop) {
@@ -452,6 +456,7 @@ function FileMenu(props: Props) {
<RenameFile />
</ListItemIcon>
<ListItemText primary={t('core:renameFile')} />
+ <MenuKeyBinding keyBinding={keyBindings['renameFile']} />
</MenuItem>,
);
if (selectedEntries.length < 2) {
diff --git a/src/renderer/components/menus/MenuKeyBinding.tsx b/src/renderer/components/menus/MenuKeyBinding.tsx
new file mode 100644
index 000000000..0ad14d966
--- /dev/null
+++ b/src/renderer/components/menus/MenuKeyBinding.tsx
@@ -0,0 +1,48 @@
+/**
+ * TagSpaces - universal file and folder organizer
+ * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License (version 3) as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+import React from 'react';
+import Typography from '@mui/material/Typography';
+import AppConfig from '-/AppConfig';
+
+interface Props {
+ keyBinding?: string;
+}
+
+function MenuKeyBinding(props: Props) {
+ let adjKB = props.keyBinding;
+ if (AppConfig.isMacLike) {
+ adjKB = adjKB
+ .replace('+', ' ')
+ .replace('command', '⌘')
+ .replace('shift', '');
+ } else {
+ adjKB = adjKB.replace('+', ' + ');
+ }
+ return (
+ <Typography
+ variant="body2"
+ color="text.secondary"
+ style={{ textTransform: 'uppercase' }}
+ >
+ {adjKB}
+ </Typography>
+ );
+}
+
+export default MenuKeyBinding;
diff --git a/src/renderer/perspectives/common/DirectoryMenuItems.tsx b/src/renderer/perspectives/common/DirectoryMenuItems.tsx
index 02f4ab461..769e9ecce 100644
--- a/src/renderer/perspectives/common/DirectoryMenuItems.tsx
+++ b/src/renderer/perspectives/common/DirectoryMenuItems.tsx
@@ -1,4 +1,5 @@
import React from 'react';
+import { useSelector } from 'react-redux';
import MenuItem from '@mui/material/MenuItem';
import ListItemIcon from '@mui/material/ListItemIcon';
import OpenFolderIcon from '@mui/icons-material/SubdirectoryArrowLeft';
@@ -26,6 +27,8 @@ import {
NewFolderIcon,
AddExistingFileIcon,
} from '-/components/CommonIcons';
+import { getKeyBindingObject } from '-/reducers/settings';
+import MenuKeyBinding from '-/components/menus/MenuKeyBinding';
import { TS } from '-/tagspaces.namespace';
export function getDirectoryMenuItems(
@@ -54,6 +57,7 @@ export function getDirectoryMenuItems(
showAddRemoveTagsDialog?: () => void,
openInNewWindow?: () => void,
) {
+ const keyBindings = useSelector(getKeyBindingObject);
const menuItems = [];
if (selectedEntriesLength < 2) {
if (perspectiveMode) {
@@ -122,6 +126,7 @@ export function getDirectoryMenuItems(
<RenameFolderIcon />
</ListItemIcon>
<ListItemText primary={t('core:renameDirectory')} />
+ <MenuKeyBinding keyBinding={keyBindings['renameFile']} />
</MenuItem>,
);
}
diff --git a/src/renderer/perspectives/grid-perspective/components/MainToolbar.tsx b/src/renderer/perspectives/grid-perspective/components/MainToolbar.tsx
index 056eba6df..154dd8249 100644
--- a/src/renderer/perspectives/grid-perspective/components/MainToolbar.tsx
+++ b/src/renderer/perspectives/grid-perspective/components/MainToolbar.tsx
@@ -96,7 +96,10 @@ function MainToolbar(props: Props) {
title={
t('core:navigateToParentDirectory') +
' (' +
- keyBindings['openParentDirectory'].toUpperCase() +
+ keyBindings['openParentDirectory']
+ .replace('command', '⌘')
+ .replace('+', ' + ')
+ .toUpperCase() +
')'
}
>
@@ -119,7 +122,10 @@ function MainToolbar(props: Props) {
title={
t('core:toggleSelectAllFiles') +
' (' +
- keyBindings['selectAll'].toUpperCase() +
+ keyBindings['selectAll']
+ .replace('command', '⌘')
+ .replace('+', ' + ')
+ .toUpperCase() +
')'
}
>
@@ -146,7 +152,10 @@ function MainToolbar(props: Props) {
title={
t('core:tagSelectedEntries') +
' (' +
- keyBindings['addRemoveTags'].toUpperCase() +
+ keyBindings['addRemoveTags']
+ .replace('command', '⌘')
+ .replace('+', ' + ')
+ .toUpperCase() +
')'
}
>