feat(ui): add HiDPI zoom controls and hotkeys
This commit is contained in:
1 parent
540844de9f
commit
05ef074e4f
4 files changed
+63
-1
No files matched your search
@@ -28,6 +28,7 @@
|
||||
"core:webview:default",
|
||||
"core:webview:allow-create-webview-window",
|
||||
"core:webview:allow-webview-close",
|
||||
"core:webview:allow-set-webview-zoom",
|
||||
"opener:default",
|
||||
"dialog:default",
|
||||
"clipboard-manager:default",
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
"minHeight": 600,
|
||||
"decorations": false,
|
||||
"transparent": true,
|
||||
"resizable": true
|
||||
"resizable": true,
|
||||
"zoomHotkeysEnabled": true
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { getCurrent } from '@tauri-apps/api/webview';
|
||||
import { goBack, goForward } from '$lib/stores/navigationStore';
|
||||
|
||||
// ============ Theme Management ============
|
||||
@@ -20,6 +21,22 @@ export function loadSavedTheme(): void {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply saved UI zoom level (Tauri webview zoom)
|
||||
*/
|
||||
export async function applySavedZoom(): Promise<void> {
|
||||
const savedZoom = localStorage.getItem('qbz-zoom-level');
|
||||
if (!savedZoom) return;
|
||||
const zoom = Number.parseFloat(savedZoom);
|
||||
if (!Number.isFinite(zoom) || zoom <= 0) return;
|
||||
|
||||
try {
|
||||
await getCurrent().setZoom(zoom);
|
||||
} catch (err) {
|
||||
console.warn('Failed to apply saved zoom:', err);
|
||||
}
|
||||
}
|
||||
|
||||
// ============ Last.fm Session ============
|
||||
|
||||
/**
|
||||
@@ -87,6 +104,7 @@ export interface BootstrapResult {
|
||||
export function bootstrapApp(): BootstrapResult {
|
||||
// Load theme
|
||||
loadSavedTheme();
|
||||
void applySavedZoom();
|
||||
|
||||
// Setup mouse navigation
|
||||
const cleanupMouse = setupMouseNavigation();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { getCurrent } from '@tauri-apps/api/webview';
|
||||
import { ArrowLeft, FolderOpen, ChevronDown, ChevronRight } from 'lucide-svelte';
|
||||
import Toggle from '../Toggle.svelte';
|
||||
import Dropdown from '../Dropdown.svelte';
|
||||
@@ -120,6 +121,20 @@
|
||||
let crossfade = $state(0);
|
||||
let normalizeVolume = $state(false);
|
||||
|
||||
// UI scale settings
|
||||
const zoomOptions = ['80%', '90%', '100%', '110%', '125%', '150%', '175%', '200%'];
|
||||
const zoomMap: Record<string, number> = {
|
||||
'80%': 0.8,
|
||||
'90%': 0.9,
|
||||
'100%': 1,
|
||||
'110%': 1.1,
|
||||
'125%': 1.25,
|
||||
'150%': 1.5,
|
||||
'175%': 1.75,
|
||||
'200%': 2,
|
||||
};
|
||||
let zoomLevel = $state('100%');
|
||||
|
||||
// Appearance settings
|
||||
let theme = $state('Dark');
|
||||
let compactMode = $state(false);
|
||||
@@ -172,6 +187,14 @@
|
||||
language = savedLanguage;
|
||||
}
|
||||
|
||||
// Load UI zoom level
|
||||
const savedZoom = localStorage.getItem('qbz-zoom-level');
|
||||
if (savedZoom) {
|
||||
const parsed = Number.parseFloat(savedZoom);
|
||||
const match = zoomOptions.find(option => Math.abs((zoomMap[option] ?? 1) - parsed) < 0.01);
|
||||
zoomLevel = match || '100%';
|
||||
}
|
||||
|
||||
// Load cache stats
|
||||
loadCacheStats();
|
||||
|
||||
@@ -681,6 +704,17 @@
|
||||
applyTheme(themeValue);
|
||||
localStorage.setItem('qbz-theme', themeValue);
|
||||
}
|
||||
|
||||
async function handleZoomChange(value: string) {
|
||||
zoomLevel = value;
|
||||
const zoom = zoomMap[value] ?? 1;
|
||||
localStorage.setItem('qbz-zoom-level', String(zoom));
|
||||
try {
|
||||
await getCurrent().setZoom(zoom);
|
||||
} catch (err) {
|
||||
console.warn('Failed to set zoom:', err);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="settings-view">
|
||||
@@ -798,6 +832,14 @@
|
||||
onchange={handleLanguageChange}
|
||||
/>
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<span class="setting-label">UI Scale</span>
|
||||
<Dropdown
|
||||
value={zoomLevel}
|
||||
options={zoomOptions}
|
||||
onchange={handleZoomChange}
|
||||
/>
|
||||
</div>
|
||||
<div class="setting-row last">
|
||||
<span class="setting-label">Compact Mode</span>
|
||||
<Toggle enabled={compactMode} onchange={(v) => (compactMode = v)} />
|
||||
|
||||
Reference in new issue
Block a user