import { useEffect, useState } from 'react'; import { useSettings, QUALITY_LABEL, SUBTITLE_COLORS, SUBTITLE_MARGIN, type Preferences, type Quality, type SkipMode, type SubtitleBox, type SubtitleEdge, type SubtitleMode, type SubtitlePosition } from '../../app/settings'; import { useSession } from '../../app/session'; import { useSections, useServerQuery } from '../../app/queries'; import * as api from '../../plex/api'; import { art } from '../../app/format'; import { useDownloads } from '../../downloads/store'; import { appInfo, fullscreenShortcut, isMac, isNative, openExternal, pickFolder, revealPath, shortcut, type AppInfo } from '../../platform/native'; import { checkForUpdate, installUpdate, useUpdater } from '../../app/updater'; import { Button, Segmented, Select, Switch } from '../../ui/primitives'; import { confirmDialog } from '../../ui/overlays'; import { Pref, SettingsSection } from './parts'; import { KaleidoMark } from '../../ui/primitives'; const LANGUAGES: [string, string][] = [ ['', 'Automatic'], ['eng', 'English'], ['spa', 'Spanish'], ['fre', 'French'], ['ger', 'German'], ['ita', 'Italian'], ['por', 'Portuguese'], ['jpn', 'Japanese'], ['kor', 'Korean'], ['chi', 'Chinese'], ['rus', 'Russian'], ['hin', 'Hindi'], ['ara', 'Arabic'], ['dut', 'Dutch'], ['swe', 'Swedish'], ['nor', 'Norwegian'], ['dan', 'Danish'], ['fin', 'Finnish'], ['pol', 'Polish'], ['tur', 'Turkish'], ]; const qualityOptions = (Object.keys(QUALITY_LABEL) as Quality[]).map((q) => ({ value: q, label: QUALITY_LABEL[q] })); const skipOptions: { value: SkipMode; label: string }[] = [ { value: 'button', label: 'Show a button' }, { value: 'auto', label: 'Skip automatically' }, { value: 'off', label: 'Off' }, ]; const OS_NAMES: Record = { windows: 'Windows', macos: 'macOS', linux: 'Linux' }; const SHORTCUTS: [string, string][][] = [ [ [shortcut('K'), 'Search'], [isMac ? '⌘[ / Mouse back' : 'Alt + ← / Mouse back', 'Go back'], [isMac ? '⌘] / Mouse forward' : 'Alt + → / Mouse forward', 'Go forward'], ['Esc', 'Go back or close a dialog'], [fullscreenShortcut, 'Full screen'], [shortcut(','), 'Settings'], ['Right-click a title', 'Title actions'], ], [ ['Space or K', 'Play / pause'], ['← / →', 'Seek back / forward'], ['Shift + ← / →', 'Seek one minute'], ['J / L', 'Seek 10 seconds'], ['↑ / ↓ or scroll', 'Volume'], ['M', 'Mute'], ['F or double-click', 'Full screen'], ['C', 'Next subtitle track'], ['U', 'Cycle upscaling'], ['B', 'Compare with enhancement off'], ['Shift + P / N', 'Previous / next episode'], ['0–9', 'Jump to 0–90%'], ['Esc or Backspace', 'Exit full screen, then keep playing in the corner'], ], ]; /** * A frame from the library with a sample line drawn the way mpv will draw it: * sizes are in mpv's scaled pixels, where the frame height is 720. */ function SubtitlePreview({ prefs }: { prefs: Preferences }) { const session = useSession(); const cw = useServerQuery(['continue'], (srv) => api.continueWatching(srv), { enabled: !!session.server, staleTime: 15_000 }); const still = cw.data?.find((i) => art.backdrop(i)); const px = (n: number) => `calc(${n} / 720 * 100cqh)`; const edge = prefs.subtitleBox === 'none' ? prefs.subtitleEdge : 'none'; const outline = edge === 'outline' ? 1.8 : edge === 'raised' ? 1.3 : 0; const shadow = edge === 'shadow' ? 2.2 : edge === 'raised' ? 1.6 : 0; return (
{still && session.server && }
The night is darkest just before the dawn.
And I promise you, the dawn is coming.
); } export function AppSettings({ tab }: { tab: string }) { const s = useSettings(); const set = s.set; const session = useSession(); const sections = useSections(); const downloads = useDownloads(); const [info, setInfo] = useState(null); const updater = useUpdater(); useEffect(() => { appInfo().then(setInfo); }, []); const movieLibs = (sections.data ?? []).filter((x) => x.type === 'movie'); const showLibs = (sections.data ?? []).filter((x) => x.type === 'show'); switch (tab) { case 'general': return ( <> set('movieSection', v)} options={movieLibs.map((l) => ({ value: l.id, label: l.title }))} /> )} {showLibs.length > 1 && ( set('watchedPercent', v)} options={[70, 75, 80, 85, 90, 95].map((v) => ({ value: v, label: `${v}%` }))} /> ); case 'playback': return ( <> set('remoteQuality', v)} options={qualityOptions} /> set('hwdec', v)} /> set('hdrPassthrough', v)} /> set('skipCredits', v)} options={skipOptions} /> set('countdownSeconds', v)} options={[5, 8, 10, 15, 20, 30].map((v) => ({ value: v, label: `${v} seconds` }))} /> set('audioLanguage', v)} options={LANGUAGES.map(([value, label]) => ({ value, label }))} /> value={s.subtitleMode} onChange={(v) => set('subtitleMode', v)} options={[ { value: 'auto', label: 'As chosen in Plex' }, { value: 'forced', label: 'Forced subtitles only' }, { value: 'always', label: 'Always' }, { value: 'off', label: 'Never' }, ]} /> set('subtitleScale', v)} options={[ { value: 0.8, label: 'Small' }, { value: 1, label: 'Normal' }, { value: 1.25, label: 'Large' }, { value: 1.5, label: 'Extra large' }, ]} />
{SUBTITLE_COLORS.map((c) => (
value={s.subtitleEdge} onChange={(v) => set('subtitleEdge', v)} options={[ { value: 'outline', label: 'Outline' }, { value: 'shadow', label: 'Shadow' }, { value: 'raised', label: 'Both' }, { value: 'none', label: 'None' }, ]} /> value={s.subtitleBox} onChange={(v) => set('subtitleBox', v)} options={[ { value: 'none', label: 'None' }, { value: 'translucent', label: 'Translucent' }, { value: 'solid', label: 'Solid' }, ]} /> set('subtitleBold', v)} /> value={s.subtitlePosition} onChange={(v) => set('subtitlePosition', v)} options={[ { value: 'low', label: 'Low' }, { value: 'normal', label: 'Normal' }, { value: 'high', label: 'Raised' }, ]} />
); case 'interface': return ( set('colorWash', v)} /> set('heroRotation', v)} /> set('themeVolume', v)} options={[15, 30, 50, 75, 100].map((v) => ({ value: v, label: `${v}%` }))} /> set('reducedMotion', v)} /> ); case 'downloads': return ( {downloads.dir && ( )} Always ); case 'shortcuts': return (
{SHORTCUTS.map((group, i) => ( {group.map(([k, label]) => ( {k} ))} ))}
); case 'about': return ( <>

Kaleido

Version {info?.version ?? '—'} · {OS_NAMES[info?.platform ?? ''] ?? info?.platform}

{updater.available ? ( ) : ( )} {info?.dataDir && ( )}

Kaleido is an independent project and is not affiliated with Plex. Video playback uses mpv (libmpv), licensed under the LGPL.

); default: return null; } }