TagSpaces is an offline, open source, document manager with tagging support
chore: enhancing tooltip with keybinding capabilty
Ilian Sapundshiev64df1170f7e2
diff --git a/src/main/electron-menus.ts b/src/main/electron-menus.tsindex 8ea9f2026..9e7d52d0c 100644--- a/src/main/electron-menus.ts+++ b/src/main/electron-menus.ts@@ -203,7 +203,10 @@ export default function buildDesktopMenu(props: any, i18n) {{label: '&' + i18n.t('documentation'),accelerator: 'F1',- click: props.openHelpFeedbackPanel,+ click: () => {+ shell.openExternal(Links.documentationLinks.general);+ },+ //props.openHelpFeedbackPanel,},{label: '&' + i18n.t('shortcutKeys'),diff --git a/src/renderer/components/EntryContainerNav.tsx b/src/renderer/components/EntryContainerNav.tsxindex ed408eaae..23fa11273 100644--- a/src/renderer/components/EntryContainerNav.tsx+++ b/src/renderer/components/EntryContainerNav.tsx@@ -1,10 +1,11 @@import React from 'react';import { useSelector } from 'react-redux';import { useTheme } from '@mui/material/styles';-import { IconButton, Tooltip } from '@mui/material';+import { IconButton } from '@mui/material';import CloseIcon from '@mui/icons-material/Close';import PrevDocumentIcon from '@mui/icons-material/KeyboardArrowUp';import NextDocumentIcon from '@mui/icons-material/KeyboardArrowDown';+import Tooltip from '-/components/Tooltip';import { useTranslation } from 'react-i18next';import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';import { getKeyBindingObject } from '-/reducers/settings';@@ -36,12 +37,8 @@ function EntryContainerNav(props: Props) {{isFile && (<><Tooltip- title={- t('core:openPrevFileTooltip') +- ' (' +- adjustKeyBinding(keyBindings['prevDocument']) +- ')'- }+ title={t('core:openPrevFileTooltip')}+ keyBinding={keyBindings['prevDocument']}><IconButtonaria-label={t('core:openPrevFileTooltip')}@@ -53,12 +50,8 @@ function EntryContainerNav(props: Props) {</IconButton></Tooltip><Tooltip- title={- t('core:openNextFileTooltip') +- ' (' +- adjustKeyBinding(keyBindings['nextDocument']) +- ')'- }+ title={t('core:openNextFileTooltip')}+ keyBinding={keyBindings['nextDocument']}><IconButtonaria-label={t('core:openNextFileTooltip')}@@ -72,12 +65,8 @@ function EntryContainerNav(props: Props) {</>)}<Tooltip- title={- t('core:closeEntry') +- ' (' +- adjustKeyBinding(keyBindings['closeViewer']) +- ')'- }+ title={t('core:closeEntry')}+ keyBinding={keyBindings['closeViewer']}><IconButtononClick={startClosingEntry}diff --git a/src/renderer/components/MobileNavigation.tsx b/src/renderer/components/MobileNavigation.tsxindex 32af8c56d..3a1309653 100644--- a/src/renderer/components/MobileNavigation.tsx+++ b/src/renderer/components/MobileNavigation.tsx@@ -31,16 +31,13 @@ import ThemingIcon from '@mui/icons-material/InvertColors';import TagLibraryIcon from '@mui/icons-material/LocalOfferOutlined';import RecentThingsIcon from '@mui/icons-material/BookmarksOutlined';import HelpIcon from '@mui/icons-material/HelpOutline';-import OpenInNewIcon from '@mui/icons-material/OpenInNew';import { Divider } from '@mui/material';import {OpenNewWindowIcon,- LinkIcon,AudioRecordIcon,NewFileIcon,NewFolderIcon,LocalLocationIcon,- AddExistingFileIcon,} from '-/components/CommonIcons';import AccountCircleIcon from '@mui/icons-material/AccountCircle';import SettingsIcon from '@mui/icons-material/Settings';@@ -77,6 +74,7 @@ import UserDetailsPopover from '-/components/UserDetailsPopover';import PlatformIO from '-/services/platform-facade';import AppConfig from '-/AppConfig';import { useTranslation } from 'react-i18next';+import { getKeyBindingObject } from '-/reducers/settings';const PREFIX = 'MobileNavigation';@@ -88,7 +86,7 @@ const classes = {const Root = styled(Box)(({ theme }) => ({[`& .${classes.button}`]: {position: 'relative',- padding: '11px', // '8px 12px 6px 8px',+ // padding: '8px', // '8px 12px 6px 8px',margin: '0',},[`& .${classes.selectedButton}`]: {@@ -105,6 +103,7 @@ function MobileNavigation(props: Props) {const { t } = useTranslation();const dispatch: AppDispatch = useDispatch();+ const keyBindings = useSelector(getKeyBindingObject);const isLocationManagerPanelOpenedSelector = useSelector(isLocationManagerPanelOpened,);@@ -372,9 +371,13 @@ function MobileNavigation(props: Props) {</IconButton></Tooltip><ToggleButtonGroup exclusive>- <Tooltip title={t('core:locationManager')}>+ <Tooltip+ title={t('core:locationManager')}+ keyBinding={keyBindings['showLocationManager']}+ ><ToggleButtononClick={openLocationManagerPanel}+ size="small"className={isLocationManagerPanelOpenedSelector? classNames(classes.button, classes.selectedButton)@@ -386,10 +389,14 @@ function MobileNavigation(props: Props) {<LocalLocationIcon /></ToggleButton></Tooltip>- <Tooltip title={t('core:tagLibrary')}>+ <Tooltip+ title={t('core:tagLibrary')}+ keyBinding={keyBindings['showTagLibrary']}+ ><ToggleButtondata-tid="tagLibrary"onClick={openTagLibraryPanel}+ size="small"className={isTagLibraryPanelOpenedSelector? classNames(classes.button, classes.selectedButton)@@ -403,6 +410,7 @@ function MobileNavigation(props: Props) {<Tooltip title={t('core:quickAccess')}><ToggleButtondata-tid="quickAccessButton"+ size="small"onClick={openSearchPanel}className={isSearchPanelOpenedSelector@@ -418,6 +426,7 @@ function MobileNavigation(props: Props) {<ToggleButtondata-tid="helpFeedback"onClick={openHelpFeedbackPanel}+ size="small"className={isHelpFeedbackPanelOpenedSelector? classNames(classes.button, classes.selectedButton)diff --git a/src/renderer/components/Tooltip.tsx b/src/renderer/components/Tooltip.tsxindex c9829cecb..512153eff 100644--- a/src/renderer/components/Tooltip.tsx+++ b/src/renderer/components/Tooltip.tsx@@ -18,9 +18,11 @@import React from 'react';import Tooltip from '@mui/material/Tooltip';+import { adjustKeyBinding } from '-/components/dialogs/KeyboardDialog';interface Props {title: any;+ keyBinding?: string;children: any;classes?: any;placement?:@@ -39,14 +41,18 @@ interface Props {}function TooltipTS(props: Props) {- const { title, placement } = props;+ const { title, placement, keyBinding } = props;+ let tooltipText = title;+ if (keyBinding) {+ tooltipText = title + ' (' + adjustKeyBinding(keyBinding) + ')';+ }return (<Tooltip+ {...props}arrow- title={title}+ title={tooltipText}disableInteractiveplacement="top"- {...props}/>);}diff --git a/src/renderer/components/menus/FileMenu.tsx b/src/renderer/components/menus/FileMenu.tsxindex 70f2cc3cb..e92b601cb 100644--- a/src/renderer/components/menus/FileMenu.tsx+++ b/src/renderer/components/menus/FileMenu.tsx@@ -116,8 +116,7 @@ function FileMenu(props: Props) {const { openEntry } = useOpenedEntryContext();const { openDirectory, currentLocationPath } = useDirectoryContentContext();const { showNotification } = useNotificationContext();- const { copyFilePromise, setFolderThumbnailPromise } =- usePlatformFacadeContext();+ const { setFolderThumbnailPromise } = usePlatformFacadeContext();const { currentLocation, readOnlyMode } = useCurrentLocationContext();//const locations: Array<TS.Location> = useSelector(getLocations);const { openFileNatively, duplicateFile } = useFsActionsContext();diff --git a/src/renderer/perspectives/grid-perspective/components/MainToolbar.tsx b/src/renderer/perspectives/grid-perspective/components/MainToolbar.tsxindex 3ea7cdc35..0c5334872 100644--- a/src/renderer/perspectives/grid-perspective/components/MainToolbar.tsx+++ b/src/renderer/perspectives/grid-perspective/components/MainToolbar.tsx@@ -37,7 +37,6 @@ import AppConfig from '-/AppConfig';import { Pro } from '-/pro';import { ProTooltip } from '-/components/HelperComponents';import { getKeyBindingObject } from '-/reducers/settings';-import { TS } from '-/tagspaces.namespace';import { actions as AppActions, AppDispatch } from '-/reducers/app';import {classes,@@ -47,9 +46,7 @@ import { useTranslation } from 'react-i18next';import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';-import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';-import { adjustKeyBinding } from '-/components/dialogs/KeyboardDialog';interface Props {prefixDataTID?: string;@@ -94,12 +91,8 @@ function MainToolbar(props: Props) {data-tid={prefixDataTID + 'perspectiveToolbar'}><Tooltip- title={- t('core:navigateToParentDirectory') +- ' (' +- adjustKeyBinding(keyBindings['openParentDirectory']) +- ')'- }+ title={t('core:navigateToParentDirectory')}+ keyBinding={keyBindings['openParentDirectory']}><IconButtonaria-label={t('core:navigateToParentDirectory')}@@ -117,12 +110,8 @@ function MainToolbar(props: Props) {</IconButton></Tooltip><Tooltip- title={- t('core:toggleSelectAllFiles') +- ' (' +- adjustKeyBinding(keyBindings['selectAll']) +- ')'- }+ title={t('core:toggleSelectAllFiles')}+ keyBinding={keyBindings['selectAll']}><IconButtondata-tid={prefixDataTID + 'PerspectiveSelectAllFiles'}@@ -144,12 +133,8 @@ function MainToolbar(props: Props) {</Tooltip>{!readOnlyMode && (<Tooltip- title={- t('core:tagSelectedEntries') +- ' (' +- adjustKeyBinding(keyBindings['addRemoveTags']) +- ')'- }+ title={t('core:tagSelectedEntries')}+ keyBinding={keyBindings['addRemoveTags']}><span><IconButton@@ -166,12 +151,8 @@ function MainToolbar(props: Props) {)}{!readOnlyMode && (<Tooltip- title={- t('core:copyMoveSelectedEntries') +- ' (' +- adjustKeyBinding(keyBindings['copyMoveSelectedEntries']) +- ')'- }+ title={t('core:copyMoveSelectedEntries')}+ keyBinding={keyBindings['copyMoveSelectedEntries']}><span><IconButton@@ -188,12 +169,8 @@ function MainToolbar(props: Props) {)}{!readOnlyMode && (<Tooltip- title={- t('core:deleteSelectedEntries') +- ' (' +- keyBindings['deleteDocument'].toUpperCase() +- ')'- }+ title={t('core:deleteSelectedEntries')}+ keyBinding={keyBindings['deleteDocument']}><span><IconButton