File: RejectPasswordPathAnimation.qml

package info (click to toggle)
polkit-kde-agent-1 4%3A6.3.6-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 804 kB
  • sloc: cpp: 581; xml: 29; sh: 3; makefile: 3
file content (53 lines) | stat: -rw-r--r-- 1,700 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
    SPDX-FileCopyrightText: 2022 ivan (@ratijas) tkachenko <me@ratijas.tk>

    SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.15
import QtQml 2.15

import org.kde.kirigami 2.20 as Kirigami

PathAnimation {
    id: root

    /** The magnitude/distance/offset of the animation, in the usual device-independent pixels. */
    property real swing: 15

    /**
     * In which direction the target starts moving first.
     * Must be either Qt.LeftToRight or Qt.RightToLeft.
     *
     * By default it is opposite to the application's layout direction, to
     * make an animation feel more "disturbing".
     */
    property int initialDirection: Qt.application.layoutDirection === Qt.RightToLeft ? Qt.LeftToRight : Qt.RightToLeft

    alwaysRunToEnd: true

    // This animation's speed does not depend on user preferences, except when
    // we honor the "reduced animations" special case.
    // Animators with a duration of 0 do not fire reliably, which is why duration is at least 1.
    // see Bug 357532 and QTBUG-39766
    duration: Kirigami.Units.longDuration <= 1 ? 1 : 600
    easing.type: Easing.OutCubic

    path: Path {
        PathPolyline {
            path: {
                const directionFactor = root.initialDirection === Qt.RightToLeft ? -1 : 1;
                const extreme = root.swing * directionFactor;
                const here = Qt.point(extreme, 0);
                const there = Qt.point(-extreme, 0);
                return [
                    Qt.point(0, 0),
                    here, there,
                    here, there,
                    here, there,
                    Qt.point(0, 0),
                ];
            }
        }
    }
}