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
|
|
|
|
2024-10-31 05:05:44 +00:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls as QQC2
|
|
|
|
|
import QtQuick.Layouts
|
2026-05-24 13:49:02 +00:00
|
|
|
import QtQuick.Shapes 1.8
|
2024-10-31 05:05:44 +00:00
|
|
|
import QtQuick.Window
|
2021-12-22 23:29:00 +00:00
|
|
|
|
2026-03-07 03:08:07 +00:00
|
|
|
import org.kde.kirigami as Kirigami
|
2021-12-22 23:29:00 +00:00
|
|
|
|
2023-09-05 15:34:49 +00:00
|
|
|
import org.kde.plasma.core as PlasmaCore
|
2021-12-22 23:29:00 +00:00
|
|
|
import org.kde.plasma.components 3.0 as PlasmaComponents
|
2023-11-02 11:08:17 +00:00
|
|
|
import org.kde.plasma.private.mobileshell as MobileShell
|
2025-08-19 15:54:55 +00:00
|
|
|
import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings
|
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
|
|
|
|
2024-10-31 05:05:44 +00:00
|
|
|
property alias quickSettings: quickSettingsPanel.quickSettings
|
|
|
|
|
property alias statusBar: quickSettingsPanel.statusBar
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
readonly property real minimizedQuickSettingsOffset: height
|
|
|
|
|
readonly property real maximizedQuickSettingsOffset: height
|
2026-05-19 07:13:08 +00:00
|
|
|
readonly property bool isConvergence: ShellSettings.Settings.convergenceModeEnabled
|
|
|
|
|
readonly property real convergenceFrameThickness: MobileShell.Constants.convergenceWorkspaceFrameThickness
|
2026-05-24 13:49:02 +00:00
|
|
|
readonly property real convergenceSurfaceTopInset: MobileShell.Constants.topPanelHeight + convergenceFrameThickness
|
2026-05-19 07:13:08 +00:00
|
|
|
readonly property real convergenceSurfaceBottomInset: MobileShell.Constants.convergenceDockHeight + convergenceFrameThickness
|
|
|
|
|
readonly property real convergenceSurfaceSideInset: 0
|
|
|
|
|
readonly property real convergenceSurfaceWidth: Math.max(0, width - convergenceSurfaceSideInset * 2)
|
|
|
|
|
readonly property real convergenceSurfaceHeight: Math.max(0, height - convergenceSurfaceTopInset - convergenceSurfaceBottomInset)
|
2024-10-31 05:05:44 +00:00
|
|
|
readonly property bool isOnLargeScreen: width > quickSettingsPanel.width * 2.5
|
2022-05-15 13:45:26 +00:00
|
|
|
readonly property real minWidthHeight: Math.min(root.width, root.height)
|
2026-05-24 14:31:28 +00:00
|
|
|
readonly property real quickSettingsPanelLeft: quickSettingsPanel.x
|
2025-03-20 02:06:33 +00:00
|
|
|
readonly property real opacityValue: Math.max(0, Math.min(1, actionDrawer.offsetResistance / root.minimizedQuickSettingsOffset))
|
2024-11-14 03:34:01 +00:00
|
|
|
readonly property double brightnessPressedValue: quickSettings.brightnessPressedValue
|
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
|
|
|
|
2022-04-08 00:23:36 +00:00
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-04-08 00:23:36 +00:00
|
|
|
// dismiss drawer when background is clicked
|
|
|
|
|
onClicked: root.actionDrawer.close();
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2026-05-24 13:49:02 +00:00
|
|
|
Shape {
|
|
|
|
|
id: actionDrawerSurface
|
|
|
|
|
x: quickSettingsPanel.x - cornerRadius
|
|
|
|
|
y: quickSettingsPanel.y
|
|
|
|
|
width: bodyWidth + cornerRadius
|
|
|
|
|
height: quickSettingsPanel.height
|
|
|
|
|
opacity: root.isConvergence ? quickSettingsPanel.opacity * root.brightnessPressedValue : 0
|
|
|
|
|
visible: opacity > 0 && bodyWidth > 0 && height > 0
|
|
|
|
|
z: 0
|
|
|
|
|
preferredRendererType: Shape.CurveRenderer
|
|
|
|
|
asynchronous: true
|
|
|
|
|
enabled: false
|
|
|
|
|
|
|
|
|
|
readonly property real bodyWidth: quickSettingsPanel.width
|
|
|
|
|
readonly property real cornerRadius: Math.min(MobileShell.Constants.convergenceWorkspaceFrameRadius,
|
|
|
|
|
Math.max(0.01, Math.min(bodyWidth, height) / 2))
|
|
|
|
|
|
|
|
|
|
Kirigami.Theme.inherit: false
|
|
|
|
|
Kirigami.Theme.colorSet: Kirigami.Theme.Window
|
|
|
|
|
|
|
|
|
|
ShapePath {
|
|
|
|
|
id: actionDrawerSurfacePath
|
|
|
|
|
readonly property real cornerRadius: actionDrawerSurface.cornerRadius
|
|
|
|
|
|
2026-06-01 10:38:17 +00:00
|
|
|
fillColor: MobileShell.SurfaceColors.accentSurface(Kirigami.Theme.backgroundColor, 0.32, 0.18)
|
2026-05-24 13:49:02 +00:00
|
|
|
strokeWidth: 0
|
|
|
|
|
startX: actionDrawerSurface.width
|
|
|
|
|
startY: 0
|
|
|
|
|
|
|
|
|
|
PathLine { x: 0; y: 0 }
|
|
|
|
|
PathArc { x: actionDrawerSurfacePath.cornerRadius; y: actionDrawerSurfacePath.cornerRadius; radiusX: actionDrawerSurfacePath.cornerRadius; radiusY: actionDrawerSurfacePath.cornerRadius; direction: PathArc.Clockwise }
|
|
|
|
|
PathLine { x: actionDrawerSurfacePath.cornerRadius; y: actionDrawerSurface.height - actionDrawerSurfacePath.cornerRadius }
|
|
|
|
|
PathArc { x: 0; y: actionDrawerSurface.height; radiusX: actionDrawerSurfacePath.cornerRadius; radiusY: actionDrawerSurfacePath.cornerRadius; direction: PathArc.Clockwise }
|
|
|
|
|
PathLine { x: actionDrawerSurface.width; y: actionDrawerSurface.height }
|
|
|
|
|
PathLine { x: actionDrawerSurface.width; y: 0 }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-08 00:23:36 +00:00
|
|
|
// right sidebar
|
2023-11-02 11:08:17 +00:00
|
|
|
MobileShell.QuickSettingsPanel {
|
2024-10-31 05:05:44 +00:00
|
|
|
id: quickSettingsPanel
|
2026-05-24 13:49:02 +00:00
|
|
|
z: 1
|
2026-05-19 07:13:08 +00:00
|
|
|
height: Math.min(quickSettingsPanel.contentImplicitHeight + quickSettingsPanel.topPadding + quickSettingsPanel.bottomPadding, quickSettingsPanel.availableHeight)
|
|
|
|
|
width: Math.min(intendedWidth, quickSettingsPanel.availableWidth)
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2025-08-19 15:54:55 +00:00
|
|
|
readonly property real columnWidth: 6 * Kirigami.Units.gridUnit
|
2026-05-19 07:13:08 +00:00
|
|
|
readonly property real availableWidth: root.isConvergence ? root.convergenceSurfaceWidth : intendedWidth
|
|
|
|
|
readonly property real availableHeight: root.isConvergence ? root.convergenceSurfaceHeight : root.height
|
2026-04-15 09:58:08 +00:00
|
|
|
// In convergence mode, use up to 45% of screen width so more
|
|
|
|
|
// tiles are visible without pagination.
|
|
|
|
|
readonly property int convergenceColumns: Math.min(6, Math.floor(root.width * 0.45 / columnWidth))
|
2026-05-19 07:13:08 +00:00
|
|
|
readonly property int effectiveColumns: root.isConvergence
|
2026-04-15 09:58:08 +00:00
|
|
|
? Math.max(ShellSettings.Settings.quickSettingsColumns, convergenceColumns)
|
|
|
|
|
: ShellSettings.Settings.quickSettingsColumns
|
|
|
|
|
readonly property real intendedWidth: (columnWidth * effectiveColumns) + Kirigami.Units.gridUnit
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2026-05-19 07:13:08 +00:00
|
|
|
readonly property bool isConvergence: root.isConvergence
|
2026-04-16 15:25:37 +00:00
|
|
|
property real offsetRatio: (quickSettingsPanel.height + restingTopMargin) / root.height
|
2026-05-19 07:13:08 +00:00
|
|
|
readonly property real restingTopMargin: root.isConvergence ? root.convergenceSurfaceTopInset : 0
|
2026-04-16 15:25:37 +00:00
|
|
|
anchors.topMargin: isConvergence ? restingTopMargin : Math.min(root.actionDrawer.offsetResistance * offsetRatio - quickSettingsPanel.height, 0)
|
2022-04-08 00:23:36 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.right: parent.right
|
2026-05-19 07:13:08 +00:00
|
|
|
anchors.rightMargin: isConvergence ? root.convergenceSurfaceSideInset : 0
|
2026-04-16 15:25:37 +00:00
|
|
|
opacity: isConvergence ? Math.max(0, Math.min(1, root.actionDrawer.offset / root.minimizedQuickSettingsOffset)) : 1
|
2024-07-27 03:47:44 +00:00
|
|
|
|
2022-04-08 00:23:36 +00:00
|
|
|
actionDrawer: root.actionDrawer
|
2026-05-19 07:13:08 +00:00
|
|
|
fullScreenHeight: quickSettingsPanel.availableHeight
|
2021-12-22 23:29:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|