2023-10-22 03:59:27 +00:00
|
|
|
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
|
|
|
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import QtQuick.Controls as Controls
|
|
|
|
|
|
|
|
|
|
import org.kde.plasma.components 3.0 as PC3
|
2023-11-05 05:14:39 +00:00
|
|
|
import org.kde.kirigami as Kirigami
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-11-02 11:08:17 +00:00
|
|
|
import org.kde.plasma.private.mobileshell as MobileShell
|
2026-04-09 10:29:46 +00:00
|
|
|
import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings
|
2025-07-16 17:02:18 +00:00
|
|
|
import plasma.applet.org.kde.plasma.mobile.homescreen.folio as Folio
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2023-11-05 05:14:39 +00:00
|
|
|
import 'private'
|
|
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
Item {
|
|
|
|
|
id: root
|
2024-06-21 04:42:14 +00:00
|
|
|
required property Folio.HomeScreen folio
|
2023-10-22 03:59:27 +00:00
|
|
|
|
|
|
|
|
property var homeScreen
|
|
|
|
|
|
|
|
|
|
property real leftPadding: 0
|
|
|
|
|
property real topPadding: 0
|
|
|
|
|
property real bottomPadding: 0
|
|
|
|
|
property real rightPadding: 0
|
|
|
|
|
|
|
|
|
|
required property int headerHeight
|
|
|
|
|
required property var headerItem
|
|
|
|
|
|
2025-07-10 16:54:01 +00:00
|
|
|
// Height from top of screen that the drawer starts
|
2023-10-22 03:59:27 +00:00
|
|
|
readonly property real drawerTopMargin: height - topPadding - bottomPadding
|
|
|
|
|
|
|
|
|
|
property alias flickable: appDrawerGrid
|
|
|
|
|
|
2026-04-09 10:29:46 +00:00
|
|
|
// Convergence popup background
|
|
|
|
|
readonly property bool isPopup: ShellSettings.Settings.convergenceModeEnabled
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
visible: root.isPopup
|
|
|
|
|
anchors.fill: parent
|
2026-05-23 13:58:56 +00:00
|
|
|
radius: 0
|
2026-04-09 10:29:46 +00:00
|
|
|
color: Kirigami.Theme.backgroundColor
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-10 16:54:01 +00:00
|
|
|
// Keyboard navigation
|
|
|
|
|
Keys.onPressed: (event) => {
|
|
|
|
|
if (event.key === Qt.Key_Escape || event.key === Qt.Key_Back) {
|
|
|
|
|
// Close drawer if "back" action
|
|
|
|
|
folio.HomeScreenState.closeAppDrawer();
|
|
|
|
|
event.accepted = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// App drawer container
|
2023-10-22 03:59:27 +00:00
|
|
|
Item {
|
|
|
|
|
anchors.fill: parent
|
2026-04-09 10:29:46 +00:00
|
|
|
clip: root.isPopup
|
2023-10-22 03:59:27 +00:00
|
|
|
|
|
|
|
|
anchors.leftMargin: root.leftPadding
|
|
|
|
|
anchors.topMargin: root.topPadding
|
|
|
|
|
anchors.rightMargin: root.rightPadding
|
|
|
|
|
anchors.bottomMargin: root.bottomPadding
|
|
|
|
|
|
2025-07-10 16:54:01 +00:00
|
|
|
// Drawer header
|
2023-10-22 03:59:27 +00:00
|
|
|
MobileShell.BaseItem {
|
|
|
|
|
id: drawerHeader
|
2024-07-01 16:04:32 +00:00
|
|
|
z: 1
|
2023-10-22 03:59:27 +00:00
|
|
|
height: root.headerHeight
|
|
|
|
|
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
|
|
|
|
|
contentItem: root.headerItem
|
2025-07-10 16:54:01 +00:00
|
|
|
|
|
|
|
|
// Keyboard navigation for header (search bar)
|
|
|
|
|
Keys.onPressed: (event) => {
|
|
|
|
|
if (event.key === Qt.Key_Down || event.key === Qt.Key_Tab || event.key === Qt.Key_Backtab) {
|
|
|
|
|
// Go from search bar to app grid
|
|
|
|
|
appDrawerGrid.forceActiveFocus();
|
|
|
|
|
appDrawerGrid.currentIndex = 0;
|
|
|
|
|
event.accepted = true;
|
|
|
|
|
} else if (event.key === Qt.Key_Up) {
|
|
|
|
|
// Go to homescreen pages
|
|
|
|
|
folio.HomeScreenState.closeAppDrawer();
|
|
|
|
|
event.accepted = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
|
2025-07-10 16:54:01 +00:00
|
|
|
// App list
|
2023-10-22 03:59:27 +00:00
|
|
|
AppDrawerGrid {
|
|
|
|
|
id: appDrawerGrid
|
2024-06-21 04:42:14 +00:00
|
|
|
folio: root.folio
|
2023-10-22 03:59:27 +00:00
|
|
|
homeScreen: root.homeScreen
|
|
|
|
|
height: parent.height - drawerHeader.height
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.bottom: parent.bottom
|
2025-03-20 02:06:33 +00:00
|
|
|
opacity: 0 // we display with the opacity gradient below
|
2023-11-05 05:14:39 +00:00
|
|
|
headerHeight: root.headerHeight
|
2025-07-10 16:54:01 +00:00
|
|
|
|
|
|
|
|
// Keyboard navigation
|
|
|
|
|
topEdgeCallback: () => {
|
|
|
|
|
drawerHeader.contentItem.forceActiveFocus();
|
|
|
|
|
currentIndex = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Keys.onPressed: (event) => {
|
|
|
|
|
if (event.key === Qt.Key_Tab || event.key === Qt.Key_Backtab) {
|
|
|
|
|
topEdgeCallback();
|
|
|
|
|
event.accepted = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
|
2025-07-10 16:54:01 +00:00
|
|
|
// Opacity gradient at grid edges
|
2025-03-20 02:06:33 +00:00
|
|
|
MobileShell.FlickableOpacityGradient {
|
2023-10-22 03:59:27 +00:00
|
|
|
anchors.fill: appDrawerGrid
|
2023-11-05 05:14:39 +00:00
|
|
|
flickable: appDrawerGrid
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|