diff --git a/browser/main/modals/PreferencesModal/HotkeyTab.js b/browser/main/modals/PreferencesModal/HotkeyTab.js new file mode 100644 index 00000000..21103c03 --- /dev/null +++ b/browser/main/modals/PreferencesModal/HotkeyTab.js @@ -0,0 +1,156 @@ +import React, { PropTypes } from 'react' +import CSSModules from 'browser/lib/CSSModules' +import styles from './ConfigTab.styl' +import ConfigManager from 'browser/main/lib/ConfigManager' +import store from 'browser/main/store' + +const electron = require('electron') +const ipc = electron.ipcRenderer + +const OSX = global.process.platform === 'darwin' + +class HotkeyTagb extends React.Component { + constructor (props) { + super(props) + + this.state = { + isHotkeyHintOpen: false, + config: props.config + } + } + + componentDidMount () { + this.handleSettingDone = () => { + this.setState({keymapAlert: { + type: 'success', + message: 'Successfully applied!' + }}) + } + this.handleSettingError = (err) => { + this.setState({keymapAlert: { + type: 'error', + message: err.message != null ? err.message : 'Error occurs!' + }}) + } + ipc.addListener('APP_SETTING_DONE', this.handleSettingDone) + ipc.addListener('APP_SETTING_ERROR', this.handleSettingError) + } + + componentWillUnmount () { + ipc.removeListener('APP_SETTING_DONE', this.handleSettingDone) + ipc.removeListener('APP_SETTING_ERROR', this.handleSettingError) + } + + handleSaveButtonClick (e) { + let newConfig = { + hotkey: this.state.config.hotkey + } + + ConfigManager.set(newConfig) + + store.dispatch({ + type: 'SET_UI', + config: newConfig + }) + } + + handleHintToggleButtonClick (e) { + this.setState({ + isHotkeyHintOpen: !this.state.isHotkeyHintOpen + }) + } + + handleHotkeyChange (e) { + let { config } = this.state + config.hotkey = { + toggleFinder: this.refs.toggleFinder.value, + toggleMain: this.refs.toggleMain.value + } + this.setState({ + config + }) + } + + render () { + let keymapAlert = this.state.keymapAlert + let keymapAlertElement = keymapAlert != null + ?
+ {keymapAlert.message} +
+ : null + let { config } = this.state + + return ( +Available Keys
+0 to 9A to ZF1 to F24~, !, @, #, $, etc.PlusSpaceBackspaceDeleteInsertReturn (or Enter as alias)Up, Down, Left and RightHome and EndPageUp and PageDownEscape (or Esc for short)VolumeUp, VolumeDown and VolumeMuteMediaNextTrack, MediaPreviousTrack, MediaStop and MediaPlayPause