shift-shell/components/mobileshell/qml/actiondrawer/private/LandscapeContentContainer.qml
Marco Allegretti b1f8d17f88 Apply accent-aware shell surface theming
Add a shared SurfaceColors helper and route shell, action drawer, popup,
and Folio surfaces through accent-aware background colors.
2026-06-01 12:38:17 +02:00

122 lines
6.4 KiB
QML

// SPDX-FileCopyrightText: 2021-2024 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later
import QtQuick
import QtQuick.Controls as QQC2
import QtQuick.Layouts
import QtQuick.Shapes 1.8
import QtQuick.Window
import org.kde.kirigami as Kirigami
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.plasma.private.mobileshell as MobileShell
import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings
import org.kde.plasma.private.mobileshell.quicksettingsplugin as QS
/**
* Root element that contains all the ActionDrawer's contents, and is anchored to the screen.
*/
Item {
id: root
required property var actionDrawer
property alias quickSettings: quickSettingsPanel.quickSettings
property alias statusBar: quickSettingsPanel.statusBar
readonly property real minimizedQuickSettingsOffset: height
readonly property real maximizedQuickSettingsOffset: height
readonly property bool isConvergence: ShellSettings.Settings.convergenceModeEnabled
readonly property real convergenceFrameThickness: MobileShell.Constants.convergenceWorkspaceFrameThickness
readonly property real convergenceSurfaceTopInset: MobileShell.Constants.topPanelHeight + convergenceFrameThickness
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)
readonly property bool isOnLargeScreen: width > quickSettingsPanel.width * 2.5
readonly property real minWidthHeight: Math.min(root.width, root.height)
readonly property real quickSettingsPanelLeft: quickSettingsPanel.x
readonly property real opacityValue: Math.max(0, Math.min(1, actionDrawer.offsetResistance / root.minimizedQuickSettingsOffset))
readonly property double brightnessPressedValue: quickSettings.brightnessPressedValue
Kirigami.Theme.colorSet: Kirigami.Theme.View
Kirigami.Theme.inherit: false
MouseArea {
anchors.fill: parent
// dismiss drawer when background is clicked
onClicked: root.actionDrawer.close();
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
fillColor: MobileShell.SurfaceColors.accentSurface(Kirigami.Theme.backgroundColor, 0.32, 0.18)
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 }
}
}
// right sidebar
MobileShell.QuickSettingsPanel {
id: quickSettingsPanel
z: 1
height: Math.min(quickSettingsPanel.contentImplicitHeight + quickSettingsPanel.topPadding + quickSettingsPanel.bottomPadding, quickSettingsPanel.availableHeight)
width: Math.min(intendedWidth, quickSettingsPanel.availableWidth)
readonly property real columnWidth: 6 * Kirigami.Units.gridUnit
readonly property real availableWidth: root.isConvergence ? root.convergenceSurfaceWidth : intendedWidth
readonly property real availableHeight: root.isConvergence ? root.convergenceSurfaceHeight : root.height
// 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))
readonly property int effectiveColumns: root.isConvergence
? Math.max(ShellSettings.Settings.quickSettingsColumns, convergenceColumns)
: ShellSettings.Settings.quickSettingsColumns
readonly property real intendedWidth: (columnWidth * effectiveColumns) + Kirigami.Units.gridUnit
readonly property bool isConvergence: root.isConvergence
property real offsetRatio: (quickSettingsPanel.height + restingTopMargin) / root.height
readonly property real restingTopMargin: root.isConvergence ? root.convergenceSurfaceTopInset : 0
anchors.topMargin: isConvergence ? restingTopMargin : Math.min(root.actionDrawer.offsetResistance * offsetRatio - quickSettingsPanel.height, 0)
anchors.top: parent.top
anchors.right: parent.right
anchors.rightMargin: isConvergence ? root.convergenceSurfaceSideInset : 0
opacity: isConvergence ? Math.max(0, Math.min(1, root.actionDrawer.offset / root.minimizedQuickSettingsOffset)) : 1
actionDrawer: root.actionDrawer
fullScreenHeight: quickSettingsPanel.availableHeight
}
}
}