touch operation
This commit is contained in:
@@ -15,7 +15,6 @@ import SendTimeExtensionIcon from "@mui/icons-material/SendTimeExtension";
|
||||
import InputIcon from "@mui/icons-material/Input";
|
||||
import SelectAllIcon from "@mui/icons-material/SelectAll";
|
||||
import EventNoteIcon from "@mui/icons-material/EventNote";
|
||||
import TouchAppIcon from "@mui/icons-material/TouchApp";
|
||||
|
||||
function LinkItem({ label, url, icon }) {
|
||||
const match = useMatch(url);
|
||||
@@ -48,12 +47,6 @@ export default function Navigator(props) {
|
||||
url: "/input",
|
||||
icon: <InputIcon />,
|
||||
},
|
||||
{
|
||||
id: "touch_setting",
|
||||
label: i18n("touch_setting"),
|
||||
url: "/touch",
|
||||
icon: <TouchAppIcon />,
|
||||
},
|
||||
{
|
||||
id: "selection_translate",
|
||||
label: i18n("selection_translate"),
|
||||
|
||||
@@ -60,6 +60,9 @@ export default function Settings() {
|
||||
case "newlineLength":
|
||||
value = limitNumber(value, 1, 1000);
|
||||
break;
|
||||
case "touchTranslate":
|
||||
value = limitNumber(value, 0, 3);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
updateSetting({
|
||||
@@ -86,6 +89,7 @@ export default function Settings() {
|
||||
newlineLength = TRANS_NEWLINE_LENGTH,
|
||||
mouseKey = OPT_MOUSEKEY_DISABLE,
|
||||
detectRemote = false,
|
||||
touchTranslate = 2,
|
||||
} = setting;
|
||||
const { isHide = false } = fab || {};
|
||||
|
||||
@@ -169,6 +173,22 @@ export default function Settings() {
|
||||
</Select>
|
||||
</FormControl>
|
||||
|
||||
<FormControl size="small">
|
||||
<InputLabel>{i18n("touch_translate_shortcut")}</InputLabel>
|
||||
<Select
|
||||
name="touchTranslate"
|
||||
value={touchTranslate}
|
||||
label={i18n("touch_translate_shortcut")}
|
||||
onChange={handleChange}
|
||||
>
|
||||
{[0, 2, 3].map((item) => (
|
||||
<MenuItem key={item} value={item}>
|
||||
{i18n(`touch_tap_${item}`)}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Select>
|
||||
</FormControl>
|
||||
|
||||
<FormControl size="small">
|
||||
<InputLabel>{i18n("hide_fab_button")}</InputLabel>
|
||||
<Select
|
||||
|
||||
@@ -22,7 +22,6 @@ import Webfix from "./Webfix";
|
||||
import InputSetting from "./InputSetting";
|
||||
import Tranbox from "./Tranbox";
|
||||
import FavWords from "./FavWords";
|
||||
import TouchSetting from "./touchSetting";
|
||||
|
||||
export default function Options() {
|
||||
const [error, setError] = useState("");
|
||||
@@ -123,7 +122,6 @@ export default function Options() {
|
||||
<Route index element={<Setting />} />
|
||||
<Route path="rules" element={<Rules />} />
|
||||
<Route path="input" element={<InputSetting />} />
|
||||
<Route path="touch" element={<TouchSetting />} />
|
||||
<Route path="tranbox" element={<Tranbox />} />
|
||||
<Route path="apis" element={<Apis />} />
|
||||
<Route path="sync" element={<SyncSetting />} />
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
import Box from "@mui/material/Box";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import TextField from "@mui/material/TextField";
|
||||
import MenuItem from "@mui/material/MenuItem";
|
||||
import { useI18n } from "../../hooks/I18n";
|
||||
import {
|
||||
OPT_SHORTCUT_TRANSLATE,
|
||||
OPT_SHORTCUT_STYLE,
|
||||
OPT_SHORTCUT_POPUP,
|
||||
OPT_SHORTCUT_SETTING,
|
||||
} from "../../config";
|
||||
import Grid from "@mui/material/Grid";
|
||||
import { limitNumber } from "../../libs/utils";
|
||||
import { useTouch } from "../../hooks/Touch";
|
||||
|
||||
function TouchItem({ action, name }) {
|
||||
const i18n = useI18n();
|
||||
const { touchOperation, setTouchOperation } = useTouch(action);
|
||||
const [triggerShortcut, triggerCount, triggerTime] = touchOperation;
|
||||
|
||||
const handleChangeShortcut = (e) => {
|
||||
const value = limitNumber(e.target.value, 0, 3);
|
||||
setTouchOperation(value, 0);
|
||||
};
|
||||
|
||||
const handleChangeCount = (e) => {
|
||||
const value = limitNumber(e.target.value, 1, 3);
|
||||
setTouchOperation(value, 2);
|
||||
};
|
||||
|
||||
const handleChangeTime = (e) => {
|
||||
const value = limitNumber(e.target.value, 100, 1000);
|
||||
setTouchOperation(value, 3);
|
||||
};
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Grid container spacing={2} columns={12}>
|
||||
<Grid item xs={12} sm={12} md={4} lg={4}>
|
||||
<TextField
|
||||
select
|
||||
fullWidth
|
||||
size="small"
|
||||
name="triggerShortcut"
|
||||
value={triggerShortcut}
|
||||
label={i18n(name)}
|
||||
onChange={handleChangeShortcut}
|
||||
>
|
||||
{[0, 2, 3].map((val) => (
|
||||
<MenuItem key={val} value={val}>
|
||||
{i18n(`touch_tap_${val}`)}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={12} md={4} lg={4}>
|
||||
<TextField
|
||||
select
|
||||
fullWidth
|
||||
size="small"
|
||||
name="triggerCount"
|
||||
value={triggerCount}
|
||||
label={i18n("shortcut_press_count")}
|
||||
onChange={handleChangeCount}
|
||||
>
|
||||
{[1, 2, 3].map((val) => (
|
||||
<MenuItem key={val} value={val}>
|
||||
{val}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
</Grid>
|
||||
<Grid item xs={12} sm={12} md={4} lg={4}>
|
||||
<TextField
|
||||
fullWidth
|
||||
size="small"
|
||||
label={i18n("combo_timeout")}
|
||||
type="number"
|
||||
name="triggerTime"
|
||||
defaultValue={triggerTime}
|
||||
onChange={handleChangeTime}
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
export default function TouchSetting() {
|
||||
return (
|
||||
<Box>
|
||||
<Stack spacing={3}>
|
||||
<TouchItem
|
||||
action={OPT_SHORTCUT_TRANSLATE}
|
||||
name="toggle_translate_shortcut"
|
||||
/>
|
||||
<TouchItem action={OPT_SHORTCUT_STYLE} name="toggle_style_shortcut" />
|
||||
<TouchItem action={OPT_SHORTCUT_POPUP} name="toggle_popup_shortcut" />
|
||||
<TouchItem action={OPT_SHORTCUT_SETTING} name="open_setting_shortcut" />
|
||||
</Stack>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user