Warning, /plasma/plasma-mobile/look-and-feel/contents/logout/Logout.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   SPDX-FileCopyrightText: 2014 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
0003  *   SPDX-FileCopyrightText: 2020 Linus Jahn <lnj@kaidan.im>
0004  *   SPDX-FileCopyrightText: 2020 Marco Martin <mart@kde.org
0005  *   SPDX-FileCopyrightText: 2022 Seshan Ravikumar <seshan10@me.com>
0006  *
0007  *   SPDX-License-Identifier: GPL-2.0-or-later
0008  */
0009 
0010 import QtQuick 2.12
0011 import QtQuick.Layouts 1.12
0012 import QtQuick.Controls 2.8 as Controls
0013 
0014 import org.kde.plasma.core 2.0 as PlasmaCore
0015 import org.kde.kcoreaddons 1.0 as KCoreAddons
0016 
0017 import org.kde.plasma.private.sessions 2.0
0018 
0019 PlasmaCore.ColorScope {
0020     id: root
0021 
0022     colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
0023     signal logoutRequested()
0024     signal haltRequested()
0025     signal suspendRequested(int spdMethod)
0026     signal rebootRequested()
0027     signal rebootRequested2(int opt)
0028     signal cancelRequested()
0029     signal lockScreenRequested()
0030 
0031     Controls.Action {
0032         onTriggered: root.cancelRequested()
0033         shortcut: "Escape"
0034     }
0035     
0036     Rectangle {
0037         id: blackOverlay
0038         anchors.fill: parent
0039         color: "black"
0040         opacity: 0
0041         z: opacity > 0 ? 1 : 0
0042     }
0043 
0044     Rectangle {
0045         id: background
0046         anchors.fill: parent
0047         color: PlasmaCore.ColorScope.backgroundColor
0048         opacity: 0
0049     }
0050 
0051     MouseArea {
0052         anchors.fill: parent
0053         onClicked: {
0054             closeAnim.execute(root.cancelRequested);
0055         }
0056     }
0057 
0058     Component.onCompleted: openAnim.restart()
0059     onVisibleChanged: {
0060         if (visible) {
0061             openAnim.restart()
0062         }
0063     }
0064 
0065     ParallelAnimation {
0066         id: openAnim
0067         running: true
0068         OpacityAnimator {
0069             target: buttons
0070             from: 0
0071             to: 1
0072             duration: PlasmaCore.Units.longDuration
0073             easing.type: Easing.InOutQuad
0074         }
0075         OpacityAnimator {
0076             target: background
0077             from: 0
0078             to: 0.6
0079             duration: PlasmaCore.Units.longDuration
0080             easing.type: Easing.InOutQuad
0081         }
0082     }
0083 
0084     SequentialAnimation {
0085         id: closeAnim
0086         running: false
0087 
0088         property bool closeToBlack: false
0089         property var callback
0090         function execute(call) {
0091             callback = call;
0092             closeAnim.restart();
0093         }
0094         ParallelAnimation {
0095             OpacityAnimator {
0096                 target: buttons
0097                 from: 1
0098                 to: 0
0099                 duration: PlasmaCore.Units.longDuration
0100                 easing.type: Easing.InOutQuad
0101             }
0102             OpacityAnimator {
0103                 target: background
0104                 from: 0.6
0105                 to: 0
0106                 duration: PlasmaCore.Units.longDuration
0107                 easing.type: Easing.InOutQuad
0108             }
0109             OpacityAnimator {
0110                 target: blackOverlay
0111                 from: 0
0112                 to: closeAnim.closeToBlack ? 1 : 0
0113                 duration: PlasmaCore.Units.longDuration
0114                 easing.type: Easing.InOutQuad
0115             }
0116         }
0117         ScriptAction {
0118             script: {
0119                 if (closeAnim.callback) {
0120                     closeAnim.callback();
0121                 }
0122                 buttons.opacity = 1;
0123                 background.opacity = 0.6;
0124             }
0125         }
0126     }
0127     
0128     Item {
0129         id: buttons
0130         anchors.fill: parent
0131         opacity: 0
0132         
0133         ColumnLayout {
0134             anchors.centerIn: parent
0135             spacing: PlasmaCore.Units.gridUnit
0136 
0137             ActionButton {
0138                 iconSource: "system-reboot"
0139                 text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Restart")
0140                 onClicked: {
0141                     closeAnim.closeToBlack = true;
0142                     closeAnim.execute(root.rebootRequested);
0143                 }
0144             }
0145 
0146             ActionButton {
0147                 iconSource: "system-shutdown"
0148                 text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Shut Down")
0149                 onClicked: {
0150                     closeAnim.closeToBlack = true;
0151                     closeAnim.execute(root.haltRequested);
0152                 }
0153             }
0154 
0155             ActionButton {
0156                 iconSource: "system-log-out"
0157                 text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Log Out")
0158                 onClicked: {
0159                     closeAnim.closeToBlack = true;
0160                     closeAnim.execute(root.logoutRequested);
0161                 }
0162             }
0163         }
0164         
0165         ActionButton {
0166             anchors {
0167                 bottom: parent.bottom
0168                 bottomMargin: PlasmaCore.Units.largeSpacing
0169                 horizontalCenter: parent.horizontalCenter
0170             }
0171             iconSource: "dialog-cancel"
0172             text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Cancel")
0173             onClicked: {
0174                 closeAnim.closeToBlack = false;
0175                 closeAnim.execute(root.cancelRequested);
0176             }
0177         }
0178     }
0179 }