Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | 173x 173x 173x 173x 14x 14x 14x 279x 7x 2x 144x 122x 6x 3x 1x 2x 2x 6x 2x 141x 2x 139x 3x 136x 141x 6x 5x 5x 6x 1x 4x 3x 3x 141x 1x 564x 564x 564x 2x 2x 6x 1x 2x 282x 1x 1x | import { useEffect, useId, useState, type KeyboardEvent } from 'react';
import { DEFAULT_SHORTCUTS, type Action } from '../platform/Desktop';
import { Icon, Logo } from '../Ui';
import {
ACTION_LABELS,
formatShortcut,
isDefault,
toAccelerator,
type Shortcuts,
} from './Shortcuts';
import type { Theme } from './Theme';
import type { Updater, UpdateState } from './Updater';
export type TrayIcon = 'app' | 'white';
export function Appearance({
mac,
blend,
onBlend,
theme,
onTheme,
}: {
mac: boolean;
blend: number;
onBlend: (value: number) => void;
theme: Theme;
onTheme: (theme: Theme) => void;
}) {
const id = useId();
const [strength, setStrength] = useState(blend);
useEffect(() => setStrength(blend), [blend]);
return (
<section
className='panel'
aria-labelledby={`${id}-appearance-title`}
data-tour='appearance'
>
<h2 id={`${id}-appearance-title`}>Appearance</h2>
<div className='settings-group'>
{mac ? (
<div className='setting-row appearance-row'>
<label htmlFor={`${id}-window-design`}>Window design</label>
<div className='appearance-control'>
<input
id={`${id}-window-design`}
className='appearance-slider'
type='range'
min='0'
max='100'
step='1'
value={strength}
aria-valuetext={`${strength}% Liquid Glass`}
onChange={(event) => {
const value = event.target.valueAsNumber;
setStrength(value);
onBlend(value);
}}
/>
<div className='appearance-labels' aria-hidden='true'>
<span>Current</span>
<output htmlFor={`${id}-window-design`}>{strength}%</output>
<span>Liquid Glass</span>
</div>
</div>
</div>
) : (
<div className='setting-row'>
<strong id={`${id}-theme-label`}>Theme</strong>
<div
className='segmented'
role='radiogroup'
aria-labelledby={`${id}-theme-label`}
>
{(['light', 'dark', 'system'] as const).map((option) => (
<button
key={option}
role='radio'
aria-checked={theme === option}
onClick={() => onTheme(option)}
>
{option.charAt(0).toUpperCase() + option.slice(1)}
</button>
))}
</div>
</div>
)}
</div>
</section>
);
}
const TRAY_ICONS: { id: TrayIcon; label: string; mono: boolean }[] = [
{ id: 'white', label: 'White', mono: true },
{ id: 'app', label: 'App icon', mono: false },
];
export function updateMessage(state: UpdateState) {
switch (state.status) {
case 'idle':
return 'New versions come from the Daguerre releases on GitHub.';
case 'checking':
return 'Checking for updates…';
case 'latest':
return "You're up to date.";
case 'unpublished':
return 'No installable update is published on GitHub yet.';
case 'available':
return `Daguerre ${state.version} is available.`;
case 'downloading':
return state.progress === undefined
? `Downloading Daguerre ${state.version}…`
: `Downloading Daguerre ${state.version}… ${Math.round(state.progress * 100)}%`;
case 'ready':
return `Daguerre ${state.version} is installed. Restart to use it.`;
case 'error':
return `Couldn't update: ${state.message}`;
}
}
function UpdateButton({ state, check, install, restart }: Updater) {
if (state.status === 'available')
return (
<button type='button' className='btn primary' onClick={install}>
Install {state.version}
</button>
);
if (state.status === 'ready')
return (
<button type='button' className='btn primary' onClick={restart}>
Restart
</button>
);
return (
<button
type='button'
className='btn'
onClick={check}
disabled={state.status === 'checking' || state.status === 'downloading'}
aria-busy={state.status === 'checking' || state.status === 'downloading'}
>
Check now
</button>
);
}
export function SettingsPage({
shortcuts,
failed,
mac,
wayland,
onShortcuts,
onRecording,
autostart,
onAutostart,
trayIcon,
onTrayIcon,
blend,
onBlend,
theme,
onTheme,
screenAccess,
onRequestAccess,
version,
updater,
}: {
shortcuts: Shortcuts;
failed: Record<string, string>;
mac: boolean;
wayland: boolean;
onShortcuts: (next: Shortcuts) => void;
/** Global shortcuts pause while one is being recorded, so pressing the old keys doesn't capture. */
onRecording: (recording: boolean) => void;
autostart: boolean;
onAutostart: (on: boolean) => void;
trayIcon: TrayIcon;
onTrayIcon: (icon: TrayIcon) => void;
blend: number;
onBlend: (value: number) => void;
theme: Theme;
onTheme: (theme: Theme) => void;
screenAccess: boolean;
onRequestAccess: () => void;
version: string;
updater: Updater;
}) {
const tray = mac ? 'menu bar' : 'system tray';
function record(action: Action, e: KeyboardEvent<HTMLInputElement>) {
if (e.key === 'Tab') return;
e.preventDefault();
const plain = !e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey;
if (plain && (e.key === 'Backspace' || e.key === 'Delete'))
return onShortcuts({ ...shortcuts, [action]: '' });
if (plain && e.key === 'Escape') return e.currentTarget.blur();
const accelerator = toAccelerator(e);
if (accelerator) onShortcuts({ ...shortcuts, [action]: accelerator });
}
return (
<div className='page'>
<header className='page-head' data-tauri-drag-region>
<div>
<h1>Settings</h1>
<p>
{wayland
? 'Capture shortcuts are managed by your desktop.'
: `Shortcuts work in any app while Daguerre runs in the ${tray}.`}
</p>
</div>
</header>
<Appearance
mac={mac}
blend={blend}
onBlend={onBlend}
theme={theme}
onTheme={onTheme}
/>
<section className='panel' aria-labelledby='shortcuts-title'>
<div className='panel-head'>
<div>
<h2 id='shortcuts-title'>Keyboard shortcuts</h2>
<p className='meta' id='shortcut-hint'>
Click a shortcut and press the new keys. Backspace removes it.
</p>
</div>
<button
className='btn ghost'
onClick={() => onShortcuts(DEFAULT_SHORTCUTS)}
disabled={wayland || isDefault(shortcuts)}
>
<Icon name='reset' size={15} />
Restore defaults
</button>
</div>
<ul className='shortcut-table'>
{(Object.keys(ACTION_LABELS) as Action[]).map((action) => {
const id = `shortcut-${action}`;
const accelerator = wayland ? '' : shortcuts[action];
return (
<li key={action} className='shortcut-row'>
<label htmlFor={id}>{ACTION_LABELS[action]}</label>
<div className='shortcut-control'>
<input
id={id}
className='shortcut-input'
readOnly
disabled={wayland}
value={accelerator ? formatShortcut(accelerator, mac) : ''}
placeholder={wayland ? 'Desktop settings' : 'None'}
onFocus={() => onRecording(true)}
onBlur={() => onRecording(false)}
onKeyDown={(e) => record(action, e)}
aria-describedby={
failed[action] ? `${id}-error` : 'shortcut-hint'
}
aria-invalid={!!failed[action]}
/>
<button
className='icon-btn sm'
onClick={() => onShortcuts({ ...shortcuts, [action]: '' })}
disabled={wayland || !shortcuts[action]}
aria-label={`Remove the ${ACTION_LABELS[action]} shortcut`}
title='Remove'
>
<Icon name='close' size={14} />
</button>
</div>
{failed[action] && (
<p className='shortcut-error' id={`${id}-error`} role='alert'>
Couldn't use this shortcut: {failed[action]}
</p>
)}
</li>
);
})}
</ul>
{wayland && (
<p className='panel-note'>
On Wayland, Daguerre uses desktop keyboard shortcuts. Add them in
your desktop's keyboard settings with commands such as{' '}
<code>daguerre --capture selection</code> (also <code>screen</code>{' '}
and <code>copy-selection</code>).
</p>
)}
</section>
<section className='panel' aria-labelledby='general-title'>
<h2 id='general-title'>General</h2>
<div className='settings-group'>
<div className='setting-row'>
<div>
<label htmlFor='autostart'>Open at login</label>
<p className='meta'>Starts quietly in the {tray}.</p>
</div>
<input
id='autostart'
type='checkbox'
role='switch'
className='switch'
checked={autostart}
onChange={(e) => onAutostart(e.target.checked)}
/>
</div>
<div className='setting-row'>
<div>
<strong id='tray-icon-label'>
{mac ? 'Menu bar icon' : 'System tray icon'}
</strong>
<p className='meta' id='tray-icon-hint'>
{mac
? 'Adaptive turns black or white to match the menu bar.'
: `Choose how Daguerre appears in the ${tray}.`}
</p>
</div>
<div
className='segmented'
role='radiogroup'
aria-labelledby='tray-icon-label'
aria-describedby='tray-icon-hint'
>
{TRAY_ICONS.map((opt) => (
<button
key={opt.id}
role='radio'
aria-checked={trayIcon === opt.id}
onClick={() => onTrayIcon(opt.id)}
>
<span
className={
opt.mono
? 'tray-preview tray-preview-mono'
: 'tray-preview'
}
>
<Logo size={opt.mono ? 16 : 18} mono={opt.mono} />
</span>
{mac && opt.mono ? 'Adaptive' : opt.label}
</button>
))}
</div>
</div>
</div>
</section>
{mac && (
<section className='panel' aria-labelledby='permissions-title'>
<h2 id='permissions-title'>Permissions</h2>
<div className='settings-group'>
<div className='setting-row'>
<div>
<strong>Screen Recording</strong>
<p className='meta'>
{screenAccess
? 'Allowed. Daguerre can capture other apps.'
: 'Needed to capture other apps. After allowing it, quit and reopen Daguerre.'}
</p>
</div>
{screenAccess ? (
<span className='status-ok'>
<Icon name='check' size={15} />
Allowed
</span>
) : (
<button className='btn primary' onClick={onRequestAccess}>
Allow
</button>
)}
</div>
</div>
</section>
)}
<section className='panel' aria-labelledby='updates-title'>
<h2 id='updates-title'>Updates</h2>
<div className='settings-group'>
<div className='setting-row'>
<div>
<label htmlFor='auto-update'>Update automatically</label>
<p className='meta'>
Checks GitHub when Daguerre opens and once a day, and installs
new versions.
</p>
</div>
<input
id='auto-update'
type='checkbox'
role='switch'
className='switch'
checked={updater.auto}
onChange={(e) => updater.changeAuto(e.target.checked)}
/>
</div>
<div className='setting-row'>
<div>
<strong>Check for updates</strong>
<p className='meta' role='status'>
{updateMessage(updater.state)}
</p>
</div>
<UpdateButton {...updater} />
</div>
</div>
</section>
<section className='panel' aria-labelledby='about-title'>
<h2 id='about-title'>About</h2>
<div className='about'>
<Logo size={36} />
<div>
<strong>Daguerre {version}</strong>
<p className='meta'>
Screenshots, window titles and settings stay on this device.
Nothing is uploaded.
</p>
</div>
</div>
</section>
</div>
);
}
|