Files
z-bar-qt/Modules/Settings/Pages.qml
T
zach dbb51ceadd
C++ / fmt (pull_request) Failing after 4s
C++ / build (pull_request) Failing after 12s
JS/TS / fmt (pull_request) Successful in 15s
JS/TS / lint (pull_request) Successful in 15s
C++ / clang-tidy (pull_request) Failing after 33s
Python / static (pull_request) Failing after 36s
Rust / fmt (pull_request) Successful in 1m14s
Rust / build (pull_request) Successful in 1m49s
Rust / clippy (pull_request) Successful in 1m33s
Python / verify (pull_request) Successful in 2m10s
feat: config object migration path and add new options to settings
2026-08-31 18:43:41 +02:00

114 lines
2.1 KiB
QML

import QtQuick
import qs.Components
import ZShell.Config
import qs.Services
Item {
id: root
property int animOff
property Item currentItem
property int lastPageIdx
required property SettingsState sState
function loadPage(idx: int): void {
if (currentItem)
currentItem.destroy();
const comp = PageCompRegistry.pageComps[idx] ?? PageCompRegistry.placeholderComp;
const incubator = comp.incubateObject(container, {
sState
});
const attach = () => {
incubator.object.anchors.fill = container;
currentItem = incubator.object;
};
if (incubator.status === Component.Ready)
attach();
else
incubator.onStatusChanged = status => {
if (status === Component.Ready)
attach();
};
}
Item {
id: container
anchors.fill: parent
layer.enabled: opacity < 1
objectName: "PageContainer"
Component.onCompleted: root.loadPage(root.sState.currentPageIdx)
// CustomRect {
// anchors.fill: parent
// color: Qt.alpha(Colors.palette.m3shadow, 0.3)
// opacity: root.sState.dimmed ? 1 : 0
// visible: opacity > 0
// z: 0
//
// Behavior on opacity {
// Anim {}
// }
// }
}
Connections {
function onCurrentPageIdxChanged(): void {
switchAnim.complete();
root.animOff = Tokens.padding.small * (root.sState.currentPageIdx > root.lastPageIdx ? 1 : -1);
switchAnim.start();
root.lastPageIdx = root.sState.currentPageIdx;
}
target: root.sState
}
SequentialAnimation {
id: switchAnim
Anim {
property: "opacity"
target: container
to: 0
type: Anim.DefaultEffects
}
ScriptAction {
script: root.loadPage(root.sState.currentPageIdx)
}
PropertyAction {
property: "topMargin"
target: container.anchors
value: root.animOff
}
PropertyAction {
property: "bottomMargin"
target: container.anchors
value: -root.animOff
}
ParallelAnimation {
Anim {
from: 0
property: "opacity"
target: container
to: 1
type: Anim.SlowEffects
}
Anim {
properties: "topMargin,bottomMargin"
target: container.anchors
to: 0
type: Anim.SlowEffects
}
}
}
}