2023-06-13 00:49:54 +00:00
|
|
|
// SPDX-FileCopyrightText: 2021-2023 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2015-03-13 21:16:19 +00:00
|
|
|
|
2023-06-13 00:49:54 +00:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import QtQuick.Window
|
|
|
|
|
import QtQml.Models
|
2015-03-13 21:16:19 +00:00
|
|
|
|
2023-06-13 00:49:54 +00:00
|
|
|
import org.kde.kirigami as Kirigami
|
2021-04-09 20:59:05 +00:00
|
|
|
|
2023-06-13 00:49:54 +00:00
|
|
|
import org.kde.plasma.plasmoid
|
2023-09-05 15:34:49 +00:00
|
|
|
import org.kde.plasma.core as PlasmaCore
|
2015-03-13 21:16:19 +00:00
|
|
|
|
2023-03-19 01:48:49 +00:00
|
|
|
import org.kde.plasma.private.mobileshell as MobileShell
|
2025-04-21 15:56:33 +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.state as MobileShellState
|
|
|
|
|
import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin
|
2020-07-22 15:17:10 +00:00
|
|
|
|
2023-06-13 00:49:54 +00:00
|
|
|
import org.kde.taskmanager as TaskManager
|
|
|
|
|
import org.kde.notificationmanager as NotificationManager
|
2024-11-25 17:30:47 +00:00
|
|
|
import org.kde.layershell 1.0 as LayerShell
|
2022-02-11 22:50:17 +00:00
|
|
|
|
2023-06-13 00:49:54 +00:00
|
|
|
ContainmentItem {
|
2015-03-13 21:16:19 +00:00
|
|
|
id: root
|
2025-07-02 14:27:33 +00:00
|
|
|
|
2023-06-13 00:49:54 +00:00
|
|
|
Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground
|
2025-07-02 14:27:33 +00:00
|
|
|
Plasmoid.status: PlasmaCore.Types.PassiveStatus // Ensure that the panel never takes focus away from the running app
|
2023-03-03 06:11:51 +00:00
|
|
|
|
2025-07-02 14:27:33 +00:00
|
|
|
// Filled in by the shell (Panel.qml) with the plasma-workspace PanelView
|
2023-10-22 17:53:55 +00:00
|
|
|
property var panel: null
|
2024-11-25 17:30:47 +00:00
|
|
|
onPanelChanged: setWindowProperties()
|
|
|
|
|
|
2025-07-02 14:27:33 +00:00
|
|
|
// Whether the startup feedback is showing
|
|
|
|
|
readonly property bool showingStartupFeedback: MobileShellState.ShellDBusObject.startupFeedbackModel.activeWindowIsStartupFeedback
|
|
|
|
|
|
|
|
|
|
// Whether an app is maximized and showing (does not include startup feedback)
|
|
|
|
|
readonly property bool showingApp: windowMaximizedTracker.showingWindow && !showingStartupFeedback
|
|
|
|
|
|
|
|
|
|
// Whether the currently showing app is in "fullscreen"
|
|
|
|
|
readonly property bool fullscreen: {
|
|
|
|
|
if (windowMaximizedTracker.isCurrentWindowFullscreen) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The "autoHidePanelsEnabled" settings option treats every app as a fullscreen window
|
|
|
|
|
return (ShellSettings.Settings.autoHidePanelsEnabled && showingApp);
|
|
|
|
|
}
|
|
|
|
|
onFullscreenChanged: {
|
|
|
|
|
MobileShellState.ShellDBusClient.panelState = fullscreen ? "hidden" : "default";
|
2023-11-17 07:48:24 +00:00
|
|
|
}
|
2023-10-22 17:53:55 +00:00
|
|
|
|
2025-07-02 14:27:33 +00:00
|
|
|
property WindowPlugin.WindowMaximizedTracker windowMaximizedTracker: WindowPlugin.WindowMaximizedTracker {
|
|
|
|
|
id: windowMaximizedTracker
|
|
|
|
|
screenGeometry: Plasmoid.containment.screenGeometry
|
2024-11-25 17:30:47 +00:00
|
|
|
|
2025-07-02 14:27:33 +00:00
|
|
|
onShowingWindowChanged: {
|
|
|
|
|
// Hide panel when we open the task switcher and an app is "fullscreen"
|
|
|
|
|
if (windowMaximizedTracker.showingWindow
|
|
|
|
|
&& MobileShellState.ShellDBusClient.isTaskSwitcherVisible
|
|
|
|
|
&& (ShellSettings.Settings.autoHidePanelsEnabled || fullscreen)) {
|
|
|
|
|
MobileShellState.ShellDBusClient.panelState = "hidden";
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-25 17:30:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setWindowProperties() {
|
|
|
|
|
if (root.panel) {
|
|
|
|
|
root.panel.floating = false;
|
|
|
|
|
root.panel.maximize(); // maximize first, then we can apply offsets (otherwise they are overridden)
|
2025-07-02 14:27:33 +00:00
|
|
|
root.panel.thickness = MobileShell.Constants.topPanelHeight;
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-02 14:27:33 +00:00
|
|
|
// Update the touch area when hidden to minimize the space the panel takes for touch input
|
2024-11-25 17:30:47 +00:00
|
|
|
function updateTouchArea() {
|
|
|
|
|
const hiddenTouchAreaThickness = Kirigami.Units.gridUnit;
|
|
|
|
|
|
2025-07-02 14:27:33 +00:00
|
|
|
if (MobileShellState.ShellDBusClient.panelState == "hidden") {
|
2024-11-25 17:30:47 +00:00
|
|
|
MobileShell.ShellUtil.setInputRegion(root.panel, Qt.rect(0, 0, root.panel.width, hiddenTouchAreaThickness));
|
|
|
|
|
} else {
|
|
|
|
|
MobileShell.ShellUtil.setInputRegion(root.panel, Qt.rect(0, 0, 0, 0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-02 14:27:33 +00:00
|
|
|
// Overlay the panel over the lockscreen when brought up
|
|
|
|
|
LockscreenOverlay {
|
|
|
|
|
window: root.Window.window
|
2025-04-21 15:56:33 +00:00
|
|
|
}
|
|
|
|
|
|
2025-07-02 14:27:33 +00:00
|
|
|
// Enforce thickness of panel
|
2022-06-27 22:08:42 +00:00
|
|
|
Binding {
|
2023-10-22 17:53:55 +00:00
|
|
|
target: panel // assumed to be plasma-workspace "PanelView" component
|
2022-06-27 22:08:42 +00:00
|
|
|
property: "thickness"
|
2023-10-22 17:53:55 +00:00
|
|
|
value: MobileShell.Constants.topPanelHeight
|
2022-06-27 22:08:42 +00:00
|
|
|
}
|
2023-06-13 00:49:54 +00:00
|
|
|
|
2021-10-29 01:54:52 +00:00
|
|
|
Connections {
|
2025-07-02 14:27:33 +00:00
|
|
|
target: ShellSettings.Settings
|
2023-03-20 01:32:19 +00:00
|
|
|
|
2025-07-02 14:27:33 +00:00
|
|
|
function onAutoHidePanelsEnabledChanged() {
|
|
|
|
|
root.setWindowProperties();
|
2022-03-13 21:47:42 +00:00
|
|
|
}
|
2021-10-29 01:54:52 +00:00
|
|
|
}
|
2023-03-20 01:32:19 +00:00
|
|
|
|
2015-03-13 21:16:19 +00:00
|
|
|
Component.onCompleted: {
|
2024-11-25 17:30:47 +00:00
|
|
|
root.setWindowProperties();
|
2021-04-09 20:59:05 +00:00
|
|
|
}
|
2023-06-13 00:49:54 +00:00
|
|
|
|
2025-07-02 14:27:33 +00:00
|
|
|
// Visual panel component
|
|
|
|
|
StatusPanel {
|
2024-11-25 17:30:47 +00:00
|
|
|
id: statusPanel
|
2021-04-09 20:59:05 +00:00
|
|
|
anchors.fill: parent
|
2025-07-02 14:27:33 +00:00
|
|
|
containmentItem: root
|
2023-03-03 06:11:51 +00:00
|
|
|
}
|
2015-03-13 21:16:19 +00:00
|
|
|
}
|