Warning, /plasma/plasma-mobile/containments/taskpanel/package/contents/ui/main.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
0002 // SPDX-FileCopyrightText: 2021-2023 Devin Lin <devin@kde.org>
0003 // SPDX-License-Identifier: GPL-2.0-or-later
0004 
0005 import QtQuick 2.4
0006 import QtQuick.Layouts 1.1
0007 import QtQuick.Window 2.15
0008 
0009 import org.kde.kirigami 2.20 as Kirigami
0010 
0011 import org.kde.taskmanager 0.1 as TaskManager
0012 import org.kde.plasma.plasmoid 2.0
0013 import org.kde.plasma.core as PlasmaCore
0014 import org.kde.kquickcontrolsaddons 2.0
0015 
0016 import org.kde.plasma.private.mobileshell as MobileShell
0017 import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings
0018 import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin
0019 
0020 ContainmentItem {
0021     id: root
0022     Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground
0023     Plasmoid.status: PlasmaCore.Types.PassiveStatus // ensure that the panel never takes focus away from the running app
0024 
0025     // filled in by the shell (Panel.qml) with the plasma-workspace PanelView
0026     property var panel: null
0027     onPanelChanged: {
0028         setWindowProperties()
0029     }
0030 
0031     // filled in by the shell (Panel.qml)
0032     property var tabBar: null
0033     onTabBarChanged: {
0034         if (tabBar) {
0035             tabBar.visible = false;
0036         }
0037     }
0038 
0039     readonly property bool inLandscape: MobileShell.Constants.navigationPanelOnSide(Screen.width, Screen.height)
0040 
0041     readonly property real navigationPanelHeight: Kirigami.Units.gridUnit * 2
0042 
0043     readonly property real intendedWindowThickness: navigationPanelHeight
0044     readonly property real intendedWindowLength: inLandscape ? Screen.height : Screen.width
0045     readonly property real intendedWindowOffset: inLandscape ? MobileShell.Constants.topPanelHeight : 0; // offset for top panel
0046     readonly property int intendedWindowLocation: inLandscape ? PlasmaCore.Types.RightEdge : PlasmaCore.Types.BottomEdge
0047 
0048     onIntendedWindowLengthChanged: maximizeTimer.restart() // ensure it always takes up the full length of the screen
0049     onIntendedWindowLocationChanged: {
0050         root.panel.location = intendedWindowLocation;
0051     }
0052     onIntendedWindowOffsetChanged: {
0053         if (root.panel) {
0054             root.panel.offset = intendedWindowOffset;
0055         }
0056     }
0057 
0058     // use a timer so we don't have to maximize for every single pixel
0059     // - improves performance if the shell is run in a window, and can be resized
0060     Timer {
0061         id: maximizeTimer
0062         running: false
0063         interval: 100
0064         onTriggered: {
0065             // maximize first, then we can apply offsets (otherwise they are overridden)
0066             root.panel.maximize()
0067             root.panel.offset = intendedWindowOffset;
0068         }
0069     }
0070 
0071 
0072     function setWindowProperties() {
0073         if (root.panel) {
0074             root.panel.floating = false;
0075             root.panel.maximize(); // maximize first, then we can apply offsets (otherwise they are overridden)
0076             root.panel.offset = intendedWindowOffset;
0077             root.panel.thickness = navigationPanelHeight;
0078             root.panel.location = intendedWindowLocation;
0079         }
0080     }
0081 
0082     Connections {
0083         target: root.panel
0084 
0085         // HACK: There seems to be some component that overrides our initial bindings for the panel,
0086         //   which is particularly problematic on first start (since the panel is misplaced)
0087         // - We set an event to override any attempts to override our bindings.
0088         function onLocationChanged() {
0089             if (root.panel.location !== root.intendedWindowLocation) {
0090                 root.setWindowProperties();
0091             }
0092         }
0093 
0094         function onThicknessChanged() {
0095             if (root.panel.thickness !== root.intendedWindowThickness) {
0096                 root.setWindowProperties();
0097             }
0098         }
0099     }
0100 
0101     Component.onCompleted: setWindowProperties();
0102 
0103     // only opaque if there are no maximized windows on this screen
0104     readonly property bool opaqueBar: WindowPlugin.WindowMaximizedTracker.showingWindow
0105 
0106     Item {
0107         anchors.fill: parent
0108 
0109         // contrasting colour
0110         Kirigami.Theme.colorSet: opaqueBar ? Kirigami.Theme.Window : Kirigami.Theme.Complementary
0111         Kirigami.Theme.inherit: false
0112 
0113         // load appropriate system navigation component
0114         NavigationPanelComponent {
0115             id: navigationPanel
0116             anchors.fill: parent
0117             opaqueBar: root.opaqueBar
0118             isVertical: root.inLandscape
0119         }
0120     }
0121 }