import { KeyboardShortcutRegister } from '@/components/KeyboardShortcutRegister'; import { ListItem } from '@/components/ListItem'; import { usePromiseValue } from '@/helpers/useServiceValue'; import { Box, Divider, FormControl, InputLabel, List, ListItemText, MenuItem, Select, Switch, Typography } from '@mui/material'; import { usePreferenceObservable } from '@services/preferences/hooks'; import type { IWindowService } from '@services/windows/interface'; import React from 'react'; import { useTranslation } from 'react-i18next'; import { Paper, SectionTitle } from '../PreferenceComponents'; import type { ISectionProps } from '../useSections'; export function TidGiMiniWindow(props: Partial): React.JSX.Element { const { t } = useTranslation(); const preference = usePreferenceObservable(); const platform = usePromiseValue(async () => await window.service.context.get('platform')); const workspaces = usePromiseValue(async () => (await window.service.workspace.getWorkspacesAsList()), []); if (preference === undefined || platform === undefined) { return {t('Loading')}; } return ( <> {t('Menu.TidGiMiniWindow')} {/* Attach to taskbar/system tray settings */} { await window.service.preference.set('tidgiMiniWindow', event.target.checked); }} data-testid='attach-to-tidgi-mini-window-switch' /> } > {/* Other settings are only visible when attached to taskbar/system tray */} {preference.tidgiMiniWindow && ( <> {/* Set shortcut key to toggle TidGi mini window */} { if (value && value.trim() !== '') { await window.service.native.registerKeyboardShortcut('Window', 'toggleTidgiMiniWindow', value); } else { await window.service.native.unregisterKeyboardShortcut('Window', 'toggleTidgiMiniWindow'); } }} data-testid='tidgi-mini-window-shortcut-input' /> {t('Preference.TidgiMiniWindowShortcutKeyHelperText')} {/* Show title bar on tidgi mini window */} { await window.service.preference.set('tidgiMiniWindowShowTitleBar', event.target.checked); }} data-testid='tidgi-mini-window-titlebar-switch' /> } > {/* Keep tidgi mini window on top of other windows */} { await window.service.preference.set('tidgiMiniWindowAlwaysOnTop', event.target.checked); }} data-testid='tidgi-mini-window-always-on-top-switch' /> } > {/* Show the same workspace in both small and main window */} { await window.service.preference.set('tidgiMiniWindowSyncWorkspaceWithMainWindow', event.target.checked); }} data-testid='tidgi-mini-window-sync-workspace-switch' /> } > {/* Select fixed workspace for TidGi mini window */} {!preference.tidgiMiniWindowSyncWorkspaceWithMainWindow && ( <> {/* Sidebar display settings */} { await window.service.preference.set('tidgiMiniWindowShowSidebar', event.target.checked); }} data-testid='sidebar-on-tidgi-mini-window-switch' /> } > {t('Preference.TidgiMiniWindowFixedWorkspace')} )} )} ); }