mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
88 lines
3.1 KiB
QML
88 lines
3.1 KiB
QML
|
|
/*
|
||
|
|
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
||
|
|
*
|
||
|
|
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||
|
|
*/
|
||
|
|
|
||
|
|
import QtQuick 2.15
|
||
|
|
import QtQuick.Controls 2.15
|
||
|
|
import QtQuick.Layouts 1.1
|
||
|
|
import QtQuick.Window 2.2
|
||
|
|
|
||
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||
|
|
import org.kde.plasma.components 3.0 as PlasmaComponents
|
||
|
|
|
||
|
|
import "../components" as Components
|
||
|
|
import "../widgets" as Widgets
|
||
|
|
import "quicksettings"
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Root element that contains all of the ActionDrawer's contents, and is anchored to the screen.
|
||
|
|
*/
|
||
|
|
PlasmaCore.ColorScope {
|
||
|
|
id: root
|
||
|
|
|
||
|
|
required property var actionDrawer
|
||
|
|
|
||
|
|
readonly property real minimizedQuickSettingsOffset: quickSettings.minimizedHeight
|
||
|
|
readonly property real maximizedQuickSettingsOffset: minimizedQuickSettingsOffset + quickSettings.maxAddedHeight
|
||
|
|
|
||
|
|
colorGroup: PlasmaCore.Theme.ViewColorGroup
|
||
|
|
|
||
|
|
function applyMinMax(val) {
|
||
|
|
return Math.max(0, Math.min(1, val));
|
||
|
|
}
|
||
|
|
|
||
|
|
// fullscreen background
|
||
|
|
Rectangle {
|
||
|
|
anchors.fill: parent
|
||
|
|
color: Qt.rgba(PlasmaCore.Theme.backgroundColor.r, PlasmaCore.Theme.backgroundColor.g, PlasmaCore.Theme.backgroundColor.b, 0.95)
|
||
|
|
opacity: Math.max(0, Math.min(1, actionDrawer.offset / root.minimizedQuickSettingsOffset))
|
||
|
|
}
|
||
|
|
|
||
|
|
QuickSettingsDrawer {
|
||
|
|
id: quickSettings
|
||
|
|
z: 1 // ensure it's above notifications
|
||
|
|
anchors.top: parent.top
|
||
|
|
anchors.left: parent.left
|
||
|
|
anchors.right: parent.right
|
||
|
|
|
||
|
|
actionDrawer: root.actionDrawer
|
||
|
|
|
||
|
|
// opacity and move animation
|
||
|
|
property real offsetDist: actionDrawer.offset - minimizedQuickSettingsOffset
|
||
|
|
property real totalOffsetDist: maximizedQuickSettingsOffset - minimizedQuickSettingsOffset
|
||
|
|
minimizedToFullProgress: actionDrawer.opened ? applyMinMax(offsetDist / totalOffsetDist) : 0
|
||
|
|
|
||
|
|
addedHeight: {
|
||
|
|
if (!actionDrawer.opened) {
|
||
|
|
// over-scroll effect for initial opening
|
||
|
|
let progress = (root.actionDrawer.offset - minimizedQuickSettingsOffset) / quickSettings.maxAddedHeight;
|
||
|
|
let effectProgress = Math.atan(Math.max(0, progress));
|
||
|
|
return quickSettings.maxAddedHeight * 0.25 * effectProgress;
|
||
|
|
} else {
|
||
|
|
return Math.max(0, Math.min(quickSettings.maxAddedHeight, root.actionDrawer.offset - minimizedQuickSettingsOffset));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
transform: Translate {
|
||
|
|
id: translate
|
||
|
|
y: Math.min(root.actionDrawer.offset - minimizedQuickSettingsOffset, 0)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
Widgets.NotificationsWidget {
|
||
|
|
anchors {
|
||
|
|
top: quickSettings.top
|
||
|
|
topMargin: quickSettings.height + translate.y
|
||
|
|
bottom: parent.bottom
|
||
|
|
bottomMargin: PlasmaCore.Units.largeSpacing
|
||
|
|
left: parent.left
|
||
|
|
leftMargin: PlasmaCore.Units.largeSpacing
|
||
|
|
right: parent.right
|
||
|
|
rightMargin: PlasmaCore.Units.largeSpacing
|
||
|
|
}
|
||
|
|
opacity: applyMinMax(root.actionDrawer.offset / root.minimizedQuickSettingsOffset)
|
||
|
|
}
|
||
|
|
}
|