fix(settings): simplify title bar settings to hide-only option

Remove "Use QBZ title bar" toggle since switching to system decorations
doesn't work reliably on Linux when the window was created without
decorations. Keep only "Hide title bar" option for tiling WM users.
This commit is contained in:
vicrodh committed 2026-01-23 16:28:50 -06:00
1 parent 150513179d
commit 3fb597f3fb
5 files changed
+8 -87

No files matched your search

+7 -66
View File
@@ -4,17 +4,12 @@
* 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
@@ -27,22 +22,14 @@ function notifyListeners(): void {
}
/**
* Initialize the store from localStorage and apply settings
* Initialize the store from localStorage
*/
export async function initTitleBarStore(): Promise<void> {
export function initTitleBarStore(): 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);
}
@@ -58,24 +45,17 @@ export function subscribe(listener: () => void): () => void {
}
/**
* Get current settings
* Get current setting
*/
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)
* Determine if the title bar should be visible
*/
export function shouldShowTitleBar(): boolean {
if (hideTitleBar) return false;
return useCustomTitleBar;
return !hideTitleBar;
}
/**
@@ -83,53 +63,16 @@ export function shouldShowTitleBar(): boolean {
* 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();
return hideTitleBar ? 0 : 32;
}
/**
* Set whether to hide title bar completely
*/
export async function setHideTitleBar(value: boolean): Promise<void> {
export function setHideTitleBar(value: boolean): 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);
}
@@ -137,7 +80,6 @@ export async function setHideTitleBar(value: boolean): Promise<void> {
}
export interface TitleBarState {
useCustomTitleBar: boolean;
hideTitleBar: boolean;
showTitleBar: boolean;
titleBarHeight: number;
@@ -145,7 +87,6 @@ export interface TitleBarState {
export function getTitleBarState(): TitleBarState {
return {
useCustomTitleBar,
hideTitleBar,
showTitleBar: shouldShowTitleBar(),
titleBarHeight: getTitleBarHeight()