feat(titlebar): add window controls customization store and i18n keys

This commit is contained in:
vicrodh committed 2026-02-25 20:00:15 -06:00
1 parent 76cdfc73b2
commit 736753585e
6 files changed
+349

No files matched your search

+31
View File
@@ -712,6 +712,37 @@
"hideTitleBarDesc": "Titelleiste komplett ausblenden (für Tiling-Window-Manager-Nutzer)",
"searchInTitleBar": "Suche in Titelleiste",
"searchInTitleBarDesc": "Suchfeld in der Titelleiste statt in der Seitenleiste anzeigen",
"windowControlsPosition": "Position der Fenstersteuerung",
"windowControlsPositionDesc": "Fenstersteuerungstasten links oder rechts in der Titelleiste platzieren",
"windowControlsPositionRight": "Rechts",
"windowControlsPositionLeft": "Links",
"windowControlsStyle": "Stil der Fenstersteuerung",
"windowControlsStyleDesc": "Form der Fenstersteuerungstasten wählen",
"windowControlsStyleRectangular": "Rechteckig",
"windowControlsStyleCircular": "Kreisförmig",
"windowControlsStyleSquare": "Quadratisch",
"windowControlsSize": "Größe der Fenstersteuerung",
"windowControlsSizeDesc": "Größe der Fenstersteuerungstasten anpassen",
"windowControlsSizeSmall": "Klein",
"windowControlsSizeNormal": "Normal",
"windowControlsSizeLarge": "Groß",
"windowControlsColorPreset": "Farbvorlage der Fenstersteuerung",
"windowControlsColorPresetDesc": "Farbschema für die Fenstersteuerungstasten wählen",
"windowControlsColorPresetDefault": "Standard",
"windowControlsColorPresetMacOS": "macOS",
"windowControlsColorPresetAdwaita": "Adwaita",
"windowControlsColorPresetMonochrome": "Monochrom",
"windowControlsColorPresetCustom": "Benutzerdefiniert",
"windowControlsCustomColors": "Benutzerdefinierte Farben",
"windowControlsClose": "Schließen",
"windowControlsMaximize": "Maximieren",
"windowControlsMinimize": "Minimieren",
"windowControlsBg": "Hintergrund",
"windowControlsBgHover": "Hintergrund hover",
"windowControlsBgActive": "Hintergrund Klick",
"windowControlsFg": "Symbol",
"windowControlsFgHover": "Symbol hover",
"windowControlsFgActive": "Symbol Klick",
"showPurchases": "Einkäufe anzeigen",
"showPurchasesDesc": "Einkäufe-Bereich in der Seitenleiste zum Durchsuchen und Herunterladen gekaufter Musik anzeigen",
"immersiveDefaultView": "Standard-Ansicht im Immersiv-Modus",
+31
View File
@@ -729,6 +729,37 @@
"hideTitleBarDesc": "Hide the title bar completely (for tiling window manager users)",
"searchInTitleBar": "Search in title bar",
"searchInTitleBarDesc": "Show the search field in the title bar instead of the sidebar",
"windowControlsPosition": "Window controls position",
"windowControlsPositionDesc": "Place the window control buttons on the left or right side of the title bar",
"windowControlsPositionRight": "Right",
"windowControlsPositionLeft": "Left",
"windowControlsStyle": "Window controls style",
"windowControlsStyleDesc": "Choose the shape of the window control buttons",
"windowControlsStyleRectangular": "Rectangular",
"windowControlsStyleCircular": "Circular",
"windowControlsStyleSquare": "Square",
"windowControlsSize": "Window controls size",
"windowControlsSizeDesc": "Adjust the size of the window control buttons",
"windowControlsSizeSmall": "Small",
"windowControlsSizeNormal": "Normal",
"windowControlsSizeLarge": "Large",
"windowControlsColorPreset": "Window controls color preset",
"windowControlsColorPresetDesc": "Choose a color scheme for the window control buttons",
"windowControlsColorPresetDefault": "Default",
"windowControlsColorPresetMacOS": "macOS",
"windowControlsColorPresetAdwaita": "Adwaita",
"windowControlsColorPresetMonochrome": "Monochrome",
"windowControlsColorPresetCustom": "Custom",
"windowControlsCustomColors": "Custom colors",
"windowControlsClose": "Close",
"windowControlsMaximize": "Maximize",
"windowControlsMinimize": "Minimize",
"windowControlsBg": "Bg",
"windowControlsBgHover": "Bg hover",
"windowControlsBgActive": "Bg click",
"windowControlsFg": "Icon",
"windowControlsFgHover": "Icon hover",
"windowControlsFgActive": "Icon click",
"showPurchases": "Show Purchases",
"showPurchasesDesc": "Show the Purchases section in the sidebar for browsing and downloading your purchased music",
"immersiveDefaultView": "Immersive default view",
+31
View File
@@ -729,6 +729,37 @@
"hideTitleBarDesc": "Ocultar completamente la barra de título (para usuarios de gestores de ventanas en mosaico)",
"searchInTitleBar": "Buscar en barra de título",
"searchInTitleBarDesc": "Mostrar el campo de búsqueda en la barra de título en lugar de la barra lateral",
"windowControlsPosition": "Posición de controles de ventana",
"windowControlsPositionDesc": "Ubicar los botones de control de ventana a la izquierda o derecha de la barra de título",
"windowControlsPositionRight": "Derecha",
"windowControlsPositionLeft": "Izquierda",
"windowControlsStyle": "Estilo de controles de ventana",
"windowControlsStyleDesc": "Elegir la forma de los botones de control de ventana",
"windowControlsStyleRectangular": "Rectangular",
"windowControlsStyleCircular": "Circular",
"windowControlsStyleSquare": "Cuadrado",
"windowControlsSize": "Tamaño de controles de ventana",
"windowControlsSizeDesc": "Ajustar el tamaño de los botones de control de ventana",
"windowControlsSizeSmall": "Pequeño",
"windowControlsSizeNormal": "Normal",
"windowControlsSizeLarge": "Grande",
"windowControlsColorPreset": "Preset de color de controles",
"windowControlsColorPresetDesc": "Elegir un esquema de color para los botones de control de ventana",
"windowControlsColorPresetDefault": "Predeterminado",
"windowControlsColorPresetMacOS": "macOS",
"windowControlsColorPresetAdwaita": "Adwaita",
"windowControlsColorPresetMonochrome": "Monocromático",
"windowControlsColorPresetCustom": "Personalizado",
"windowControlsCustomColors": "Colores personalizados",
"windowControlsClose": "Cerrar",
"windowControlsMaximize": "Maximizar",
"windowControlsMinimize": "Minimizar",
"windowControlsBg": "Fondo",
"windowControlsBgHover": "Fondo hover",
"windowControlsBgActive": "Fondo clic",
"windowControlsFg": "Icono",
"windowControlsFgHover": "Icono hover",
"windowControlsFgActive": "Icono clic",
"showPurchases": "Mostrar Compras",
"showPurchasesDesc": "Mostrar la sección de Compras en la barra lateral para explorar y descargar tu música comprada",
"immersiveDefaultView": "Vista predeterminada del modo inmersivo",
+31
View File
@@ -712,6 +712,37 @@
"hideTitleBarDesc": "Masquer complètement la barre de titre (pour les utilisateurs de gestionnaires de fenêtres en mosaïque)",
"searchInTitleBar": "Recherche dans la barre de titre",
"searchInTitleBarDesc": "Afficher le champ de recherche dans la barre de titre au lieu de la barre latérale",
"windowControlsPosition": "Position des contrôles de fenêtre",
"windowControlsPositionDesc": "Placer les boutons de contrôle de fenêtre à gauche ou à droite de la barre de titre",
"windowControlsPositionRight": "Droite",
"windowControlsPositionLeft": "Gauche",
"windowControlsStyle": "Style des contrôles de fenêtre",
"windowControlsStyleDesc": "Choisir la forme des boutons de contrôle de fenêtre",
"windowControlsStyleRectangular": "Rectangulaire",
"windowControlsStyleCircular": "Circulaire",
"windowControlsStyleSquare": "Carré",
"windowControlsSize": "Taille des contrôles de fenêtre",
"windowControlsSizeDesc": "Ajuster la taille des boutons de contrôle de fenêtre",
"windowControlsSizeSmall": "Petit",
"windowControlsSizeNormal": "Normal",
"windowControlsSizeLarge": "Grand",
"windowControlsColorPreset": "Préréglage de couleur des contrôles",
"windowControlsColorPresetDesc": "Choisir un schéma de couleurs pour les boutons de contrôle de fenêtre",
"windowControlsColorPresetDefault": "Par défaut",
"windowControlsColorPresetMacOS": "macOS",
"windowControlsColorPresetAdwaita": "Adwaita",
"windowControlsColorPresetMonochrome": "Monochrome",
"windowControlsColorPresetCustom": "Personnalisé",
"windowControlsCustomColors": "Couleurs personnalisées",
"windowControlsClose": "Fermer",
"windowControlsMaximize": "Agrandir",
"windowControlsMinimize": "Réduire",
"windowControlsBg": "Fond",
"windowControlsBgHover": "Fond survol",
"windowControlsBgActive": "Fond clic",
"windowControlsFg": "Icône",
"windowControlsFgHover": "Icône survol",
"windowControlsFgActive": "Icône clic",
"showPurchases": "Afficher les achats",
"showPurchasesDesc": "Afficher la section Achats dans la barre latérale pour parcourir et télécharger votre musique achetée",
"immersiveDefaultView": "Vue par défaut du mode immersif",
+199
View File
@@ -0,0 +1,199 @@
/**
* Window Controls Store
*
* Manages window control button customization (position, shape, colors)
* with localStorage persistence. Follows the same observable-store pattern
* as titleBarStore / searchBarLocationStore.
*/
const STORAGE_KEY = 'qbz-window-controls';
export type ButtonPosition = 'right' | 'left';
export type ButtonShape = 'rectangular' | 'circular' | 'square';
export type ButtonSize = 'small' | 'normal' | 'large';
export interface ButtonColorSet {
bg: string;
bgHover: string;
bgActive: string;
fg: string;
fgHover: string;
fgActive: string;
}
export interface WindowControlsConfig {
position: ButtonPosition;
shape: ButtonShape;
size: ButtonSize;
minimizeColors: ButtonColorSet;
maximizeColors: ButtonColorSet;
closeColors: ButtonColorSet;
preset: string;
}
// --- Preset Definitions ---
const PRESET_DEFAULT: Omit<WindowControlsConfig, 'position' | 'shape' | 'size'> = {
preset: 'default',
minimizeColors: { bg: 'transparent', bgHover: 'rgba(255,255,255,0.1)', bgActive: 'rgba(255,255,255,0.06)', fg: '#888888', fgHover: '#ffffff', fgActive: '#cccccc' },
maximizeColors: { bg: 'transparent', bgHover: 'rgba(255,255,255,0.1)', bgActive: 'rgba(255,255,255,0.06)', fg: '#888888', fgHover: '#ffffff', fgActive: '#cccccc' },
closeColors: { bg: 'transparent', bgHover: '#e81123', bgActive: '#b20f1c', fg: '#888888', fgHover: '#ffffff', fgActive: '#ffffff' },
};
const PRESET_MACOS: Omit<WindowControlsConfig, 'position' | 'shape' | 'size'> = {
preset: 'macos',
closeColors: { bg: '#ff5f57', bgHover: '#ff3b30', bgActive: '#cc4940', fg: 'transparent', fgHover: '#4d0000', fgActive: '#4d0000' },
maximizeColors: { bg: '#28c840', bgHover: '#00b336', bgActive: '#1a9e32', fg: 'transparent', fgHover: '#004d00', fgActive: '#004d00' },
minimizeColors: { bg: '#febc2e', bgHover: '#f0a000', bgActive: '#cc8800', fg: 'transparent', fgHover: '#4d3800', fgActive: '#4d3800' },
};
const PRESET_ADWAITA: Omit<WindowControlsConfig, 'position' | 'shape' | 'size'> = {
preset: 'adwaita',
minimizeColors: { bg: 'rgba(255,255,255,0.08)', bgHover: 'rgba(255,255,255,0.15)', bgActive: 'rgba(255,255,255,0.05)', fg: '#888888', fgHover: '#ffffff', fgActive: '#cccccc' },
maximizeColors: { bg: 'rgba(255,255,255,0.08)', bgHover: 'rgba(255,255,255,0.15)', bgActive: 'rgba(255,255,255,0.05)', fg: '#888888', fgHover: '#ffffff', fgActive: '#cccccc' },
closeColors: { bg: 'rgba(255,255,255,0.08)', bgHover: '#c0392b', bgActive: '#962d22', fg: '#888888', fgHover: '#ffffff', fgActive: '#ffffff' },
};
const PRESET_MONOCHROME: Omit<WindowControlsConfig, 'position' | 'shape' | 'size'> = {
preset: 'monochrome',
minimizeColors: { bg: 'transparent', bgHover: 'rgba(255,255,255,0.12)', bgActive: 'rgba(255,255,255,0.06)', fg: '#888888', fgHover: '#ffffff', fgActive: '#cccccc' },
maximizeColors: { bg: 'transparent', bgHover: 'rgba(255,255,255,0.12)', bgActive: 'rgba(255,255,255,0.06)', fg: '#888888', fgHover: '#ffffff', fgActive: '#cccccc' },
closeColors: { bg: 'transparent', bgHover: 'rgba(255,255,255,0.12)', bgActive: 'rgba(255,255,255,0.06)', fg: '#888888', fgHover: '#ffffff', fgActive: '#cccccc' },
};
export const PRESETS: Record<string, Omit<WindowControlsConfig, 'position' | 'shape' | 'size'>> = {
default: PRESET_DEFAULT,
macos: PRESET_MACOS,
adwaita: PRESET_ADWAITA,
monochrome: PRESET_MONOCHROME,
};
// --- State ---
let config: WindowControlsConfig = {
position: 'right',
shape: 'rectangular',
size: 'normal',
...PRESET_DEFAULT,
};
// --- Listeners ---
const listeners = new Set<() => void>();
function notifyListeners(): void {
for (const listener of listeners) {
listener();
}
}
function persist(): void {
try {
localStorage.setItem(STORAGE_KEY, JSON.stringify(config));
} catch {
// localStorage not available
}
}
// --- Public API ---
export function initWindowControlsStore(): void {
try {
const saved = localStorage.getItem(STORAGE_KEY);
if (saved) {
const parsed = JSON.parse(saved) as Partial<WindowControlsConfig>;
// Deep-merge color sets so old saved data missing new fields
// (e.g. bgActive/fgActive) gets backfilled from defaults
const defaults = config;
config = {
...defaults,
...parsed,
minimizeColors: { ...defaults.minimizeColors, ...parsed.minimizeColors },
maximizeColors: { ...defaults.maximizeColors, ...parsed.maximizeColors },
closeColors: { ...defaults.closeColors, ...parsed.closeColors },
};
}
} catch {
// localStorage not available or invalid JSON
}
}
export function subscribe(listener: () => void): () => void {
listeners.add(listener);
listener();
return () => listeners.delete(listener);
}
export function getWindowControls(): WindowControlsConfig {
return { ...config };
}
export function setWindowControls(newConfig: Partial<WindowControlsConfig>): void {
config = { ...config, ...newConfig };
persist();
notifyListeners();
}
export function getButtonPosition(): ButtonPosition {
return config.position;
}
export function setButtonPosition(position: ButtonPosition): void {
config = { ...config, position };
persist();
notifyListeners();
}
export function getButtonShape(): ButtonShape {
return config.shape;
}
export function setButtonShape(shape: ButtonShape): void {
config = { ...config, shape };
persist();
notifyListeners();
}
export function getButtonSize(): ButtonSize {
return config.size;
}
export function setButtonSize(size: ButtonSize): void {
config = { ...config, size };
persist();
notifyListeners();
}
export function getPreset(): string {
return config.preset;
}
/**
* Switch to 'custom' preset, keeping current colors intact.
* This reveals the color pickers without overwriting anything.
*/
export function setPresetCustom(): void {
config = { ...config, preset: 'custom' };
persist();
notifyListeners();
}
export function applyPreset(presetName: string): void {
const preset = PRESETS[presetName];
if (preset) {
config = { ...config, ...preset };
persist();
notifyListeners();
}
}
export function setButtonColor(
button: 'minimize' | 'maximize' | 'close',
field: keyof ButtonColorSet,
value: string
): void {
const key = `${button}Colors` as 'minimizeColors' | 'maximizeColors' | 'closeColors';
config = { ...config, [key]: { ...config[key], [field]: value }, preset: 'custom' };
persist();
notifyListeners();
}
+26
View File
@@ -106,6 +106,14 @@
getSearchBarLocation
} from '$lib/stores/searchBarLocationStore';
// Window controls customization store
import {
subscribe as subscribeWindowControls,
initWindowControlsStore,
getWindowControls,
type WindowControlsConfig
} from '$lib/stores/windowControlsStore';
// Keybindings system
import {
registerAction,
@@ -413,6 +421,9 @@
let searchBarLocationPref = $state(getSearchBarLocation());
let titlebarSearchQuery = $state(getSearchQuery());
// Window Controls State
let windowControlsConfig = $state<WindowControlsConfig>(getWindowControls());
// View State (from navigationStore subscription)
let activeView = $state<ViewType>('home');
let selectedPlaylistId = $state<number | null>(null);
@@ -3127,6 +3138,12 @@
searchBarLocationPref = getSearchBarLocation();
});
// Initialize and subscribe to window controls customization
initWindowControlsStore();
const unsubscribeWindowControls = subscribeWindowControls(() => {
windowControlsConfig = getWindowControls();
});
// Sync titlebar search query with search state store
const unsubscribeTitlebarSearch = subscribeSearchQuery((query) => {
titlebarSearchQuery = query;
@@ -3510,6 +3527,7 @@
unsubscribeSidebar();
unsubscribeTitleBar();
unsubscribeSearchBarLocation();
unsubscribeWindowControls();
unsubscribeTitlebarSearch();
unsubscribeOffline();
unsubscribeNav();
@@ -3616,6 +3634,14 @@
searchQuery={titlebarSearchQuery}
onSearchInput={handleTitlebarSearchInput}
onSearchClear={handleTitlebarSearchClear}
controlsPosition={windowControlsConfig.position}
controlsShape={windowControlsConfig.shape}
controlsSize={windowControlsConfig.size}
controlsColors={{
minimize: windowControlsConfig.minimizeColors,
maximize: windowControlsConfig.maximizeColors,
close: windowControlsConfig.closeColors,
}}
/>
{/if}