-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
266 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { settingChange, useSettingStore } from './setting-store' | ||
import { shell } from 'electron' | ||
import { DbLocationSetting } from './db-location-setting' | ||
import { EcdictLocationSetting } from './ecdict-location-setting' | ||
import { ThemedCheckbox } from '../../components/themed-ui/input/checkbox' | ||
import { ThemedInputShortcut } from '../../components/themed-ui/input/input-shortcut/themed-input-shortcut' | ||
import React from 'react' | ||
import { rendererContainer } from '../../../common/container/renderer-container' | ||
import { | ||
AppService, | ||
AppServiceToken, | ||
} from '../../../common/services/app-service' | ||
import styled from 'styled-components' | ||
|
||
const appService = rendererContainer.get<AppService>(AppServiceToken) | ||
const userDataFolder = appService.getUserDataFolder() | ||
|
||
const Container = styled.div` | ||
> div { | ||
margin: 30px 0; | ||
} | ||
` | ||
|
||
const InlineContainer = styled.span` | ||
display: inline-flex; | ||
align-items: center; | ||
> * + * { | ||
margin-left: 10px; | ||
} | ||
` | ||
|
||
export const GeneralSettingPage = () => { | ||
const { appHotKey, readClipboard } = useSettingStore() | ||
return ( | ||
<Container> | ||
<div> | ||
<span>User Data Folder: </span> | ||
<a | ||
onClick={() => { | ||
shell.showItemInFolder(userDataFolder) | ||
}} | ||
role="button" | ||
> | ||
{userDataFolder} | ||
</a> | ||
</div> | ||
<DbLocationSetting /> | ||
<EcdictLocationSetting /> | ||
<div> | ||
<ThemedCheckbox | ||
checked={readClipboard} | ||
onChange={(event) => { | ||
settingChange({ | ||
readClipboard: event?.target?.checked!!, | ||
}) | ||
}} | ||
> | ||
Read Clipboard | ||
</ThemedCheckbox> | ||
</div> | ||
<div> | ||
<InlineContainer> | ||
<span>hot key:</span> | ||
<ThemedInputShortcut | ||
value={appHotKey} | ||
onChange={(value) => { | ||
settingChange({ | ||
appHotKey: value, | ||
}) | ||
}} | ||
/> | ||
</InlineContainer> | ||
</div> | ||
</Container> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import SplitPane from 'react-split-pane'; | ||
import styled from 'styled-components'; | ||
import ColorId from '../../styles/ColorId'; | ||
|
||
// see: https://github.com/tomkp/react-split-pane | ||
const SettingPageSplitPane = styled(SplitPane)` | ||
&.SplitPane { | ||
position: unset !important; | ||
} | ||
.Resizer { | ||
//background: #000; | ||
background: ${props => props.theme[ColorId.foreground]}; | ||
opacity: 0.2; | ||
z-index: 1; | ||
-moz-box-sizing: border-box; | ||
-webkit-box-sizing: border-box; | ||
box-sizing: border-box; | ||
-moz-background-clip: padding; | ||
-webkit-background-clip: padding; | ||
background-clip: padding-box; | ||
} | ||
.Resizer:hover { | ||
-webkit-transition: all 2s ease; | ||
transition: all 2s ease; | ||
} | ||
.Resizer.horizontal { | ||
height: 11px; | ||
margin: -5px 0; | ||
border-top: 5px solid rgba(255, 255, 255, 0); | ||
border-bottom: 5px solid rgba(255, 255, 255, 0); | ||
cursor: row-resize; | ||
width: 100%; | ||
} | ||
.Resizer.horizontal:hover { | ||
//border-top: 5px solid rgba(0, 0, 0, 0.5); | ||
//border-bottom: 5px solid rgba(0, 0, 0, 0.5); | ||
border-top: 5px solid rgba(255, 255, 255, 0.5); | ||
border-bottom: 5px solid rgba(255, 255, 255, 0.5); | ||
} | ||
.Resizer.vertical { | ||
width: 11px; | ||
margin: 0 -5px; | ||
border-left: 5px solid rgba(255, 255, 255, 0); | ||
border-right: 5px solid rgba(255, 255, 255, 0); | ||
cursor: col-resize; | ||
} | ||
.Resizer.vertical:hover { | ||
border-left: 5px solid rgba(0, 0, 0, 0.5); | ||
border-right: 5px solid rgba(0, 0, 0, 0.5); | ||
} | ||
.Resizer.disabled { | ||
cursor: not-allowed; | ||
} | ||
.Resizer.disabled:hover { | ||
border-color: transparent; | ||
} | ||
`; | ||
|
||
export default SettingPageSplitPane; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,67 @@ | ||
import React, { useRef } from 'react'; | ||
import styled from 'styled-components'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { ThemedCheckbox } from '../../components/themed-ui/input/checkbox'; | ||
import { ThemedContent } from '../../components/themed-ui/content/content'; | ||
import { ThemedInputShortcut } from '../../components/themed-ui/input/input-shortcut/themed-input-shortcut'; | ||
import { EcdictLocationSetting } from './ecdict-location-setting'; | ||
import { rendererContainer } from '../../../common/container/renderer-container'; | ||
import { shell } from 'electron'; | ||
import { AppService, AppServiceToken } from '../../../common/services/app-service'; | ||
import { DbLocationSetting } from './db-location-setting'; | ||
import { settingChange, useSettingStore } from './setting-store'; | ||
const appService = rendererContainer.get<AppService>(AppServiceToken); | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
import { ThemedContent } from '../../components/themed-ui/content/content' | ||
import SettingPageSplitPane from './setting-page-split-pane' | ||
// import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'; | ||
import { | ||
Tab, | ||
Tabs, | ||
TabList, | ||
TabPanel, | ||
} from '../../components/themed-ui/tabs/tabs' | ||
import ColorId from '../../styles/ColorId' | ||
import { GeneralSettingPage } from './general-setting-page' | ||
import { SyncSettingPage } from './sync-setting-page'; | ||
|
||
const Container = styled.div` | ||
height: 100vh; | ||
padding: 20px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-around; | ||
`; | ||
` | ||
|
||
const InlineContainer = styled.span` | ||
display: inline-flex; | ||
align-items: center; | ||
const StyledTabs = styled(Tabs)` | ||
display: flex; | ||
flex-direction: row; | ||
height: 100%; | ||
` | ||
|
||
> * + * { | ||
margin-left: 10px; | ||
} | ||
`; | ||
// @ts-ignore | ||
const StyledTabList = styled(TabList)` | ||
display: flex; | ||
flex-direction: column; | ||
background-color: ${(props) => props.theme[ColorId.background]}; | ||
` | ||
|
||
const userDataFolder = appService.getUserDataFolder(); | ||
const StyledContent = styled.div` | ||
margin: 20px; | ||
` | ||
|
||
const SettingPage = () => { | ||
const { | ||
appHotKey, | ||
readClipboard, | ||
} = useSettingStore() | ||
|
||
return ( | ||
<ThemedContent> | ||
<Container> | ||
<div> | ||
<span>User Data Folder: </span> | ||
<a | ||
onClick={() => { | ||
shell.showItemInFolder(userDataFolder); | ||
}} | ||
role="button" | ||
>{userDataFolder}</a> | ||
</div> | ||
<DbLocationSetting/> | ||
<EcdictLocationSetting/> | ||
<ThemedCheckbox | ||
checked={readClipboard} | ||
onChange={event => { | ||
settingChange({ | ||
readClipboard: event?.target?.checked!!, | ||
}) | ||
}}>Read Clipboard</ThemedCheckbox> | ||
<InlineContainer> | ||
<span>hot key:</span> | ||
<ThemedInputShortcut | ||
value={appHotKey} | ||
onChange={value => { | ||
settingChange({ | ||
appHotKey: value, | ||
}) | ||
}} | ||
/> | ||
</InlineContainer> | ||
<StyledTabs> | ||
<SettingPageSplitPane | ||
split="vertical" | ||
minSize={120} | ||
> | ||
<StyledTabList> | ||
<Tab>General</Tab> | ||
<Tab>Auto Sync</Tab> | ||
</StyledTabList> | ||
|
||
<StyledContent> | ||
<TabPanel> | ||
<GeneralSettingPage /> | ||
</TabPanel> | ||
<TabPanel> | ||
<SyncSettingPage /> | ||
</TabPanel> | ||
</StyledContent> | ||
</SettingPageSplitPane> | ||
</StyledTabs> | ||
</Container> | ||
</ThemedContent> | ||
); | ||
}; | ||
) | ||
} | ||
|
||
export default SettingPage; | ||
export default SettingPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { settingChange, useSettingStore } from './setting-store' | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
import { ThemedCheckbox } from '../../components/themed-ui/input/checkbox' | ||
|
||
const Container = styled.div` | ||
> div { | ||
margin: 30px 0; | ||
} | ||
` | ||
|
||
export const SyncSettingPage = () => { | ||
const syncOnQuit = useSettingStore.use['search.syncHistory.syncOnQuit']() | ||
const syncOnStart = useSettingStore.use['search.syncHistory.syncOnStart']() | ||
const syncIntervalMinutes = | ||
useSettingStore.use['search.syncHistory.syncIntervalMinutes']() | ||
const autoSyncInBackground = syncIntervalMinutes > 0 | ||
return ( | ||
<Container> | ||
<div> | ||
<ThemedCheckbox | ||
checked={syncOnStart} | ||
onChange={(event) => { | ||
settingChange({ | ||
'search.syncHistory.syncOnStart': event?.target?.checked!!, | ||
}) | ||
}} | ||
> | ||
Sync On Start | ||
</ThemedCheckbox> | ||
</div> | ||
<div> | ||
<ThemedCheckbox | ||
checked={syncOnQuit} | ||
onChange={(event) => { | ||
settingChange({ | ||
'search.syncHistory.syncOnQuit': event?.target?.checked!!, | ||
}) | ||
}} | ||
> | ||
Sync On Quit | ||
</ThemedCheckbox> | ||
</div> | ||
<div> | ||
<ThemedCheckbox | ||
checked={autoSyncInBackground} | ||
onChange={(event) => { | ||
settingChange({ | ||
'search.syncHistory.syncIntervalMinutes': event?.target?.checked | ||
? 60 | ||
: -1, | ||
}) | ||
}} | ||
> | ||
Auto Sync In Background | ||
</ThemedCheckbox> | ||
</div> | ||
</Container> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters