From ad4ea02547df07538946c9e8ad01a5d8a3106c32 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 6 Feb 2023 13:56:23 +0100 Subject: Add a reduced motion option fixes #1350 --- resources/qml/Root.qml | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'resources/qml/Root.qml') diff --git a/resources/qml/Root.qml b/resources/qml/Root.qml index f60ebac1..49e07d38 100644 --- a/resources/qml/Root.qml +++ b/resources/qml/Root.qml @@ -345,6 +345,63 @@ Pane { anchors.fill: parent initialItem: welcomePage + + Transition { + id: reducedMotionTransitionExit + PropertyAnimation { + property: "opacity" + from: 1 + to:0 + duration: 200 + } + } + Transition { + id: reducedMotionTransitionEnter + SequentialAnimation { + PropertyAction { property: "opacity"; value: 0 } + PauseAnimation { duration: 200 } + PropertyAnimation { + property: "opacity" + from: 0 + to:1 + duration: 200 + } + } + } + + // for some reason direct bindings to a hidden StackView don't work, so manually store and restore here. + property Transition pushEnterOrg + property Transition pushExitOrg + property Transition popEnterOrg + property Transition popExitOrg + property Transition replaceEnterOrg + property Transition replaceExitOrg + Component.onCompleted: { + pushEnterOrg = pushEnter; + popEnterOrg = popEnter; + replaceEnterOrg = replaceEnter; + pushExitOrg = pushExit; + popExitOrg = popExit; + replaceExitOrg = replaceExit; + + updateTrans() + } + + function updateTrans() { + pushEnter = Settings.reducedMotion ? reducedMotionTransitionEnter : pushEnterOrg; + pushExit = Settings.reducedMotion ? reducedMotionTransitionExit : pushExitOrg; + popEnter = Settings.reducedMotion ? reducedMotionTransitionEnter : popEnterOrg; + popExit = Settings.reducedMotion ? reducedMotionTransitionExit : popExitOrg; + replaceEnter = Settings.reducedMotion ? reducedMotionTransitionEnter : replaceEnterOrg; + replaceExit = Settings.reducedMotion ? reducedMotionTransitionExit : replaceExitOrg; + } + + Connections { + target: Settings + function onReducedMotionChanged() { + mainWindow.updateTrans(); + } + } } Component { -- cgit 1.5.1