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-11-14 06:11:50 +00:00
|
|
|
Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground
|
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()
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-14 06:11:50 +00:00
|
|
|
// filled in by the shell (Panel.qml)
|
|
|
|
|
property var tabBar: null
|
|
|
|
|
onTabBarChanged: {
|
|
|
|
|
if (tabBar) {
|
|
|
|
|
tabBar.visible = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-03 06:11:51 +00:00
|
|
|
|
|
|
|
|
readonly property bool inLandscape: Screen.width > Screen.height;
|
|
|
|
|
|
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-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
|
|
|
|
|
onIntendedWindowLocationChanged: locationChangeTimer.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
|
|
|
|
|
|
|
|
// 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)
|
2023-10-17 05:12:44 +00:00
|
|
|
root.panel.maximize()
|
|
|
|
|
root.panel.offset = intendedWindowOffset;
|
2023-03-03 06:11:51 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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
|
2023-10-17 05:12:44 +00:00
|
|
|
onTriggered: root.panel.location = intendedWindowLocation
|
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;
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
2023-10-21 05:46:31 +00:00
|
|
|
NavigationPanelComponent {
|
2023-06-13 00:49:54 +00:00
|
|
|
anchors.fill: parent
|
2023-10-21 05:46:31 +00:00
|
|
|
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
|
|
|
}
|