All checks were successful
Validate Kaleido Desktop / validate (push) Successful in 1m22s
- Player controls centred under the timeline: previous episode, back 10 s, play/pause, forward 10 s, next episode; volume and time on the left. - Previous episode button and Shift+P. - Draggable miniplayer, kept inside the window and remembered. - Fix the next-episode card's buttons and the skip button being covered by the player's title row, and skip buttons also pausing playback. - Drop the "Highly rated"/"Recommended" label from the hero and restore the gap between its logo and the details line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
425 lines
20 KiB
TypeScript
425 lines
20 KiB
TypeScript
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<string, string> = { 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 (
|
||
<div className="subtitle-preview">
|
||
{still && session.server && <img src={session.server.image(art.backdrop(still), 960, 540)} alt="" draggable={false} />}
|
||
<div className="subtitle-preview-line" style={{ bottom: px(SUBTITLE_MARGIN[prefs.subtitlePosition]) }}>
|
||
<span
|
||
className={prefs.subtitleBox}
|
||
style={{
|
||
color: prefs.subtitleColor,
|
||
fontSize: px(38 * prefs.subtitleScale),
|
||
fontWeight: prefs.subtitleBold ? 700 : 400,
|
||
WebkitTextStroke: outline ? `${px(outline * 2)} #000` : undefined,
|
||
textShadow: shadow ? `${px(shadow)} ${px(shadow)} 0 rgba(0, 0, 0, 0.7)` : undefined,
|
||
}}
|
||
>
|
||
The night is darkest just before the dawn.
|
||
<br />
|
||
And I promise you, the dawn is coming.
|
||
</span>
|
||
</div>
|
||
</div>
|
||
);
|
||
}
|
||
|
||
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<AppInfo | null>(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 (
|
||
<>
|
||
<SettingsSection title="Account" description="Your Plex account and the server Kaleido is browsing.">
|
||
<Pref label={session.user?.title ?? 'Signed in with a server token'} description={session.user?.email || 'Manual connection'}>
|
||
<Button variant="ghost" size="sm" icon="logout" onClick={() => confirmDialog({ title: 'Sign out of Plex?', message: 'Downloads stay on this computer. You can sign in again at any time.', confirm: 'Sign out' }).then((ok) => void (ok && session.signOut()))}>
|
||
Sign out
|
||
</Button>
|
||
</Pref>
|
||
<Pref
|
||
label="Server"
|
||
description={
|
||
session.server
|
||
? `${session.server.name} · ${session.connection?.relay ? 'Plex Relay' : session.connection?.local ? 'Local network' : 'Remote'} · ${session.server.uri.replace(/X-Plex-Token=[^&]+/, '')}`
|
||
: ''
|
||
}
|
||
>
|
||
<Button variant="ghost" size="sm" icon="swap" onClick={session.showServerPicker} disabled={!session.accountToken}>
|
||
Change
|
||
</Button>
|
||
</Pref>
|
||
</SettingsSection>
|
||
<SettingsSection title="Browsing">
|
||
<Pref label="Start on" description="The page Kaleido opens to.">
|
||
<Select
|
||
value={s.startPage}
|
||
onChange={(v) => set('startPage', v)}
|
||
options={[
|
||
{ value: 'home', label: 'Home' },
|
||
{ value: 'movies', label: 'Movies' },
|
||
{ value: 'shows', label: 'TV Shows' },
|
||
]}
|
||
/>
|
||
</Pref>
|
||
{movieLibs.length > 1 && (
|
||
<Pref label="Movies library" description="The library shown in Movies.">
|
||
<Select value={s.movieSection || movieLibs[0].id} onChange={(v) => set('movieSection', v)} options={movieLibs.map((l) => ({ value: l.id, label: l.title }))} />
|
||
</Pref>
|
||
)}
|
||
{showLibs.length > 1 && (
|
||
<Pref label="TV Shows library" description="The library shown in TV Shows.">
|
||
<Select value={s.showSection || showLibs[0].id} onChange={(v) => set('showSection', v)} options={showLibs.map((l) => ({ value: l.id, label: l.title }))} />
|
||
</Pref>
|
||
)}
|
||
<Pref label="Mark as watched at" description="How far into a title playback counts as watched. This belongs to Kaleido and doesn’t change your server.">
|
||
<Select value={s.watchedPercent} onChange={(v) => set('watchedPercent', v)} options={[70, 75, 80, 85, 90, 95].map((v) => ({ value: v, label: `${v}%` }))} />
|
||
</Pref>
|
||
</SettingsSection>
|
||
</>
|
||
);
|
||
case 'playback':
|
||
return (
|
||
<>
|
||
<SettingsSection title="Quality" description="Original quality plays the source file directly; Kaleido decodes nearly every format, so Plex rarely needs to convert.">
|
||
<Pref label="On your local network">
|
||
<Select value={s.quality} onChange={(v) => set('quality', v)} options={qualityOptions} />
|
||
</Pref>
|
||
<Pref label="Away from home" description="Used when the server is reached remotely or through Plex Relay.">
|
||
<Select value={s.remoteQuality} onChange={(v) => set('remoteQuality', v)} options={qualityOptions} />
|
||
</Pref>
|
||
<Pref label="Hardware decoding" description="Uses your graphics card to decode video. Turn off only if you see artifacts. Applies after restarting Kaleido.">
|
||
<Switch checked={s.hwdec} onChange={(v) => set('hwdec', v)} />
|
||
</Pref>
|
||
<Pref label="HDR passthrough" description={`Sends HDR video to HDR-capable displays${isMac ? '' : ' when Windows HDR is on'}. Applies after restarting Kaleido.`}>
|
||
<Switch checked={s.hdrPassthrough} onChange={(v) => set('hdrPassthrough', v)} />
|
||
</Pref>
|
||
</SettingsSection>
|
||
<SettingsSection title="Episodes and markers" description="Intro and credits markers come from your Plex server’s analysis.">
|
||
<Pref label="Skip intros">
|
||
<Select value={s.skipIntro} onChange={(v) => set('skipIntro', v)} options={skipOptions} />
|
||
</Pref>
|
||
<Pref label="Skip credits">
|
||
<Select value={s.skipCredits} onChange={(v) => set('skipCredits', v)} options={skipOptions} />
|
||
</Pref>
|
||
<Pref label="Play the next episode automatically">
|
||
<Switch checked={s.autoplayNext} onChange={(v) => set('autoplayNext', v)} />
|
||
</Pref>
|
||
<Pref label="Countdown" description="Seconds before the next episode starts.">
|
||
<Select value={s.countdownSeconds} disabled={!s.autoplayNext} onChange={(v) => set('countdownSeconds', v)} options={[5, 8, 10, 15, 20, 30].map((v) => ({ value: v, label: `${v} seconds` }))} />
|
||
</Pref>
|
||
<Pref label="Arrow-key seek">
|
||
<Select value={s.seekStep} onChange={(v) => set('seekStep', v)} options={[5, 10, 15, 30].map((v) => ({ value: v, label: `${v} seconds` }))} />
|
||
</Pref>
|
||
</SettingsSection>
|
||
</>
|
||
);
|
||
case 'subtitles':
|
||
return (
|
||
<>
|
||
<SettingsSection title="Audio">
|
||
<Pref label="Preferred audio language" description="Automatic follows the track Plex selects for each title.">
|
||
<Select value={s.audioLanguage} onChange={(v) => set('audioLanguage', v)} options={LANGUAGES.map(([value, label]) => ({ value, label }))} />
|
||
</Pref>
|
||
</SettingsSection>
|
||
<SettingsSection title="Subtitles">
|
||
<Pref label="Show subtitles">
|
||
<Select<SubtitleMode>
|
||
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' },
|
||
]}
|
||
/>
|
||
</Pref>
|
||
<Pref label="Subtitle language" description="Automatic uses the language of the audio track.">
|
||
<Select value={s.subtitleLanguage} onChange={(v) => set('subtitleLanguage', v)} options={LANGUAGES.map(([value, label]) => ({ value, label }))} />
|
||
</Pref>
|
||
</SettingsSection>
|
||
<SettingsSection title="Subtitle style" description="How text subtitles look. Image subtitles (Blu-ray, DVD) and styled ASS subtitles keep their own look. Changes apply to a playing video straight away.">
|
||
<SubtitlePreview prefs={s} />
|
||
<Pref label="Size">
|
||
<Select
|
||
value={s.subtitleScale}
|
||
onChange={(v) => set('subtitleScale', v)}
|
||
options={[
|
||
{ value: 0.8, label: 'Small' },
|
||
{ value: 1, label: 'Normal' },
|
||
{ value: 1.25, label: 'Large' },
|
||
{ value: 1.5, label: 'Extra large' },
|
||
]}
|
||
/>
|
||
</Pref>
|
||
<Pref label="Text colour">
|
||
<div className="swatches" role="radiogroup" aria-label="Text colour">
|
||
{SUBTITLE_COLORS.map((c) => (
|
||
<button
|
||
key={c.value}
|
||
role="radio"
|
||
aria-checked={s.subtitleColor === c.value}
|
||
aria-label={c.label}
|
||
title={c.label}
|
||
className={s.subtitleColor === c.value ? 'selected' : ''}
|
||
style={{ background: c.value }}
|
||
onClick={() => set('subtitleColor', c.value)}
|
||
/>
|
||
))}
|
||
</div>
|
||
</Pref>
|
||
<Pref label="Edge">
|
||
<Segmented<SubtitleEdge>
|
||
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' },
|
||
]}
|
||
/>
|
||
</Pref>
|
||
<Pref label="Background">
|
||
<Segmented<SubtitleBox>
|
||
value={s.subtitleBox}
|
||
onChange={(v) => set('subtitleBox', v)}
|
||
options={[
|
||
{ value: 'none', label: 'None' },
|
||
{ value: 'translucent', label: 'Translucent' },
|
||
{ value: 'solid', label: 'Solid' },
|
||
]}
|
||
/>
|
||
</Pref>
|
||
<Pref label="Bold">
|
||
<Switch checked={s.subtitleBold} onChange={(v) => set('subtitleBold', v)} />
|
||
</Pref>
|
||
<Pref label="Position">
|
||
<Segmented<SubtitlePosition>
|
||
value={s.subtitlePosition}
|
||
onChange={(v) => set('subtitlePosition', v)}
|
||
options={[
|
||
{ value: 'low', label: 'Low' },
|
||
{ value: 'normal', label: 'Normal' },
|
||
{ value: 'high', label: 'Raised' },
|
||
]}
|
||
/>
|
||
</Pref>
|
||
</SettingsSection>
|
||
</>
|
||
);
|
||
case 'interface':
|
||
return (
|
||
<SettingsSection title="Interface" description="Kaleido keeps the same artwork-led look as its TV app.">
|
||
<Pref label="Artwork colour wash" description="Tints pages with colors from the title’s artwork.">
|
||
<Switch checked={s.colorWash} onChange={(v) => set('colorWash', v)} />
|
||
</Pref>
|
||
<Pref label="Rotate featured titles" description="Cycles the featured title on Home and Discover every 8 seconds.">
|
||
<Switch checked={s.heroRotation} onChange={(v) => set('heroRotation', v)} />
|
||
</Pref>
|
||
<Pref label="Poster size" description="Card size in library grids.">
|
||
<Select
|
||
value={s.posterSize}
|
||
onChange={(v) => set('posterSize', v)}
|
||
options={[
|
||
{ value: 'compact', label: 'Compact' },
|
||
{ value: 'comfortable', label: 'Comfortable' },
|
||
{ value: 'large', label: 'Large' },
|
||
]}
|
||
/>
|
||
</Pref>
|
||
<Pref label="Theme music" description="Plays a show or movie’s theme on its page.">
|
||
<Switch checked={s.themeMusic} onChange={(v) => set('themeMusic', v)} />
|
||
</Pref>
|
||
<Pref label="Theme music volume">
|
||
<Select value={s.themeVolume} disabled={!s.themeMusic} onChange={(v) => set('themeVolume', v)} options={[15, 30, 50, 75, 100].map((v) => ({ value: v, label: `${v}%` }))} />
|
||
</Pref>
|
||
<Pref label="Reduce motion" description="Turns off transitions and animations.">
|
||
<Switch checked={s.reducedMotion} onChange={(v) => set('reducedMotion', v)} />
|
||
</Pref>
|
||
</SettingsSection>
|
||
);
|
||
case 'downloads':
|
||
return (
|
||
<SettingsSection title="Offline media" description="Downloads keep the original file, so they play exactly as on your server.">
|
||
<Pref label="Download folder" description={downloads.dir || info?.defaultDownloadDir || 'Not set'}>
|
||
<Button variant="ghost" size="sm" icon="folder" disabled={!isNative} onClick={async () => {
|
||
const dir = await pickFolder(downloads.dir);
|
||
if (dir) await downloads.setDir(dir);
|
||
}}>
|
||
Change
|
||
</Button>
|
||
{downloads.dir && (
|
||
<Button variant="ghost" size="sm" onClick={() => revealPath(downloads.dir)}>
|
||
Open
|
||
</Button>
|
||
)}
|
||
</Pref>
|
||
<Pref label="Resume interrupted downloads" description="Downloads in progress when Kaleido closed continue automatically when it reconnects.">
|
||
<span className="muted">Always</span>
|
||
</Pref>
|
||
</SettingsSection>
|
||
);
|
||
case 'shortcuts':
|
||
return (
|
||
<div className="shortcut-columns">
|
||
{SHORTCUTS.map((group, i) => (
|
||
<SettingsSection key={i} title={i === 0 ? 'Browsing' : 'Player'}>
|
||
{group.map(([k, label]) => (
|
||
<Pref key={label} label={label}>
|
||
<span className="kbd">{k}</span>
|
||
</Pref>
|
||
))}
|
||
</SettingsSection>
|
||
))}
|
||
</div>
|
||
);
|
||
case 'about':
|
||
return (
|
||
<>
|
||
<div className="about-app">
|
||
<KaleidoMark size={56} />
|
||
<div>
|
||
<h2>Kaleido</h2>
|
||
<p className="muted">
|
||
Version {info?.version ?? '—'} · {OS_NAMES[info?.platform ?? ''] ?? info?.platform}
|
||
</p>
|
||
</div>
|
||
</div>
|
||
<SettingsSection title="Updates" description="Kaleido checks for new versions when it starts and installs them with your permission.">
|
||
<Pref
|
||
label={updater.available ? `Kaleido ${updater.available.version} is available` : updater.checking ? 'Checking…' : 'You’re up to date'}
|
||
description={updater.error || (updater.available?.notes ? updater.available.notes : updater.checkedAt ? `Last checked ${new Date(updater.checkedAt).toLocaleTimeString()}` : '')}
|
||
>
|
||
{updater.available ? (
|
||
<Button variant="primary" size="sm" icon="download" busy={updater.installing} onClick={installUpdate}>
|
||
{updater.installing ? `Installing ${Math.round(updater.progress * 100)}%` : 'Install and restart'}
|
||
</Button>
|
||
) : (
|
||
<Button variant="ghost" size="sm" icon="refresh" busy={updater.checking} disabled={!isNative} onClick={() => checkForUpdate(true)}>
|
||
Check now
|
||
</Button>
|
||
)}
|
||
</Pref>
|
||
</SettingsSection>
|
||
<SettingsSection title="Information">
|
||
<Pref label="Plex client identifier" description={localStorage.getItem('kaleido.clientId') ?? ''} />
|
||
{info?.dataDir && (
|
||
<Pref label="App data" description={info.dataDir}>
|
||
<Button variant="ghost" size="sm" onClick={() => revealPath(info.dataDir)}>
|
||
Open
|
||
</Button>
|
||
</Pref>
|
||
)}
|
||
<Pref label="Source code" description="git.elijahkuntz.com/Elijah/Kaleido-Desktop">
|
||
<Button variant="ghost" size="sm" icon="external" onClick={() => openExternal('https://git.elijahkuntz.com/Elijah/Kaleido-Desktop')}>
|
||
Open
|
||
</Button>
|
||
</Pref>
|
||
<Pref label="Reset preferences" description="Restores Kaleido’s settings. Your sign-in and downloads are kept.">
|
||
<Button variant="ghost" size="sm" onClick={() => confirmDialog({ title: 'Reset preferences?', message: 'Playback, subtitle and interface settings return to their defaults.', confirm: 'Reset' }).then((ok) => ok && s.reset())}>
|
||
Reset
|
||
</Button>
|
||
</Pref>
|
||
</SettingsSection>
|
||
<p className="legal">Kaleido is an independent project and is not affiliated with Plex. Video playback uses mpv (libmpv), licensed under the LGPL.</p>
|
||
</>
|
||
);
|
||
default:
|
||
return null;
|
||
}
|
||
}
|