2023-06-13 00:49:54 +00:00
|
|
|
// SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
|
|
|
|
|
// SPDX-FileCopyrightText: 2021-2023 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2015-06-11 22:35:46 +00:00
|
|
|
|
|
|
|
|
import QtQuick 2.4
|
|
|
|
|
import QtQuick.Layouts 1.1
|
2022-02-13 04:23:57 +00:00
|
|
|
import QtQuick.Window 2.15
|
2024-11-25 17:30:47 +00:00
|
|
|
import QtQuick.Shapes 1.8
|
2015-06-11 22:35:46 +00:00
|
|
|
|
2026-03-07 03:08:07 +00:00
|
|
|
import org.kde.kirigami as Kirigami
|
2023-07-25 01:13:52 +00:00
|
|
|
|
2016-06-27 16:34:20 +00:00
|
|
|
import org.kde.taskmanager 0.1 as TaskManager
|
2015-06-11 22:35:46 +00:00
|
|
|
import org.kde.plasma.plasmoid 2.0
|
2023-09-05 15:34:49 +00:00
|
|
|
import org.kde.plasma.core as PlasmaCore
|
2015-06-11 22:35:46 +00:00
|
|
|
import org.kde.kquickcontrolsaddons 2.0
|
|
|
|
|
|
2023-03-26 18:22:14 +00:00
|
|
|
import org.kde.plasma.private.mobileshell as MobileShell
|
2023-03-18 19:28:17 +00:00
|
|
|
import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings
|
2023-03-19 01:48:49 +00:00
|
|
|
import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin
|
2024-07-13 16:30:07 +00:00
|
|
|
import org.kde.plasma.private.mobileshell.state as MobileShellState
|
2024-11-25 17:30:47 +00:00
|
|
|
import org.kde.plasma.workspace.keyboardlayout as Keyboards
|
|
|
|
|
import org.kde.layershell 1.0 as LayerShell
|
2020-07-22 15:17:10 +00:00
|
|
|
|
2023-06-13 00:49:54 +00:00
|
|
|
ContainmentItem {
|
2015-06-18 23:31:26 +00:00
|
|
|
id: root
|
2023-11-14 06:11:50 +00:00
|
|
|
Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground
|
2023-11-14 07:05:32 +00:00
|
|
|
Plasmoid.status: PlasmaCore.Types.PassiveStatus // ensure that the panel never takes focus away from the running app
|
2023-10-17 05:12:44 +00:00
|
|
|
|
|
|
|
|
// filled in by the shell (Panel.qml) with the plasma-workspace PanelView
|
|
|
|
|
property var panel: null
|
|
|
|
|
onPanelChanged: {
|
|
|
|
|
setWindowProperties()
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-25 17:30:47 +00:00
|
|
|
MobileShell.HapticsEffect {
|
|
|
|
|
id: haptics
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-23 04:48:22 +00:00
|
|
|
readonly property bool inLandscape: MobileShell.Constants.navigationPanelOnSide(Screen.width, Screen.height)
|
2023-03-03 06:11:51 +00:00
|
|
|
|
2024-03-09 02:00:23 +00:00
|
|
|
readonly property real navigationPanelHeight: MobileShell.Constants.navigationPanelThickness
|
panels: Add support for defining device specific panel tweaks
This adds support for specifying options needed to deal with phone
display panel pecularities (ex. screen curves, notches, punch holes)
This is implemented as settings in ~/.config/plasmamobilerc, which can
set panel heights, paddings, and center spacings to duck display
cutouts. The pixel values are scaling independent, and so are not
affected when the display scaling is changed.
This is then exposed over DBus, so that components from outside of
plasmashell (ex. KWin) can access it easily without needing to connect to
kscreen themselves. Each screen is exposed as a single object.
Currently support is only added in the status bar and the navigation
panel.
Currently all screens have the settings applied. In the future, we may
want to limit this just to the internal screen (?)
---
This also adds a "devices" folder (in `devices/configs`) where per-device configs can be set.
This is installed to `/usr/share/plasma-mobile-device-configs`.
In `plasmamobilerc` (installed to `/etc/xdg/plasmamobilerc`, or
`~/.config/plasmamobilerc`), envmanager will read:
```toml
[Device]
device=oneplus-enchilada
```
for the device config to use and write its settings to
`~/.config/plasma-mobile/plasmamobilerc`.
2025-10-05 23:06:52 +00:00
|
|
|
onNavigationPanelHeightChanged: setWindowProperties()
|
2023-03-03 06:11:51 +00:00
|
|
|
|
2023-03-18 07:02:01 +00:00
|
|
|
readonly property real intendedWindowThickness: navigationPanelHeight
|
2023-10-21 05:46:31 +00:00
|
|
|
readonly property real intendedWindowLength: inLandscape ? Screen.height : Screen.width
|
|
|
|
|
readonly property real intendedWindowOffset: inLandscape ? MobileShell.Constants.topPanelHeight : 0; // offset for top panel
|
|
|
|
|
readonly property int intendedWindowLocation: inLandscape ? PlasmaCore.Types.RightEdge : PlasmaCore.Types.BottomEdge
|
2023-03-03 06:11:51 +00:00
|
|
|
|
|
|
|
|
onIntendedWindowLengthChanged: maximizeTimer.restart() // ensure it always takes up the full length of the screen
|
2024-03-04 02:39:21 +00:00
|
|
|
onIntendedWindowLocationChanged: setPanelLocationTimer.restart()
|
2023-03-26 18:22:14 +00:00
|
|
|
onIntendedWindowOffsetChanged: {
|
2023-10-17 05:12:44 +00:00
|
|
|
if (root.panel) {
|
|
|
|
|
root.panel.offset = intendedWindowOffset;
|
2023-03-26 18:22:14 +00:00
|
|
|
}
|
|
|
|
|
}
|
2023-03-03 06:11:51 +00:00
|
|
|
|
2024-03-04 02:39:21 +00:00
|
|
|
// HACK: the entire shell seems to crash sometimes if this is applied immediately after a display change (ex. screen rotation)
|
|
|
|
|
// see https://invent.kde.org/plasma/plasma-mobile/-/issues/321
|
|
|
|
|
Timer {
|
|
|
|
|
id: setPanelLocationTimer
|
|
|
|
|
running: false
|
|
|
|
|
interval: 100
|
|
|
|
|
onTriggered: {
|
|
|
|
|
root.panel.location = intendedWindowLocation;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 06:11:51 +00:00
|
|
|
// use a timer so we don't have to maximize for every single pixel
|
|
|
|
|
// - improves performance if the shell is run in a window, and can be resized
|
|
|
|
|
Timer {
|
|
|
|
|
id: maximizeTimer
|
|
|
|
|
running: false
|
|
|
|
|
interval: 100
|
|
|
|
|
onTriggered: {
|
|
|
|
|
// maximize first, then we can apply offsets (otherwise they are overridden)
|
2024-11-25 17:30:47 +00:00
|
|
|
root.panel.maximize();
|
2023-10-17 05:12:44 +00:00
|
|
|
root.panel.offset = intendedWindowOffset;
|
2023-03-03 06:11:51 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setWindowProperties() {
|
2023-10-17 05:12:44 +00:00
|
|
|
if (root.panel) {
|
2023-11-14 06:11:50 +00:00
|
|
|
root.panel.floating = false;
|
2023-10-17 05:12:44 +00:00
|
|
|
root.panel.maximize(); // maximize first, then we can apply offsets (otherwise they are overridden)
|
|
|
|
|
root.panel.offset = intendedWindowOffset;
|
|
|
|
|
root.panel.thickness = navigationPanelHeight;
|
|
|
|
|
root.panel.location = intendedWindowLocation;
|
2025-04-21 15:56:33 +00:00
|
|
|
root.panel.visibilityMode = ShellSettings.Settings.autoHidePanelsEnabled ? 3 : 0;
|
2024-11-25 17:30:47 +00:00
|
|
|
MobileShell.ShellUtil.setWindowLayer(root.panel, LayerShell.Window.LayerOverlay);
|
|
|
|
|
root.updateTouchArea();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// update the touch area when hidden to minimize the space the panel takes for touch input
|
|
|
|
|
function updateTouchArea() {
|
|
|
|
|
const hiddenTouchAreaThickness = Kirigami.Units.gridUnit;
|
|
|
|
|
|
|
|
|
|
if (navigationPanel.state == "hidden") {
|
|
|
|
|
if (inLandscape) {
|
|
|
|
|
MobileShell.ShellUtil.setInputRegion(root.panel, Qt.rect(root.panel.width - hiddenTouchAreaThickness, 0, hiddenTouchAreaThickness, root.panel.height));
|
|
|
|
|
} else {
|
|
|
|
|
MobileShell.ShellUtil.setInputRegion(root.panel, Qt.rect(0, root.panel.height - hiddenTouchAreaThickness, root.panel.width, hiddenTouchAreaThickness));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
MobileShell.ShellUtil.setInputRegion(root.panel, Qt.rect(0, 0, 0, 0));
|
2023-03-18 07:02:01 +00:00
|
|
|
}
|
2023-03-03 06:11:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Connections {
|
2023-10-17 05:12:44 +00:00
|
|
|
target: root.panel
|
2023-03-03 06:11:51 +00:00
|
|
|
|
|
|
|
|
// HACK: There seems to be some component that overrides our initial bindings for the panel,
|
|
|
|
|
// which is particularly problematic on first start (since the panel is misplaced)
|
|
|
|
|
// - We set an event to override any attempts to override our bindings.
|
|
|
|
|
function onLocationChanged() {
|
2023-10-17 05:12:44 +00:00
|
|
|
if (root.panel.location !== root.intendedWindowLocation) {
|
2023-03-03 06:11:51 +00:00
|
|
|
root.setWindowProperties();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onThicknessChanged() {
|
2023-10-17 05:12:44 +00:00
|
|
|
if (root.panel.thickness !== root.intendedWindowThickness) {
|
2023-03-03 06:11:51 +00:00
|
|
|
root.setWindowProperties();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-21 15:56:33 +00:00
|
|
|
Connections {
|
|
|
|
|
target: ShellSettings.Settings
|
|
|
|
|
|
2025-07-02 14:27:33 +00:00
|
|
|
function onAutoHidePanelsEnabledChanged() {
|
2025-04-21 15:56:33 +00:00
|
|
|
root.setWindowProperties();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-03 06:11:51 +00:00
|
|
|
Component.onCompleted: setWindowProperties();
|
|
|
|
|
|
|
|
|
|
// only opaque if there are no maximized windows on this screen
|
2025-04-21 15:56:33 +00:00
|
|
|
readonly property bool showingStartupFeedback: MobileShellState.ShellDBusObject.startupFeedbackModel.activeWindowIsStartupFeedback && startupFeedbackColorAnimation.visible && windowMaximizedTracker.windowCount === 1
|
2025-09-14 02:18:32 +00:00
|
|
|
readonly property bool opaqueBar: {
|
|
|
|
|
if (Keyboards.KWinVirtualKeyboard.visible) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return (windowMaximizedTracker.showingWindow || isCurrentWindowFullscreen) && !showingStartupFeedback
|
|
|
|
|
}
|
2024-11-25 17:30:47 +00:00
|
|
|
readonly property alias isCurrentWindowFullscreen: windowMaximizedTracker.isCurrentWindowFullscreen
|
2025-04-21 15:56:33 +00:00
|
|
|
readonly property bool fullscreen: isCurrentWindowFullscreen || (ShellSettings.Settings.autoHidePanelsEnabled && opaqueBar)
|
2024-06-23 22:47:24 +00:00
|
|
|
|
|
|
|
|
WindowPlugin.WindowMaximizedTracker {
|
|
|
|
|
id: windowMaximizedTracker
|
|
|
|
|
screenGeometry: Plasmoid.containment.screenGeometry
|
2025-04-21 15:56:33 +00:00
|
|
|
|
|
|
|
|
onShowingWindowChanged: {
|
|
|
|
|
if (windowMaximizedTracker.showingWindow && MobileShellState.ShellDBusClient.isTaskSwitcherVisible && (ShellSettings.Settings.autoHidePanelsEnabled || fullscreen)) {
|
|
|
|
|
navigationPanel.offset = root.navigationPanelHeight;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-06-23 22:47:24 +00:00
|
|
|
}
|
2023-03-03 06:11:51 +00:00
|
|
|
|
2024-07-13 16:30:07 +00:00
|
|
|
MobileShell.StartupFeedbackPanelFill {
|
|
|
|
|
id: startupFeedbackColorAnimation
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
|
|
|
|
|
fullHeight: root.height
|
|
|
|
|
screen: Plasmoid.screen
|
|
|
|
|
maximizedTracker: windowMaximizedTracker
|
2024-11-25 17:30:47 +00:00
|
|
|
|
2025-04-21 15:56:33 +00:00
|
|
|
visible: !root.fullscreen
|
2024-07-13 16:30:07 +00:00
|
|
|
}
|
|
|
|
|
|
2025-09-14 02:18:32 +00:00
|
|
|
Item {
|
2024-11-25 17:30:47 +00:00
|
|
|
id: navigationPanel
|
2023-03-03 06:11:51 +00:00
|
|
|
anchors.fill: parent
|
2024-11-25 17:30:47 +00:00
|
|
|
|
|
|
|
|
property real offset: 0
|
|
|
|
|
|
2025-12-14 04:38:13 +00:00
|
|
|
Component {
|
|
|
|
|
id: navigationPanelComponent
|
|
|
|
|
|
|
|
|
|
NavigationPanelComponent {
|
|
|
|
|
isVertical: root.inLandscape
|
|
|
|
|
opaqueBar: root.opaqueBar
|
|
|
|
|
forcedComplementary: !opaqueBar && !startupFeedbackColorAnimation.isShowing
|
|
|
|
|
|
|
|
|
|
transform: [
|
|
|
|
|
Translate {
|
|
|
|
|
y: inLandscape ? 0 : navigationPanel.offset
|
|
|
|
|
x: inLandscape ? navigationPanel.offset : 0
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-12-05 04:01:40 +00:00
|
|
|
|
2025-12-14 04:38:13 +00:00
|
|
|
Component {
|
|
|
|
|
id: gesturePanelComponent
|
2024-11-25 17:30:47 +00:00
|
|
|
|
2025-12-17 00:55:50 +00:00
|
|
|
GesturePanelComponent {
|
2025-12-14 04:38:13 +00:00
|
|
|
opaqueBar: root.opaqueBar
|
|
|
|
|
|
|
|
|
|
Kirigami.Theme.inherit: false
|
|
|
|
|
Kirigami.Theme.colorSet: (!opaqueBar && !startupFeedbackColorAnimation.isShowing) ? Kirigami.Theme.Complementary : Kirigami.Theme.Window
|
|
|
|
|
|
|
|
|
|
transform: [
|
|
|
|
|
Translate {
|
|
|
|
|
y: inLandscape ? 0 : navigationPanel.offset
|
|
|
|
|
x: inLandscape ? navigationPanel.offset : 0
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// load appropriate system navigation component
|
|
|
|
|
Loader {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
sourceComponent: ShellSettings.Settings.navigationPanelEnabled ? navigationPanelComponent : gesturePanelComponent
|
2024-11-25 17:30:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
state: MobileShellState.ShellDBusClient.panelState
|
|
|
|
|
onStateChanged: {
|
|
|
|
|
if (navigationPanel.state != "hidden") {
|
|
|
|
|
root.setWindowProperties();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
states: [
|
|
|
|
|
State {
|
|
|
|
|
name: "default"
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: navigationPanel; offset: 0
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
State {
|
|
|
|
|
name: "visible"
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: navigationPanel; offset: 0
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
State {
|
|
|
|
|
name: "hidden"
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: navigationPanel; offset: root.navigationPanelHeight
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
transitions: Transition {
|
|
|
|
|
SequentialAnimation {
|
|
|
|
|
ParallelAnimation {
|
|
|
|
|
PropertyAnimation {
|
2025-09-14 02:18:32 +00:00
|
|
|
properties: "offset"
|
|
|
|
|
easing.type: navigationPanel.state === "hidden" ? Easing.InExpo : Easing.OutExpo
|
|
|
|
|
duration: Kirigami.Units.longDuration
|
2024-11-25 17:30:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ScriptAction {
|
|
|
|
|
script: {
|
|
|
|
|
root.setWindowProperties();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MobileShell.SwipeArea {
|
|
|
|
|
id: swipeArea
|
|
|
|
|
mode: inLandscape ? MobileShell.SwipeArea.HorizontalOnly : MobileShell.SwipeArea.VerticalOnly
|
|
|
|
|
anchors.fill: navigationPanel
|
|
|
|
|
enabled: navigationPanel.state == "hidden"
|
|
|
|
|
|
|
|
|
|
function startSwipeWithPoint(point) {
|
|
|
|
|
root.setWindowProperties();
|
|
|
|
|
resetAn.stop();
|
|
|
|
|
dragEffect.startPoint = inLandscape ? point.y - Screen.height / 2 : point.x - Screen.width / 2;
|
|
|
|
|
dragEffect.sidePoint = 0
|
|
|
|
|
dragEffect.offsetPoint = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateOffset(offsetX, offsetY) {
|
|
|
|
|
dragEffect.sidePoint = inLandscape ? offsetY : offsetX;
|
|
|
|
|
dragEffect.offsetPoint = Math.min(0, inLandscape ? offsetX : offsetY);
|
|
|
|
|
if (dragEffect.offsetPoint < -Kirigami.Units.gridUnit * 5 && navigationPanel.state == "hidden") {
|
|
|
|
|
swipeArea.resetSwipe();
|
|
|
|
|
resetAn.restart();
|
|
|
|
|
haptics.buttonVibrate();
|
|
|
|
|
MobileShellState.ShellDBusClient.panelState = "visible";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onSwipeStarted: (point) => startSwipeWithPoint(point)
|
|
|
|
|
onSwipeEnded: resetAn.start()
|
|
|
|
|
onSwipeMove: (totalDeltaX, totalDeltaY, deltaX, deltaY) => updateOffset(totalDeltaX, totalDeltaY);
|
|
|
|
|
|
|
|
|
|
onPressedChanged: {
|
|
|
|
|
if (!pressed && dragEffect.offsetPoint == 0) {
|
|
|
|
|
haptics.buttonVibrate();
|
|
|
|
|
MobileShellState.ShellDBusClient.panelState = "visible";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NumberAnimation {
|
|
|
|
|
id: resetAn
|
|
|
|
|
running: false
|
|
|
|
|
target: dragEffect
|
|
|
|
|
property: "offsetPoint"
|
|
|
|
|
to: 0
|
|
|
|
|
duration: Kirigami.Units.longDuration * 1.5
|
|
|
|
|
easing.type: Easing.OutExpo
|
|
|
|
|
onRunningChanged: {
|
|
|
|
|
if (!running && navigationPanel.state == "hidden") {
|
|
|
|
|
root.setWindowProperties();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MobileShell.ScreenEdgeDragEffect {
|
|
|
|
|
id: dragEffect
|
|
|
|
|
|
|
|
|
|
offsetLimit: root.inLandscape ? swipeArea.width : swipeArea.height
|
|
|
|
|
isHorizontal: root.inLandscape
|
|
|
|
|
|
|
|
|
|
states: [
|
|
|
|
|
State {
|
|
|
|
|
name: "vertical"
|
|
|
|
|
when: !root.inLandscape
|
|
|
|
|
AnchorChanges {
|
|
|
|
|
target: dragEffect
|
|
|
|
|
anchors.right: undefined
|
|
|
|
|
anchors.bottom: swipeArea.bottom
|
|
|
|
|
anchors.horizontalCenter: swipeArea.horizontalCenter
|
|
|
|
|
anchors.verticalCenter: undefined
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
State {
|
|
|
|
|
name: "horizontal"
|
|
|
|
|
when: root.inLandscape
|
|
|
|
|
AnchorChanges {
|
|
|
|
|
target: dragEffect
|
|
|
|
|
anchors.right: swipeArea.right
|
|
|
|
|
anchors.bottom: undefined
|
|
|
|
|
anchors.horizontalCenter: undefined
|
|
|
|
|
anchors.verticalCenter: swipeArea.verticalCenter
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
2023-03-18 07:02:01 +00:00
|
|
|
}
|
2023-03-03 06:11:51 +00:00
|
|
|
}
|
2015-06-12 22:18:24 +00:00
|
|
|
}
|