Warning, /plasma/kscreenlocker/greeter/fallbacktheme/LockScreen.qml is written in an unsupported language. File is not indexed.

0001 /*
0002 SPDX-FileCopyrightText: 2011 Martin Gräßlin <mgraesslin@kde.org>
0003 SPDX-FileCopyrightText: 2023 Nate Graham <nate@kde.org>
0004 
0005 SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 import QtQuick 2.15
0009 import QtQuick.Controls as QQC2
0010 
0011 import org.kde.kirigami 2.20 as Kirigami
0012 import org.kde.plasma.core as PlasmaCore
0013 import org.kde.kquickcontrolsaddons 2.0
0014 import org.kde.ksvg 1.0 as KSvg
0015 import org.kde.plasma.private.sessions 2.0
0016 
0017 Item {
0018     id: lockScreen
0019 
0020     property alias capsLockOn: unlockUI.capsLockOn
0021     property bool locked: false
0022 
0023     signal unlockRequested()
0024 
0025     // if there's no image, have a pure black background
0026     Rectangle {
0027         width: parent.width
0028         height: parent.height
0029         color: "black"
0030     }
0031 
0032     SessionsModel {
0033         id: sessionsModel
0034     }
0035 
0036     Image {
0037         anchors.fill: parent
0038         source: "file:" + PlasmaCore.Theme.wallpaperPathForSize(parent.width, parent.height)
0039         smooth: true
0040     }
0041 
0042     KSvg.FrameSvgItem {
0043         id: dialog
0044 
0045         visible: lockScreen.locked
0046         anchors.centerIn: parent
0047         width: mainStack.currentItem.implicitWidth + margins.left + margins.right
0048         height: mainStack.currentItem.implicitHeight + margins.top + margins.bottom
0049         imagePath: "widgets/background"
0050 
0051         Behavior on height {
0052             enabled: mainStack.currentItem != null
0053             NumberAnimation {
0054                 duration: Kirigami.Units.longDuration
0055             }
0056         }
0057         Behavior on width {
0058             enabled: mainStack.currentItem != null
0059             NumberAnimation {
0060                 duration: Kirigami.Units.longDuration
0061             }
0062         }
0063 
0064         QQC2.StackView {
0065             id: mainStack
0066 
0067             clip: true
0068             anchors {
0069                 fill: parent
0070                 leftMargin: dialog.margins.left
0071                 topMargin: dialog.margins.top
0072                 rightMargin: dialog.margins.right
0073                 bottomMargin: dialog.margins.bottom
0074             }
0075             initialItem: unlockUI
0076         }
0077     }
0078 
0079     Greeter {
0080         id: unlockUI
0081 
0082         switchUserEnabled: sessionsModel.canSwitchUser
0083 
0084         visible: opacity > 0
0085         opacity: mainStack.currentItem == unlockUI
0086         Behavior on opacity {
0087             NumberAnimation {
0088                 duration: Kirigami.Units.longDuration
0089             }
0090         }
0091 
0092         Connections {
0093             function onAccepted() {
0094                 lockScreen.unlockRequested();
0095             }
0096             function onSwitchUserClicked() {
0097                 mainStack.push(userSessionsUIComponent);
0098                 mainStack.currentItem.forceActiveFocus();
0099             }
0100         }
0101     }
0102 
0103     function returnToLogin() {
0104         mainStack.pop();
0105         unlockUI.resetFocus();
0106     }
0107 
0108     Component {
0109         id: userSessionsUIComponent
0110 
0111         SessionSwitching {
0112             id: userSessionsUI
0113 
0114             visible: false
0115 
0116             Connections {
0117                 function onSwitchingCanceled() {
0118                     returnToLogin();
0119                 }
0120                 function onSessionActivated() {
0121                     returnToLogin();
0122                 }
0123                 function onNewSessionStarted() {
0124                     returnToLogin();
0125                 }
0126             }
0127         }
0128     }
0129 }