2024-10-31 05:05:44 +00:00
|
|
|
// SPDX-FileCopyrightText: 2021-2024 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: LGPL-2.0-or-later
|
2021-12-22 23:29:00 +00:00
|
|
|
|
|
|
|
|
import QtQuick 2.15
|
|
|
|
|
import QtQuick.Controls 2.15
|
2024-10-31 05:05:44 +00:00
|
|
|
import QtQuick.Layouts
|
2021-12-22 23:29:00 +00:00
|
|
|
import QtQuick.Window 2.2
|
|
|
|
|
|
2023-11-02 11:08:17 +00:00
|
|
|
import org.kde.plasma.private.mobileshell as MobileShell
|
2021-12-22 23:29:00 +00:00
|
|
|
import org.kde.plasma.components 3.0 as PlasmaComponents
|
2023-07-25 01:13:52 +00:00
|
|
|
import org.kde.kirigami 2.20 as Kirigami
|
2024-07-27 15:02:48 +00:00
|
|
|
import org.kde.plasma.private.mobileshell.quicksettingsplugin as QS
|
2021-12-22 23:29:00 +00:00
|
|
|
|
|
|
|
|
/**
|
2024-06-16 20:50:06 +00:00
|
|
|
* Root element that contains all the ActionDrawer's contents, and is anchored to the screen.
|
2021-12-22 23:29:00 +00:00
|
|
|
*/
|
2023-07-25 01:13:52 +00:00
|
|
|
Item {
|
2021-12-22 23:29:00 +00:00
|
|
|
id: root
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
required property var actionDrawer
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-05-26 22:11:01 +00:00
|
|
|
// pinned position (disabled when openToPinnedMode is false)
|
2024-10-31 05:05:44 +00:00
|
|
|
readonly property real minimizedQuickSettingsOffset: quickSettingsDrawer.minimizedHeight
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-05-26 22:11:01 +00:00
|
|
|
// fully open position
|
2024-10-31 05:05:44 +00:00
|
|
|
readonly property real maximizedQuickSettingsOffset: minimizedQuickSettingsOffset + quickSettingsDrawer.maxAddedHeight
|
|
|
|
|
|
|
|
|
|
property alias quickSettings: quickSettingsDrawer.quickSettings
|
|
|
|
|
property alias statusBar: quickSettingsDrawer.statusBar
|
|
|
|
|
property alias mediaControlsWidget: quickSettingsDrawer.mediaControlsWidget
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2023-07-25 01:13:52 +00:00
|
|
|
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
|
|
|
|
Kirigami.Theme.inherit: false
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
function applyMinMax(val) {
|
|
|
|
|
return Math.max(0, Math.min(1, val));
|
|
|
|
|
}
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2023-11-02 11:08:17 +00:00
|
|
|
MobileShell.QuickSettingsDrawer {
|
2024-10-31 05:05:44 +00:00
|
|
|
id: quickSettingsDrawer
|
2024-10-30 03:30:09 +00:00
|
|
|
|
|
|
|
|
// physically move the drawer when between closed <-> pinned mode
|
|
|
|
|
readonly property real offsetHeight: actionDrawer.openToPinnedMode ? minimizedQuickSettingsOffset : maximizedQuickSettingsOffset
|
2025-03-20 02:06:33 +00:00
|
|
|
anchors {
|
|
|
|
|
topMargin: Math.min(root.actionDrawer.offsetResistance - offsetHeight, 0)
|
|
|
|
|
top: parent.top
|
|
|
|
|
left: parent.left
|
|
|
|
|
right: parent.right
|
|
|
|
|
}
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
actionDrawer: root.actionDrawer
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-05-26 22:11:01 +00:00
|
|
|
// opacity and move animation (disabled when openToPinnedMode is false)
|
2025-03-20 02:06:33 +00:00
|
|
|
property real offsetDist: actionDrawer.offsetResistance - minimizedQuickSettingsOffset
|
2021-12-22 23:29:00 +00:00
|
|
|
property real totalOffsetDist: maximizedQuickSettingsOffset - minimizedQuickSettingsOffset
|
2022-05-26 22:11:01 +00:00
|
|
|
minimizedToFullProgress: actionDrawer.openToPinnedMode ? (actionDrawer.opened ? applyMinMax(offsetDist / totalOffsetDist) : 0) : 1
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-05-26 22:11:01 +00:00
|
|
|
// this drawer opens in two stages when pinned mode is enabled:
|
|
|
|
|
// ---
|
|
|
|
|
// stage 1: the transform effect is used, the drawer physically moves down to the pinned mode
|
|
|
|
|
// stage 2: the rectangle increases height to reveal content, but the content stays still
|
|
|
|
|
// when pinned mode is disabled, only stage 1 happens
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-05-26 22:11:01 +00:00
|
|
|
// increase height of drawer when between pinned mode <-> maximized mode
|
2021-12-22 23:29:00 +00:00
|
|
|
addedHeight: {
|
2022-05-26 22:11:01 +00:00
|
|
|
if (!actionDrawer.openToPinnedMode) {
|
|
|
|
|
// if pinned mode disabled, just go to full height
|
2025-03-20 02:06:33 +00:00
|
|
|
return Math.max(maximizedQuickSettingsOffset - minimizedQuickSettingsOffset, root.actionDrawer.offsetResistance - minimizedQuickSettingsOffset)
|
2022-05-26 22:11:01 +00:00
|
|
|
} else if (!actionDrawer.opened) {
|
2025-03-20 02:06:33 +00:00
|
|
|
return Math.max(0, root.actionDrawer.offsetResistance - minimizedQuickSettingsOffset)
|
2021-12-22 23:29:00 +00:00
|
|
|
} else {
|
2025-03-20 02:06:33 +00:00
|
|
|
return Math.max(0, root.actionDrawer.offsetResistance - minimizedQuickSettingsOffset)
|
2021-12-22 23:29:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|