TagSpaces is an offline, open source, document manager with tagging support
adjusting key bindings
Ilian Sapundshiev4389b542f8da
diff --git a/app/components/EntryContainer.js b/app/components/EntryContainer.jsindex 3e25d63b8..71b7dd420 100644--- a/app/components/EntryContainer.js+++ b/app/components/EntryContainer.js@@ -20,6 +20,7 @@import React from 'react';import { connect } from 'react-redux';import { bindActionCreators } from 'redux';+import { HotKeys } from 'react-hotkeys';import Button from '@material-ui/core/Button';import IconButton from '@material-ui/core/IconButton';import EditIcon from '@material-ui/icons/Edit';@@ -401,9 +402,21 @@ class EntryContainer extends React.Component<Props, State> {}};+ reloadDocument = () => {+ const { currentEntry } = this.state;+ this.setState({+ currentEntry: {+ ...currentEntry,+ shouldReload: true+ }+ });+ }+startClosingFile = (event) => {- event.preventDefault(); // Let's stop this event.- event.stopPropagation();+ if (event) {+ event.preventDefault(); // Let's stop this event.+ event.stopPropagation();+ }if (this.state.currentEntry && this.state.currentEntry.changed) {this.setState({ isSaveBeforeCloseConfirmDialogOpened: true });} else {@@ -640,15 +653,7 @@ class EntryContainer extends React.Component<Props, State> {<IconButtontitle={i18n.t('core:reloadFile')}aria-label={i18n.t('core:reloadFile')}- onClick={() => {- const { currentEntry } = this.state;- this.setState({- currentEntry: {- ...currentEntry,- shouldReload: true- }- });- }}+ onClick={this.reloadDocument}><RefreshIcon /></IconButton>@@ -703,15 +708,7 @@ class EntryContainer extends React.Component<Props, State> {<IconButtontitle={i18n.t('core:reloadDirectory')}aria-label={i18n.t('core:reloadDirectory')}- onClick={() => {- const { currentEntry } = this.state;- this.setState({- currentEntry: {- ...currentEntry,- shouldReload: true- }- });- }}+ onClick={this.reloadDocument}><RefreshIcon /></IconButton>@@ -756,6 +753,13 @@ class EntryContainer extends React.Component<Props, State> {);};+ keyBindingHandlers = {+ closeViewer: this.startClosingFile,+ saveDocument: this.startSavingFile,+ editDocument: this.editFile,+ reloadDocument: this.reloadDocument,+ };+render() {const { classes } = this.props;const { isEditTagsModalOpened, currentEntry, isFullscreen } = this.state;@@ -789,7 +793,7 @@ class EntryContainer extends React.Component<Props, State> {}return (- <div>+ <HotKeys handlers={this.keyBindingHandlers}><ConfirmDialogopen={this.state.isSaveBeforeCloseConfirmDialogOpened}onClose={() => {@@ -977,7 +981,7 @@ class EntryContainer extends React.Component<Props, State> {{this.renderFileView(fileOpenerURL)}</div></SplitPane>- </div>+ </HotKeys>);}}diff --git a/app/components/FolderContainer.js b/app/components/FolderContainer.jsindex d67d9ceb1..2ff46b90e 100644--- a/app/components/FolderContainer.js+++ b/app/components/FolderContainer.js@@ -216,6 +216,36 @@ class FolderContainer extends React.Component<Props, State> {});},+ deleteDocument: () => {+ this.setState(+ {+ perspectiveCommand: { key: 'DELETE_SELECTED_ENTRIES' }+ },+ () => {+ this.setState({ perspectiveCommand: {} });+ }+ );+ },+ addRemoveTags: () => {+ this.setState(+ {+ perspectiveCommand: { key: 'ADD_REMOVE_TAGS' }+ },+ () => {+ this.setState({ perspectiveCommand: {} });+ }+ );+ },+ renameFile: () => {+ this.setState(+ {+ perspectiveCommand: { key: 'RENAME_ENTRY' }+ },+ () => {+ this.setState({ perspectiveCommand: {} });+ }+ );+ },openEntry: () => {const { lastSelectedEntry } = this.props;if (lastSelectedEntry) {diff --git a/app/components/dialogs/RenameFileDialog.js b/app/components/dialogs/RenameFileDialog.jsindex 00b933af4..d0975444e 100644--- a/app/components/dialogs/RenameFileDialog.js+++ b/app/components/dialogs/RenameFileDialog.js@@ -75,7 +75,10 @@ class RenameFileDialog extends React.Component<Props, State> {fileName: extractFileName(nextProps.selectedFilePath),filePath: nextProps.selectedFilePath}, () => {- this.fileName.select();+ this.fileName.focus();+ if (this.state.fileName) {+ this.fileName.setSelectionRange(0, this.state.fileName.indexOf('.'));+ }});}};diff --git a/app/components/settings/SettingsGeneral.js b/app/components/settings/SettingsGeneral.jsindex 3d5368da4..125c0c854 100644--- a/app/components/settings/SettingsGeneral.js+++ b/app/components/settings/SettingsGeneral.js@@ -59,7 +59,7 @@ type Props = {setTagTextColor: string,classes: Object,settings: Object,- setShowUnixHiddenEntries: () => void,+ toggleShowUnixHiddenEntries: () => void,setCurrentTheme: () => void,setLanguage: () => void,setDesktopMode: () => void,@@ -271,11 +271,7 @@ class SettingsGeneral extends React.Component<Props, State> {<ListItemSecondaryAction><Switchdata-tid="settingsSetShowUnixHiddenEntries"- onClick={() =>- this.props.setShowUnixHiddenEntries(- !this.props.settings.showUnixHiddenEntries- )- }+ onClick={this.props.toggleShowUnixHiddenEntries}checked={this.props.settings.showUnixHiddenEntries}/></ListItemSecondaryAction>diff --git a/app/containers/MainPage.js b/app/containers/MainPage.jsindex e42b58176..3311473ff 100644--- a/app/containers/MainPage.js+++ b/app/containers/MainPage.js@@ -146,6 +146,7 @@ type Props = {getPrevFile: () => void, // needed by electron-menusleftSplitSize: number,mainSplitSize: any,+ toggleShowUnixHiddenEntries: () => void,setLeftVerticalSplitSize: (splitSize: number) => void,setMainVerticalSplitSize: (splitSize: string) => void};@@ -289,6 +290,7 @@ class MainPage extends Component<Props, State> {};keyBindingHandlers = {+ toggleShowHiddenEntries: this.props.toggleShowUnixHiddenEntries,showFolderNavigator: this.toggleLocationManager,showTagLibrary: this.toggleTagLibrary,openSearch: this.toggleSearch,@@ -497,6 +499,7 @@ function mapDispatchToProps(dispatch) {setUpdateAvailable: AppActions.setUpdateAvailable,getNextFile: AppActions.getNextFile,getPrevFile: AppActions.getPrevFile,+ toggleShowUnixHiddenEntries: SettingsActions.toggleShowUnixHiddenEntries,setLeftVerticalSplitSize: SettingsActions.setLeftVerticalSplitSize,setMainVerticalSplitSize: SettingsActions.setMainVerticalSplitSize}, dispatch);diff --git a/app/perspectives/grid-perspective/src/index.js b/app/perspectives/grid-perspective/src/index.jsindex f3c1bed86..5f2f0929f 100644--- a/app/perspectives/grid-perspective/src/index.js+++ b/app/perspectives/grid-perspective/src/index.js@@ -303,25 +303,53 @@ class GridPerspective extends React.Component<Props, State> {componentWillReceiveProps = (nextProps: Props) => {const cmd = nextProps.perspectiveCommand;const { directoryContent } = nextProps;- if (- cmd &&- cmd.key &&- cmd.key === 'SELECT_FILE' &&- cmd.value.length > 0 &&- directoryContent &&- directoryContent.length > 0- ) {- this.setState(- {- selectedEntries: nextProps.directoryContent.filter(- fsEntry => fsEntry.path === cmd.value- )- },- () => {- this.computeFileOperationsEnabled();- // this.makeFirstSelectedEntryVisible(); // disable due to wrong scrolling+ if (cmd && cmd.key) {+ if (+ cmd.key === 'SELECT_FILE' &&+ cmd.value.length > 0 &&+ directoryContent &&+ directoryContent.length > 0+ ) {+ this.setState(+ {+ selectedEntries: nextProps.directoryContent.filter(+ fsEntry => fsEntry.path === cmd.value+ )+ },+ () => {+ this.computeFileOperationsEnabled();+ // this.makeFirstSelectedEntryVisible(); // disable due to wrong scrolling+ }+ );+ }++ if (cmd.key === 'TOGGLE_SELECT_ALL') {+ this.toggleSelectAllFiles();+ }++ if (+ cmd.key === 'ADD_REMOVE_TAGS' &&+ this.state.selectedEntries &&+ this.state.selectedEntries.length > 0+ ) {+ this.openAddRemoveTagsDialog();+ }++ if (+ cmd.key === 'RENAME_ENTRY' &&+ this.state.selectedEntries &&+ this.state.selectedEntries.length === 1+ ) {+ if (this.state.selectedEntries[0].isFile) {+ this.setState({ selectedEntryPath: this.state.selectedEntries[0].path }, () => {+ this.openFileRenameDialog();+ });}- );+ }++ if (cmd.key === 'DELETE_SELECTED_ENTRIES' && this.state.fileOperationsEnabled) {+ this.openDeleteFileDialog();+ }}// Directory changeddiff --git a/app/reducers/settings.js b/app/reducers/settings.jsindex df0a89953..19c77b022 100644--- a/app/reducers/settings.js+++ b/app/reducers/settings.js@@ -29,7 +29,7 @@ import { actions as AppActions } from './app';export const types = {UPGRADE_SETTINGS: 'SETTINGS/UPGRADE_SETTINGS',SET_LANGUAGE: 'SETTINGS/SET_LANGUAGE',- SET_SHOWUNIXHIDDENENTRIES: 'SETTINGS/SET_SHOWUNIXHIDDENENTRIES',+ TOGGLE_SHOWUNIXHIDDENENTRIES: 'SETTINGS/TOGGLE_SHOWUNIXHIDDENENTRIES',SET_DESKTOPMODE: 'SETTINGS/SET_DESKTOPMODE',SET_TAG_DELIMITER: 'SETTINGS/SET_TAG_DELIMITER',SET_MAX_SEARCH_RESULT: 'SETTINGS/SET_MAX_SEARCH_RESULT',@@ -86,8 +86,8 @@ export default (state = defaultSettings, action) => {] */};}- case types.SET_SHOWUNIXHIDDENENTRIES: {- return { ...state, showUnixHiddenEntries: action.showUnixHiddenEntries };+ case types.TOGGLE_SHOWUNIXHIDDENENTRIES: {+ return { ...state, showUnixHiddenEntries: !state.showUnixHiddenEntries };}case types.SET_TAG_DELIMITER: {return { ...state, tagDelimiter: action.delimiter };@@ -265,10 +265,7 @@ export const actions = {setTagDelimiter: (delimiter: string) => ({ type: types.SET_TAG_DELIMITER, delimiter }),setMaxSearchResult: (maxSearchResult: number) => ({ type: types.SET_MAX_SEARCH_RESULT, maxSearchResult }),setDesktopMode: (desktopMode: boolean) => ({ type: types.SET_DESKTOPMODE, desktopMode }),- setShowUnixHiddenEntries: (showUnixHiddenEntries: boolean) => ({- type: types.SET_SHOWUNIXHIDDENENTRIES,- showUnixHiddenEntries- }),+ toggleShowUnixHiddenEntries: () => ({ type: types.TOGGLE_SHOWUNIXHIDDENENTRIES }),setCheckForUpdates: (checkForUpdates: boolean) => ({ type: types.SET_CHECKFORUPDATES, checkForUpdates }),setLanguage: (language: string) => ({ type: types.SET_LANGUAGE, language }),setUseDefaultLocation: (useDefaultLocation: boolean) => ({ type: types.SET_USEDEFAULTLOCATION, useDefaultLocation }),