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
|
2015-06-11 22:35:46 +00:00
|
|
|
|
2023-07-25 01:13:52 +00:00
|
|
|
import org.kde.kirigami 2.20 as Kirigami
|
|
|
|
|
|
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
|
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-03-03 06:11:51 +00:00
|
|
|
Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground
|
|
|
|
|
|
|
|
|
|
// toggle visibility of navigation bar (show, or use gestures only)
|
|
|
|
|
Binding {
|
|
|
|
|
target: plasmoid.Window.window // assumed to be plasma-workspace "PanelView" component
|
|
|
|
|
property: "visibilityMode"
|
|
|
|
|
// 0 - VisibilityMode.NormalPanel
|
2023-03-18 07:02:01 +00:00
|
|
|
// 2 - VisibilityMode.LetWindowsCover HACK: TODO one day we make delete the panel component instead of making it invisible in gesture-only mode
|
2023-03-18 19:28:17 +00:00
|
|
|
value: ShellSettings.Settings.navigationPanelEnabled ? 0 : 2
|
2023-03-03 06:11:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// we have the following scenarios:
|
|
|
|
|
// - system is in landscape orientation & nav panel is enabled (panel on right)
|
|
|
|
|
// - system is in landscape orientation & gesture mode is enabled (panel on bottom)
|
|
|
|
|
// - system is in portrait orientation (panel on bottom)
|
|
|
|
|
readonly property bool inLandscape: Screen.width > Screen.height;
|
2023-03-18 19:28:17 +00:00
|
|
|
readonly property bool isInLandscapeNavPanelMode: inLandscape && ShellSettings.Settings.navigationPanelEnabled
|
2023-03-03 06:11:51 +00:00
|
|
|
|
2023-07-25 01:13:52 +00:00
|
|
|
readonly property real navigationPanelHeight: Kirigami.Units.gridUnit * 2
|
2023-03-03 06:11:51 +00:00
|
|
|
|
2023-03-18 07:02:01 +00:00
|
|
|
readonly property real intendedWindowThickness: navigationPanelHeight
|
2023-03-03 06:11:51 +00:00
|
|
|
readonly property real intendedWindowLength: isInLandscapeNavPanelMode ? Screen.height : Screen.width
|
2023-03-26 18:22:14 +00:00
|
|
|
readonly property real intendedWindowOffset: isInLandscapeNavPanelMode ? MobileShell.Constants.topPanelHeight : 0; // offset for top panel
|
2023-03-03 06:11:51 +00:00
|
|
|
readonly property int intendedWindowLocation: isInLandscapeNavPanelMode ? PlasmaCore.Types.RightEdge : PlasmaCore.Types.BottomEdge
|
|
|
|
|
|
|
|
|
|
onIntendedWindowLengthChanged: maximizeTimer.restart() // ensure it always takes up the full length of the screen
|
|
|
|
|
onIntendedWindowLocationChanged: locationChangeTimer.restart()
|
2023-03-26 18:22:14 +00:00
|
|
|
onIntendedWindowOffsetChanged: {
|
|
|
|
|
if (plasmoid && plasmoid.Window.window) {
|
|
|
|
|
plasmoid.Window.window.offset = intendedWindowOffset;
|
|
|
|
|
}
|
|
|
|
|
}
|
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)
|
|
|
|
|
plasmoid.Window.window.maximize()
|
|
|
|
|
plasmoid.Window.window.offset = intendedWindowOffset;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// use a timer so that rotation events are faster (offload the panel movement to later, after everything is figured out)
|
|
|
|
|
Timer {
|
|
|
|
|
id: locationChangeTimer
|
|
|
|
|
running: false
|
|
|
|
|
interval: 100
|
|
|
|
|
onTriggered: plasmoid.Window.window.location = intendedWindowLocation
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setWindowProperties() {
|
|
|
|
|
// plasmoid.Window.window is assumed to be plasma-workspace "PanelView" component
|
2023-03-26 18:22:14 +00:00
|
|
|
if (plasmoid && plasmoid.Window.window) {
|
2023-03-18 07:02:01 +00:00
|
|
|
plasmoid.Window.window.maximize(); // maximize first, then we can apply offsets (otherwise they are overridden)
|
|
|
|
|
plasmoid.Window.window.offset = intendedWindowOffset;
|
|
|
|
|
plasmoid.Window.window.thickness = navigationPanelHeight;
|
|
|
|
|
plasmoid.Window.window.location = intendedWindowLocation;
|
|
|
|
|
}
|
2023-03-03 06:11:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
|
target: plasmoid.Window.window
|
|
|
|
|
|
|
|
|
|
// 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() {
|
|
|
|
|
if (plasmoid.Window.window.location !== root.intendedWindowLocation) {
|
|
|
|
|
root.setWindowProperties();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onThicknessChanged() {
|
|
|
|
|
if (plasmoid.Window.window.thickness !== root.intendedWindowThickness) {
|
|
|
|
|
root.setWindowProperties();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component.onCompleted: setWindowProperties();
|
|
|
|
|
|
|
|
|
|
// only opaque if there are no maximized windows on this screen
|
2023-03-19 01:48:49 +00:00
|
|
|
readonly property bool opaqueBar: WindowPlugin.WindowMaximizedTracker.showingWindow
|
2023-03-03 06:11:51 +00:00
|
|
|
|
2023-07-25 01:13:52 +00:00
|
|
|
Item {
|
2023-03-03 06:11:51 +00:00
|
|
|
anchors.fill: parent
|
2023-06-13 00:49:54 +00:00
|
|
|
|
|
|
|
|
// contrasting colour
|
2023-07-25 01:13:52 +00:00
|
|
|
Kirigami.Theme.colorSet: opaqueBar ? Kirigami.Theme.Window : Kirigami.Theme.Complementary
|
|
|
|
|
Kirigami.Theme.inherit: false
|
2023-06-13 00:49:54 +00:00
|
|
|
|
|
|
|
|
// load appropriate system navigation component
|
|
|
|
|
Loader {
|
|
|
|
|
id: navigationLoader
|
|
|
|
|
active: ShellSettings.Settings.navigationPanelEnabled
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
sourceComponent: NavigationPanelComponent {
|
|
|
|
|
opaqueBar: root.opaqueBar
|
|
|
|
|
}
|
2023-03-18 07:02:01 +00:00
|
|
|
}
|
2023-03-03 06:11:51 +00:00
|
|
|
}
|
2015-06-12 22:18:24 +00:00
|
|
|
}
|