Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/tauri/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useShellStore } from "./stores/shell";
import { useShellStatusStore } from "./stores/shellStatus";
import { useConnectionsStore } from "./stores/connections";
import { useShellNavStore } from "./stores/shellNav";
import { usePreferencesStore } from "./stores/preferences";
import { initTheme } from "./theme/queryaTheme";
import { provideQueryaMotion } from "./motion";
import { buildCoreCommands, type AppCommand } from "./commands/registry";
Expand All @@ -27,6 +28,7 @@ const shell = useShellStore();
const status = useShellStatusStore();
const connections = useConnectionsStore();
const nav = useShellNavStore();
usePreferencesStore(); // hydrate prefs + --q-ui-scale on boot
const { surface } = storeToRefs(nav);

const prefsOpen = ref(false);
Expand Down
113 changes: 113 additions & 0 deletions apps/tauri/src/preferences/shortcutsCatalog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
export type ShortcutCategory = "SQL Editor" | "Data Grid" | "Navigation & App";

export type ShortcutItem = {
category: ShortcutCategory;
action: string;
keys: string[];
altKeys?: string[][];
description?: string;
};

const isMac =
typeof navigator !== "undefined" &&
/Mac|iPhone|iPad/.test(navigator.platform);

export const modKey = isMac ? "⌘" : "Ctrl";

/** Flutter Preferences shortcuts reference (read-only catalog). */
export const allShortcuts: ShortcutItem[] = [
{
category: "SQL Editor",
action: "Execute query / selection",
keys: [modKey, "Enter"],
altKeys: [[modKey, "R"]],
description: "Runs statement under cursor or selected text",
},
{
category: "SQL Editor",
action: "Execute all statements",
keys: [modKey, "Shift", "Enter"],
altKeys: [["F5"]],
description: "Runs the script one statement at a time",
},
{
category: "SQL Editor",
action: "New query tab",
keys: [modKey, "T"],
description: "Opens a new independent SQL tab session",
},
{
category: "SQL Editor",
action: "Close current tab",
keys: [modKey, "W"],
},
{
category: "SQL Editor",
action: "Query history",
keys: [modKey, "H"],
},
{
category: "SQL Editor",
action: "Format SQL statement",
keys: ["Shift", "Alt", "F"],
},
{
category: "Data Grid",
action: "Copy cell value",
keys: [modKey, "C"],
},
{
category: "Data Grid",
action: "Set cell to NULL",
keys: ["Delete"],
altKeys: [["Backspace"]],
},
{
category: "Data Grid",
action: "Toggle edit mode",
keys: [modKey, "E"],
},
{
category: "Data Grid",
action: "Refresh results",
keys: ["F5"],
},
{
category: "Navigation & App",
action: "Toggle sidebar",
keys: [modKey, "B"],
},
{
category: "Navigation & App",
action: "Command palette",
keys: [modKey, "P"],
},
{
category: "Navigation & App",
action: "Go to object",
keys: [modKey, "K"],
},
{
category: "Navigation & App",
action: "Preferences",
keys: [modKey, ","],
},
{
category: "Navigation & App",
action: "New connection",
keys: [modKey, "N"],
},
{
category: "Navigation & App",
action: "Find in preferences",
keys: [modKey, "F"],
description: "Focuses the Preferences filter field",
},
];

export const shortcutCategories = [
"All",
"SQL Editor",
"Data Grid",
"Navigation & App",
] as const satisfies ReadonlyArray<"All" | ShortcutCategory>;
29 changes: 23 additions & 6 deletions apps/tauri/src/stores/preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ export type PrefsState = {
updateChannel: "stable" | "dev";
confirmDestructive: boolean;
editorFontSize: number;
/** null = no limit */
pgTimeoutSec: number | null;
mysqlTimeoutSec: number | null;
sqliteTimeoutSec: number | null;
historyMax: number;
maxResultRows: number;
mcpEnabled: boolean;
extensionsSideload: boolean;
uiScale: number;
animateThemeChanges: boolean;
};

const defaults: PrefsState = {
Expand All @@ -28,34 +30,49 @@ const defaults: PrefsState = {
historyMax: 200,
maxResultRows: 5000,
mcpEnabled: false,
extensionsSideload: true,
uiScale: 100,
animateThemeChanges: true,
};

function load(): PrefsState {
try {
const raw = localStorage.getItem(STORAGE_KEY);
if (!raw) return { ...defaults };
return { ...defaults, ...JSON.parse(raw) };
const parsed = JSON.parse(raw) as Partial<PrefsState>;
return { ...defaults, ...parsed };
} catch {
return { ...defaults };
}
}

/** App preferences — Flutter PreferencesDialog shape, localStorage for now. */
function applyUiScale(percent: number) {
document.documentElement.style.setProperty(
"--q-ui-scale",
String(percent / 100),
);
}

/** Flutter PreferencesDialog shape — localStorage until app settings land. */
export const usePreferencesStore = defineStore("preferences", () => {
const state = reactive<PrefsState>(load());

watch(
state,
() => {
localStorage.setItem(STORAGE_KEY, JSON.stringify(state));
applyUiScale(state.uiScale);
},
{ deep: true },
{ deep: true, immediate: true },
);

function resetAppearance() {
state.uiScale = defaults.uiScale;
state.animateThemeChanges = defaults.animateThemeChanges;
}

function reset() {
Object.assign(state, defaults);
}

return { state, reset };
return { state, reset, resetAppearance };
});
6 changes: 6 additions & 0 deletions apps/tauri/src/styles/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
box-sizing: border-box;
}

html {
/* Preferences → Appearance → Interface scale (Flutter ui_scale). */
--q-ui-scale: 1;
}

html,
body,
#app {
Expand All @@ -27,4 +32,5 @@ body {
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
zoom: var(--q-ui-scale);
}
Loading
Loading