look-and-feel/logout: Cleanup and fixup animations

This commit is contained in:
Devin Lin 2022-11-27 21:44:45 -05:00
parent 146bccc57f
commit 5be3445187
2 changed files with 56 additions and 37 deletions

View file

@ -19,7 +19,6 @@ Item {
property alias labelRendering: label.renderType property alias labelRendering: label.renderType
property alias circleOpacity: buttonRect.opacity property alias circleOpacity: buttonRect.opacity
property alias circleVisiblity: buttonRect.visible property alias circleVisiblity: buttonRect.visible
property int fontSize: config.fontSize
readonly property bool softwareRendering: GraphicsInfo.api === GraphicsInfo.Software readonly property bool softwareRendering: GraphicsInfo.api === GraphicsInfo.Software
signal clicked signal clicked
@ -59,7 +58,7 @@ Item {
PlasmaComponents3.Label { PlasmaComponents3.Label {
id: label id: label
font.pointSize: Math.max(fontSize + 1,PlasmaCore.Theme.defaultFont.pointSize + 1) font.pointSize: PlasmaCore.Theme.defaultFont.pointSize + 1
anchors { anchors {
centerIn: buttonRect centerIn: buttonRect
} }

View file

@ -32,6 +32,14 @@ PlasmaCore.ColorScope {
onTriggered: root.cancelRequested() onTriggered: root.cancelRequested()
shortcut: "Escape" shortcut: "Escape"
} }
Rectangle {
id: blackOverlay
anchors.fill: parent
color: "black"
opacity: 0
z: opacity > 0 ? 1 : 0
}
Rectangle { Rectangle {
id: background id: background
@ -58,7 +66,7 @@ PlasmaCore.ColorScope {
id: openAnim id: openAnim
running: true running: true
OpacityAnimator { OpacityAnimator {
target: lay target: buttons
from: 0 from: 0
to: 1 to: 1
duration: PlasmaCore.Units.longDuration duration: PlasmaCore.Units.longDuration
@ -77,6 +85,7 @@ PlasmaCore.ColorScope {
id: closeAnim id: closeAnim
running: false running: false
property bool closeToBlack: false
property var callback property var callback
function execute(call) { function execute(call) {
callback = call; callback = call;
@ -84,7 +93,7 @@ PlasmaCore.ColorScope {
} }
ParallelAnimation { ParallelAnimation {
OpacityAnimator { OpacityAnimator {
target: lay target: buttons
from: 1 from: 1
to: 0 to: 0
duration: PlasmaCore.Units.longDuration duration: PlasmaCore.Units.longDuration
@ -97,63 +106,74 @@ PlasmaCore.ColorScope {
duration: PlasmaCore.Units.longDuration duration: PlasmaCore.Units.longDuration
easing.type: Easing.InOutQuad easing.type: Easing.InOutQuad
} }
OpacityAnimator {
target: blackOverlay
from: 0
to: closeAnim.closeToBlack ? 1 : 0
duration: PlasmaCore.Units.longDuration
easing.type: Easing.InOutQuad
}
} }
ScriptAction { ScriptAction {
script: { script: {
if (closeAnim.callback) { if (closeAnim.callback) {
closeAnim.callback(); closeAnim.callback();
} }
lay.opacity = 1; buttons.opacity = 1;
lay.scale = 1;
background.opacity = 0.6; background.opacity = 0.6;
} }
} }
} }
ColumnLayout {
id: lay Item {
anchors { id: buttons
//top: root.top anchors.fill: parent
//horizontalCenter: root.horizontalCenter
centerIn: root
}
spacing: PlasmaCore.Units.gridUnit
opacity: 0 opacity: 0
ActionButton {
iconSource: "system-reboot" ColumnLayout {
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Restart") anchors.centerIn: parent
onClicked: { spacing: PlasmaCore.Units.gridUnit
closeAnim.execute(root.rebootRequested);
}
}
ActionButton { ActionButton {
iconSource: "system-shutdown" iconSource: "system-reboot"
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Shut Down") text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Restart")
onClicked: { onClicked: {
closeAnim.execute(root.haltRequested); closeAnim.closeToBlack = true;
closeAnim.execute(root.rebootRequested);
}
} }
}
ActionButton { ActionButton {
iconSource: "system-log-out" iconSource: "system-shutdown"
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Log Out") text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Shut Down")
onClicked: { onClicked: {
closeAnim.execute(root.logoutRequested); closeAnim.closeToBlack = true;
closeAnim.execute(root.haltRequested);
}
}
ActionButton {
iconSource: "system-log-out"
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Log Out")
onClicked: {
closeAnim.closeToBlack = true;
closeAnim.execute(root.logoutRequested);
}
} }
} }
}
ActionButton { ActionButton {
anchors { anchors {
bottom: root.bottom bottom: parent.bottom
bottomMargin: PlasmaCore.Units.largeSpacing bottomMargin: PlasmaCore.Units.largeSpacing
horizontalCenter: parent.horizontalCenter horizontalCenter: parent.horizontalCenter
} }
iconSource: "dialog-cancel" iconSource: "dialog-cancel"
text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Cancel") text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Cancel")
onClicked: { onClicked: {
closeAnim.closeToBlack = false;
closeAnim.execute(root.cancelRequested); closeAnim.execute(root.cancelRequested);
} }
}
} }
} }