File: LockScreen.qml

package info (click to toggle)
kscreenlocker 6.5.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,172 kB
  • sloc: cpp: 5,698; xml: 88; sh: 32; makefile: 5
file content (106 lines) | stat: -rw-r--r-- 2,680 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
SPDX-FileCopyrightText: 2011 Martin Gräßlin <mgraesslin@kde.org>
SPDX-FileCopyrightText: 2023 Nate Graham <nate@kde.org>

SPDX-License-Identifier: GPL-2.0-or-later
*/

import QtQuick 2.15
import QtQuick.Controls as QQC2

import org.kde.kirigami 2.20 as Kirigami
import org.kde.plasma.core as PlasmaCore
import org.kde.kquickcontrolsaddons 2.0
import org.kde.ksvg 1.0 as KSvg
import org.kde.plasma.private.sessions 2.0

Item {
    id: lockScreen

    property alias capsLockOn: unlockUI.capsLockOn
    property bool locked: false

    signal unlockRequested()

    // if there's no image, have a pure black background
    Rectangle {
        width: parent.width
        height: parent.height
        color: "black"
    }

    SessionManagement {
        id: sessionManagment
    }

    Image {
        anchors.fill: parent
        source: "file:" + PlasmaCore.Theme.wallpaperPathForSize(parent.width, parent.height)
        smooth: true
    }

    KSvg.FrameSvgItem {
        id: dialog

        visible: lockScreen.locked
        anchors.centerIn: parent
        width: mainStack.currentItem.implicitWidth + margins.left + margins.right
        height: mainStack.currentItem.implicitHeight + margins.top + margins.bottom
        imagePath: "widgets/background"

        Behavior on height {
            enabled: mainStack.currentItem != null
            NumberAnimation {
                duration: Kirigami.Units.longDuration
            }
        }
        Behavior on width {
            enabled: mainStack.currentItem != null
            NumberAnimation {
                duration: Kirigami.Units.longDuration
            }
        }

        QQC2.StackView {
            id: mainStack

            clip: true
            anchors {
                fill: parent
                leftMargin: dialog.margins.left
                topMargin: dialog.margins.top
                rightMargin: dialog.margins.right
                bottomMargin: dialog.margins.bottom
            }
            initialItem: unlockUI
        }
    }

    Greeter {
        id: unlockUI

        switchUserEnabled: sessionManagment.canSwitchUser

        visible: opacity > 0
        opacity: mainStack.currentItem == unlockUI
        Behavior on opacity {
            NumberAnimation {
                duration: Kirigami.Units.longDuration
            }
        }

        Connections {
            function onAccepted() {
                lockScreen.unlockRequested();
            }
            function onSwitchUserClicked() {
                sessionManagment.switchUser();
            }
        }
    }

    function returnToLogin() {
        mainStack.pop();
        unlockUI.resetFocus();
    }
}