diff --git a/browser/main/modals/PreferencesModal/ConfigTab.js b/browser/main/modals/PreferencesModal/ConfigTab.js deleted file mode 100644 index 4091a749..00000000 --- a/browser/main/modals/PreferencesModal/ConfigTab.js +++ /dev/null @@ -1,408 +0,0 @@ -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' -import consts from 'browser/lib/consts' - -const electron = require('electron') -const ipc = electron.ipcRenderer - -const OSX = global.process.platform === 'darwin' - -class ConfigTab 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 - }) - } - - handleKeyDown (e) { - if (e.keyCode === 13) { - this.submitHotKey() - } - } - - handleConfigKeyDown (e) { - if (e.keyCode === 13) { - this.submitConfig() - } - } - - handleLineNumberingClick (e) { - let config = this.state.config - - config['preview-line-number'] = e.target.checked - this.setState({ - config - }) - } - - handleDisableDirectWriteClick (e) { - let config = this.state.config - config['disable-direct-write'] = e.target.checked - this.setState({ - config - }) - } - - 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 - }) - } - - handleUIChange (e) { - let { config } = this.state - - config.ui = { - theme: this.refs.uiTheme.value, - disableDirectWrite: this.refs.uiD2w != null - ? this.refs.uiD2w.checked - : false - } - config.editor = { - theme: this.refs.editorTheme.value, - fontSize: this.refs.editorFontSize.value, - fontFamily: this.refs.editorFontFamily.value, - indentType: this.refs.editorIndentType.value, - indentSize: this.refs.editorIndentSize.value, - switchPreview: this.refs.editorSwitchPreview.value - } - config.preview = { - fontSize: this.refs.previewFontSize.value, - fontFamily: this.refs.previewFontFamily.value, - codeBlockTheme: this.refs.previewCodeBlockTheme.value, - lineNumber: this.refs.previewLineNumber.checked - } - - this.setState({ - config - }) - } - - handleSaveUIClick (e) { - let newConfig = { - ui: this.state.config.ui, - editor: this.state.config.editor, - preview: this.state.config.preview - } - - ConfigManager.set(newConfig) - - store.dispatch({ - type: 'SET_UI', - config: newConfig - }) - } - - render () { - let keymapAlert = this.state.keymapAlert - let keymapAlertElement = keymapAlert != null - ?
- {keymapAlert.message} -
- : null - let themes = consts.THEMES - 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