shift-shell/lookandfeel/contents/logout/Logout.qml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

181 lines
4.8 KiB
QML
Raw Normal View History

2021-03-01 20:03:25 +00:00
/*
* SPDX-FileCopyrightText: 2014 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
* SPDX-FileCopyrightText: 2020 Linus Jahn <lnj@kaidan.im>
* SPDX-FileCopyrightText: 2020 Marco Martin <mart@kde.org
* SPDX-FileCopyrightText: 2022 Seshan Ravikumar <seshan10@me.com>
2021-03-01 20:03:25 +00:00
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
2020-02-08 11:25:12 +00:00
import QtQuick 2.12
import QtQuick.Layouts 1.12
2020-02-08 12:06:39 +00:00
import QtQuick.Controls 2.8 as Controls
2020-02-08 11:25:12 +00:00
import org.kde.kirigami 2.20 as Kirigami
import org.kde.coreaddons 1.0 as KCoreAddons
2020-02-08 11:25:12 +00:00
import org.kde.plasma.private.sessions 2.0
Item {
2020-02-08 11:25:12 +00:00
id: root
Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
Kirigami.Theme.inherit: false
2020-02-08 11:25:12 +00:00
signal logoutRequested()
signal haltRequested()
signal suspendRequested(int spdMethod)
signal rebootRequested()
signal rebootRequested2(int opt)
signal cancelRequested()
signal lockScreenRequested()
Controls.Action {
onTriggered: root.cancelRequested()
shortcut: "Escape"
}
2024-07-27 03:47:44 +00:00
Rectangle {
id: blackOverlay
anchors.fill: parent
color: "black"
opacity: 0
z: opacity > 0 ? 1 : 0
}
2020-02-08 11:25:12 +00:00
Rectangle {
2020-08-20 11:04:02 +00:00
id: background
2020-02-08 11:25:12 +00:00
anchors.fill: parent
color: Kirigami.Theme.backgroundColor
2020-08-20 11:04:02 +00:00
opacity: 0
2020-02-08 11:25:12 +00:00
}
MouseArea {
anchors.fill: parent
2020-08-20 11:04:02 +00:00
onClicked: {
2020-08-20 13:53:02 +00:00
closeAnim.execute(root.cancelRequested);
2020-08-20 11:04:02 +00:00
}
2020-02-08 11:25:12 +00:00
}
2020-08-20 11:04:02 +00:00
Component.onCompleted: openAnim.restart()
onVisibleChanged: {
if (visible) {
openAnim.restart()
}
2020-02-08 11:25:12 +00:00
}
2020-08-20 11:04:02 +00:00
ParallelAnimation {
id: openAnim
running: true
2020-08-20 11:04:02 +00:00
OpacityAnimator {
target: buttons
2020-08-20 11:04:02 +00:00
from: 0
to: 1
duration: Kirigami.Units.longDuration
2020-08-20 11:04:02 +00:00
easing.type: Easing.InOutQuad
}
OpacityAnimator {
target: background
from: 0
2020-08-20 13:53:02 +00:00
to: 0.6
duration: Kirigami.Units.longDuration
2020-08-20 11:04:02 +00:00
easing.type: Easing.InOutQuad
}
}
2020-08-20 13:53:02 +00:00
SequentialAnimation {
2020-08-20 11:04:02 +00:00
id: closeAnim
running: false
property bool closeToBlack: false
2020-08-20 13:53:02 +00:00
property var callback
function execute(call) {
callback = call;
closeAnim.restart();
2020-08-20 11:04:02 +00:00
}
2020-08-20 13:53:02 +00:00
ParallelAnimation {
OpacityAnimator {
target: buttons
2020-08-20 13:53:02 +00:00
from: 1
to: 0
duration: Kirigami.Units.longDuration
2020-08-20 13:53:02 +00:00
easing.type: Easing.InOutQuad
}
OpacityAnimator {
target: background
from: 0.6
to: 0
duration: Kirigami.Units.longDuration
2020-08-20 13:53:02 +00:00
easing.type: Easing.InOutQuad
}
OpacityAnimator {
target: blackOverlay
from: 0
to: closeAnim.closeToBlack ? 1 : 0
duration: Kirigami.Units.longDuration
easing.type: Easing.InOutQuad
}
2020-08-20 11:04:02 +00:00
}
2020-08-20 13:53:02 +00:00
ScriptAction {
script: {
if (closeAnim.callback) {
closeAnim.callback();
}
buttons.opacity = 1;
2020-08-20 13:53:02 +00:00
background.opacity = 0.6;
}
2020-08-20 11:04:02 +00:00
}
}
2024-07-27 03:47:44 +00:00
Item {
id: buttons
anchors.fill: parent
2020-08-20 11:04:02 +00:00
opacity: 0
2024-07-27 03:47:44 +00:00
ColumnLayout {
anchors.centerIn: parent
spacing: Kirigami.Units.gridUnit
ActionButton {
iconSource: "system-reboot"
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Restart")
onClicked: {
closeAnim.closeToBlack = true;
closeAnim.execute(root.rebootRequested);
}
2020-02-08 11:25:12 +00:00
}
ActionButton {
iconSource: "system-shutdown"
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Shut Down")
onClicked: {
closeAnim.closeToBlack = true;
closeAnim.execute(root.haltRequested);
}
2020-08-20 11:04:02 +00:00
}
ActionButton {
iconSource: "system-log-out"
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Log Out")
onClicked: {
closeAnim.closeToBlack = true;
closeAnim.execute(root.logoutRequested);
}
}
}
2024-07-27 03:47:44 +00:00
ActionButton {
anchors {
bottom: parent.bottom
bottomMargin: Kirigami.Units.gridUnit
horizontalCenter: parent.horizontalCenter
}
2020-08-20 11:04:02 +00:00
iconSource: "dialog-cancel"
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Cancel")
onClicked: {
closeAnim.closeToBlack = false;
2020-08-20 13:53:02 +00:00
closeAnim.execute(root.cancelRequested);
2020-02-08 11:25:12 +00:00
}
}
2020-02-08 11:25:12 +00:00
}
}