feat(settings): add title bar configuration
Phase 1 implementation: - Add titleBarStore.ts for managing title bar visibility - "Use QBZ title bar" toggle (default ON) - switches between custom and system decorations - "Remove title bar" toggle (default OFF) - hides title bar completely for tiling WM users - Dynamically adjust layout heights when title bar is hidden - Add i18n translations (en/es) - Settings integrate with Tauri window.setDecorations() API
This commit is contained in:
1 parent
921639041c
commit
3ac957ddda
6 files changed
+237
-7
No files matched your search
@@ -49,6 +49,7 @@
|
||||
subscription?: string;
|
||||
isExpanded?: boolean;
|
||||
onToggle?: () => void;
|
||||
showTitleBar?: boolean;
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -65,7 +66,8 @@
|
||||
userName = 'User',
|
||||
subscription = 'Qobuz™',
|
||||
isExpanded = true,
|
||||
onToggle
|
||||
onToggle,
|
||||
showTitleBar = true
|
||||
}: Props = $props();
|
||||
|
||||
let userPlaylists = $state<Playlist[]>([]);
|
||||
@@ -543,7 +545,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<aside class="sidebar" class:collapsed={!isExpanded}>
|
||||
<aside class="sidebar" class:collapsed={!isExpanded} class:no-titlebar={!showTitleBar}>
|
||||
<!-- Scrollable Content Area -->
|
||||
<div class="content">
|
||||
<!-- Search Bar -->
|
||||
@@ -797,6 +799,10 @@
|
||||
min-width: 64px;
|
||||
}
|
||||
|
||||
.sidebar.no-titlebar {
|
||||
height: calc(100vh - 104px); /* Only 104px NowPlayingBar, no title bar */
|
||||
}
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
|
||||
@@ -44,6 +44,13 @@
|
||||
type OfflineSettings
|
||||
} from '$lib/stores/offlineStore';
|
||||
import { showToast } from '$lib/stores/toastStore';
|
||||
import {
|
||||
subscribe as subscribeTitleBar,
|
||||
getUseCustomTitleBar,
|
||||
getHideTitleBar,
|
||||
setUseCustomTitleBar,
|
||||
setHideTitleBar
|
||||
} from '$lib/stores/titleBarStore';
|
||||
import {
|
||||
getPlaybackPreferences,
|
||||
setAutoplayMode,
|
||||
@@ -368,6 +375,10 @@
|
||||
let systemNotificationsEnabled = $state(true);
|
||||
let language = $state('Auto');
|
||||
|
||||
// Title bar settings
|
||||
let useCustomTitleBar = $state(getUseCustomTitleBar());
|
||||
let hideTitleBar = $state(getHideTitleBar());
|
||||
|
||||
// Library settings
|
||||
let fetchQobuzArtistImages = $state(true);
|
||||
let showQobuzDownloadsInLibrary = $state(false);
|
||||
@@ -470,6 +481,12 @@
|
||||
offlineSettings = getOfflineSettings();
|
||||
});
|
||||
|
||||
// Subscribe to title bar state changes
|
||||
const unsubscribeTitleBar = subscribeTitleBar(() => {
|
||||
useCustomTitleBar = getUseCustomTitleBar();
|
||||
hideTitleBar = getHideTitleBar();
|
||||
});
|
||||
|
||||
// Scroll tracking for navigation
|
||||
const handleScroll = () => {
|
||||
if (!settingsViewEl) return;
|
||||
@@ -497,6 +514,7 @@
|
||||
return () => {
|
||||
unsubscribeOffline();
|
||||
unsubscribeZoom();
|
||||
unsubscribeTitleBar();
|
||||
settingsViewEl?.removeEventListener('scroll', handleScroll);
|
||||
};
|
||||
});
|
||||
@@ -1660,10 +1678,28 @@
|
||||
<span class="setting-label">{$t('settings.appearance.inAppToasts')}</span>
|
||||
<Toggle enabled={toastsEnabled} onchange={(v) => { toastsEnabled = v; setToastsEnabled(v); }} />
|
||||
</div>
|
||||
<div class="setting-row last">
|
||||
<div class="setting-row">
|
||||
<span class="setting-label">{$t('settings.appearance.systemNotifications')}</span>
|
||||
<Toggle enabled={systemNotificationsEnabled} onchange={(v) => { systemNotificationsEnabled = v; setSystemNotificationsEnabled(v); }} />
|
||||
</div>
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<span class="setting-label">{$t('settings.appearance.useCustomTitleBar')}</span>
|
||||
<span class="setting-desc">{$t('settings.appearance.useCustomTitleBarDesc')}</span>
|
||||
</div>
|
||||
<Toggle
|
||||
enabled={useCustomTitleBar}
|
||||
disabled={hideTitleBar}
|
||||
onchange={(v) => setUseCustomTitleBar(v)}
|
||||
/>
|
||||
</div>
|
||||
<div class="setting-row last">
|
||||
<div class="setting-info">
|
||||
<span class="setting-label">{$t('settings.appearance.hideTitleBar')}</span>
|
||||
<span class="setting-desc">{$t('settings.appearance.hideTitleBarDesc')}</span>
|
||||
</div>
|
||||
<Toggle enabled={hideTitleBar} onchange={(v) => setHideTitleBar(v)} />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Offline Library Section -->
|
||||
|
||||
@@ -363,7 +363,11 @@
|
||||
"language": "Language",
|
||||
"uiScale": "UI Scale",
|
||||
"inAppToasts": "In-app toasts notifications",
|
||||
"systemNotifications": "System Notifications"
|
||||
"systemNotifications": "System Notifications",
|
||||
"useCustomTitleBar": "Use QBZ title bar",
|
||||
"useCustomTitleBarDesc": "Use the custom QBZ title bar instead of system decorations",
|
||||
"hideTitleBar": "Remove title bar",
|
||||
"hideTitleBarDesc": "Hide the title bar completely (for tiling window manager users)"
|
||||
},
|
||||
"library": {
|
||||
"title": "Library",
|
||||
|
||||
@@ -363,7 +363,11 @@
|
||||
"language": "Idioma",
|
||||
"uiScale": "Escala de UI",
|
||||
"inAppToasts": "Notificaciones en App",
|
||||
"systemNotifications": "Notificaciones del Sistema"
|
||||
"systemNotifications": "Notificaciones del Sistema",
|
||||
"useCustomTitleBar": "Usar barra de título de QBZ",
|
||||
"useCustomTitleBarDesc": "Usar la barra de título personalizada de QBZ en lugar de las decoraciones del sistema",
|
||||
"hideTitleBar": "Ocultar barra de título",
|
||||
"hideTitleBarDesc": "Ocultar completamente la barra de título (para usuarios de gestores de ventanas en mosaico)"
|
||||
},
|
||||
"library": {
|
||||
"title": "Biblioteca",
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
/**
|
||||
* Title Bar Settings Store
|
||||
*
|
||||
* Manages title bar visibility settings with localStorage persistence.
|
||||
*
|
||||
* Settings:
|
||||
* - useCustomTitleBar: Use QBZ custom title bar (default: true)
|
||||
* - hideTitleBar: Remove title bar completely for tiling WM users (default: false)
|
||||
*/
|
||||
|
||||
import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
|
||||
const STORAGE_KEY_CUSTOM = 'qbz-use-custom-titlebar';
|
||||
const STORAGE_KEY_HIDE = 'qbz-hide-titlebar';
|
||||
|
||||
// State
|
||||
let useCustomTitleBar = true;
|
||||
let hideTitleBar = false;
|
||||
|
||||
// Listeners
|
||||
const listeners = new Set<() => void>();
|
||||
|
||||
function notifyListeners(): void {
|
||||
for (const listener of listeners) {
|
||||
listener();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the store from localStorage and apply settings
|
||||
*/
|
||||
export async function initTitleBarStore(): Promise<void> {
|
||||
try {
|
||||
const savedCustom = localStorage.getItem(STORAGE_KEY_CUSTOM);
|
||||
const savedHide = localStorage.getItem(STORAGE_KEY_HIDE);
|
||||
|
||||
if (savedCustom !== null) {
|
||||
useCustomTitleBar = savedCustom === 'true';
|
||||
}
|
||||
if (savedHide !== null) {
|
||||
hideTitleBar = savedHide === 'true';
|
||||
}
|
||||
|
||||
// Apply settings to window
|
||||
await applyTitleBarSettings();
|
||||
} catch (e) {
|
||||
console.error('[TitleBarStore] Failed to initialize:', e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to title bar state changes
|
||||
*/
|
||||
export function subscribe(listener: () => void): () => void {
|
||||
listeners.add(listener);
|
||||
listener();
|
||||
return () => listeners.delete(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current settings
|
||||
*/
|
||||
export function getUseCustomTitleBar(): boolean {
|
||||
return useCustomTitleBar;
|
||||
}
|
||||
|
||||
export function getHideTitleBar(): boolean {
|
||||
return hideTitleBar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the custom title bar should be visible
|
||||
* - Hidden if hideTitleBar is true (tiling WM mode)
|
||||
* - Hidden if useCustomTitleBar is false (using system decorations)
|
||||
*/
|
||||
export function shouldShowTitleBar(): boolean {
|
||||
if (hideTitleBar) return false;
|
||||
return useCustomTitleBar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title bar height for layout calculations
|
||||
* Returns 0 if title bar is hidden, 32 otherwise
|
||||
*/
|
||||
export function getTitleBarHeight(): number {
|
||||
return shouldShowTitleBar() ? 32 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply current settings to the Tauri window
|
||||
*/
|
||||
async function applyTitleBarSettings(): Promise<void> {
|
||||
try {
|
||||
const appWindow = getCurrentWindow();
|
||||
|
||||
if (hideTitleBar) {
|
||||
// No title bar at all - remove decorations
|
||||
await appWindow.setDecorations(false);
|
||||
} else if (useCustomTitleBar) {
|
||||
// Custom title bar - no system decorations
|
||||
await appWindow.setDecorations(false);
|
||||
} else {
|
||||
// System title bar - enable decorations
|
||||
await appWindow.setDecorations(true);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[TitleBarStore] Failed to apply settings:', e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to use custom title bar
|
||||
*/
|
||||
export async function setUseCustomTitleBar(value: boolean): Promise<void> {
|
||||
useCustomTitleBar = value;
|
||||
try {
|
||||
localStorage.setItem(STORAGE_KEY_CUSTOM, String(value));
|
||||
await applyTitleBarSettings();
|
||||
} catch (e) {
|
||||
console.error('[TitleBarStore] Failed to save custom titlebar setting:', e);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to hide title bar completely
|
||||
*/
|
||||
export async function setHideTitleBar(value: boolean): Promise<void> {
|
||||
hideTitleBar = value;
|
||||
try {
|
||||
localStorage.setItem(STORAGE_KEY_HIDE, String(value));
|
||||
await applyTitleBarSettings();
|
||||
} catch (e) {
|
||||
console.error('[TitleBarStore] Failed to save hide titlebar setting:', e);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
export interface TitleBarState {
|
||||
useCustomTitleBar: boolean;
|
||||
hideTitleBar: boolean;
|
||||
showTitleBar: boolean;
|
||||
titleBarHeight: number;
|
||||
}
|
||||
|
||||
export function getTitleBarState(): TitleBarState {
|
||||
return {
|
||||
useCustomTitleBar,
|
||||
hideTitleBar,
|
||||
showTitleBar: shouldShowTitleBar(),
|
||||
titleBarHeight: getTitleBarHeight()
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user