The compact icon form is now a fit decision, agnostic of the sidebar state: text tabs while every label at the 11 px floor plus the tab chrome and whatever trails the tabs (the playlists button a closed sidebar adds) fits left of the search box, icons only otherwise — or always with "Compact header navigation" on. A closed sidebar used to force the compact form by itself; it now only adds one button to the measure, so a window with room keeps its text tabs. The room is measured from the third sacred button, not from the hidden row (a Row leaves a hidden child's x where it was). The downloads ring and the separator + playlists flyout button move out of the compact row into a trailing group shared by both forms, so a closed sidebar with room keeps its playlists entry; the group hides outright when it has nothing to show. Compact section buttons now call NavFlyout.sectionClicked like the text tabs and the sidebar rows do, so under the click-navigates opt-in a click on an icon lands on the section's first entry instead of only opening the flyout — Purchases was the one compact item that navigated. Settings > Navigation describes the new rule in all eight catalogs (en never carried the old entry). The Purchases navigation gate models headerNavOn and the fit bit: 128 x 3 combinations, still exactly one reachable Purchases entry. cc
59 lines
3.6 KiB
JavaScript
59 lines
3.6 KiB
JavaScript
// Exercise the production QML placement bindings across every navigation mode.
|
|
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import vm from 'node:vm';
|
|
const read = path => fs.readFileSync(new URL('../' + path, import.meta.url), 'utf8');
|
|
const header = read('crates/qbz-qt/qml/shell/HeaderBar.qml');
|
|
const sidebar = read('crates/qbz-qt/qml/shell/Sidebar.qml');
|
|
function binding(source, name) {
|
|
// Binding expressions may contain wrapped parentheses; the blank line is
|
|
// the boundary in these production properties, not a duplicated predicate.
|
|
const start = source.indexOf('readonly property bool ' + name + ':');
|
|
assert(start >= 0, name);
|
|
const next = source.indexOf('\n readonly property', start);
|
|
const blank = source.indexOf('\n\n', start);
|
|
const end = next < 0 ? blank : Math.min(next, blank);
|
|
const declaration = source.slice(start, end);
|
|
return declaration.slice(declaration.indexOf(':') + 1).trim();
|
|
}
|
|
const slots = [...header.matchAll(/\bPurchaseTab \{\s*visible:\s*([^\n]+)/g)].map(m => m[1]);
|
|
// Two slots since Purchases follows the section navigation (sidebar or
|
|
// header): the standalone title-bar entry and its pref are gone.
|
|
assert.equal(slots.length, 2, 'full and compact purchases entries');
|
|
assert.match(header, /onClicked: QbzShell.navigateTo\("purchases"\)/);
|
|
assert.match(sidebar, /id: navColumn[\s\S]*?visible: QbzShell.navInSidebar/);
|
|
let cases = 0;
|
|
for (let bits = 0; bits < 128; bits++) {
|
|
const [showPurchases, offline, navInSidebar, navHeaderCompact,
|
|
systemTitleBar, hideTitleBar, navTabsFit] = Array.from({length: 7}, (_, i) => !!(bits & (1 << i)));
|
|
for (const sidebarState of [0, 1, 2]) {
|
|
const ctx = vm.createContext({
|
|
// navTabsFit is the measured "text tabs fit beside the search box"
|
|
// bit: the form is a fit decision, agnostic of the sidebar state.
|
|
root: {settingsDoc: {showPurchases}, navTabsFit},
|
|
QbzShell: {navInSidebar, navHeaderCompact, sidebarState, systemTitleBar, hideTitleBar},
|
|
QbzSession: {offline},
|
|
});
|
|
const evaluate = expression => vm.runInContext(expression, ctx);
|
|
for (const property of ['headerNavOn', 'headerTabsOn', 'headerCompactOn', 'purchasesInHeader'])
|
|
ctx.root[property] = evaluate(binding(header, property));
|
|
const headerCount = slots.reduce((count, expression, index) => count + Number(evaluate(expression)
|
|
&& (index === 0 ? ctx.root.headerTabsOn : ctx.root.headerCompactOn)), 0);
|
|
const sidebarCount = Number(navInSidebar && sidebarState !== 2 && evaluate(binding(sidebar, 'purchasesVisible')));
|
|
assert.equal(headerCount + sidebarCount, Number(showPurchases && !offline),
|
|
`exactly one reachable Purchases entry: ${JSON.stringify({bits, sidebarState})}`);
|
|
if (!navInSidebar || sidebarState === 2)
|
|
assert.equal(headerCount, Number(showPurchases && !offline), 'Purchases follows header navigation');
|
|
cases++;
|
|
}
|
|
}
|
|
assert.equal(cases, 128 * 3);
|
|
console.log(`Purchases navigation PASS: ${cases} combinations, full/compact/closed sidebar, tabs fit or not, title bars, opt-in and offline`);
|
|
|
|
const shell = read('crates/qbz-qt/qml/shell/AppShell.qml');
|
|
// The bar's z is mode-aware since the 2.1.2 stabilization: Small's seek thumb
|
|
// overlaps the pane above it and needs the lift; the full-height modes sit
|
|
// below the Large cover dock, a later sibling that paints over the bar.
|
|
assert.match(shell, /NowPlayingBar \{[\s\S]*?\bz:\s*(?:1\b|QbzShell\.npbMode === 2 \? 1 : 0)/,
|
|
'transport paints above the content that follows it in Small, and yields to the Large cover dock otherwise');
|