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

0001 // SPDX-FileCopyrightText: 2022-2023 Devin Lin <devin@kde.org>
0002 // SPDX-License-Identifier: LGPL-2.0-or-later
0003 
0004 import QtQuick
0005 import QtQuick.Controls as QQC2
0006 import QtQuick.Layouts
0007 import QtQuick.Window
0008 
0009 import org.kde.plasma.plasmoid
0010 import org.kde.plasma.components 3.0 as PC3
0011 import org.kde.draganddrop as DragDrop
0012 
0013 import org.kde.kirigami as Kirigami
0014 import org.kde.plasma.private.mobileshell.state as MobileShellState
0015 import org.kde.plasma.private.mobileshell.windowplugin as WindowPlugin
0016 
0017 Item {
0018     id: root
0019     
0020     required property real topMargin
0021     required property real bottomMargin
0022     required property real leftMargin
0023     required property real rightMargin
0024 
0025     required property bool interactive
0026     required property var searchWidget
0027     
0028     property alias page: swipeView.currentIndex
0029 
0030     property bool settingsOpen: false
0031     property real settingsOpenFactor: settingsOpen ? 1 : 0
0032 
0033     Behavior on settingsOpenFactor {
0034         NumberAnimation { duration: 200 }
0035     }
0036 
0037     function triggerHomescreen() {
0038         swipeView.setCurrentIndex(0);
0039         swipeView.focusChild();
0040         favoritesView.closeFolder();
0041         favoritesView.goToBeginning();
0042         gridAppList.goToBeginning();
0043     }
0044     
0045     function openConfigure() {
0046         settingsOpen = true;
0047     }
0048 
0049     function openContainmentSettings() {
0050         Plasmoid.internalAction("configure").trigger();
0051         Plasmoid.editMode = false;
0052     }
0053 
0054     Connections {
0055         target: WindowPlugin.WindowMaximizedTracker
0056 
0057         function onShowingWindowChanged(){
0058             if (WindowPlugin.WindowMaximizedTracker.showingWindow) {
0059                 swipeView.focusChild();
0060             }
0061         }
0062     }
0063 
0064     SettingsScreen {
0065         id: settings
0066         bottomMargin: root.bottomMargin
0067         anchors.fill: parent
0068         opacity: root.settingsOpenFactor
0069         visible: opacity > 0
0070         homeScreen: root
0071         z: 1
0072     }
0073 
0074     QQC2.SwipeView {
0075         id: swipeView
0076         opacity: Math.min(1 - root.settingsOpenFactor, 1 - searchWidget.openFactor)
0077         interactive: root.interactive
0078         
0079         anchors.fill: parent
0080         anchors.topMargin: root.topMargin
0081         anchors.bottomMargin: root.bottomMargin
0082         anchors.leftMargin: root.leftMargin
0083         anchors.rightMargin: root.rightMargin
0084 
0085         function focusChild() {
0086             currentItem.focusRequested();
0087         }
0088 
0089         onCurrentIndexChanged: focusChild()
0090 
0091         Item {
0092             height: swipeView.height
0093             width: swipeView.width
0094 
0095             signal focusRequested()
0096 
0097             // open wallpaper menu when held on click
0098             TapHandler {
0099                 onPressedChanged: {
0100                     if (pressed) {
0101                         favoritesView.resetHighlight();
0102                     }
0103                 }
0104 
0105                 onLongPressed: root.openConfigure()
0106             }
0107             
0108             FavoritesView {
0109                 id: favoritesView
0110                 anchors.fill: parent
0111                 searchWidget: root.searchWidget
0112                 interactive: root.interactive && swipeView.contentItem.contentX === 0
0113                 onOpenConfigureRequested: root.openConfigure()
0114 
0115                 onPageForwardRequested: {
0116                     swipeView.setCurrentIndex(1);
0117                     swipeView.focusChild();
0118                     resetHighlight();
0119                 }
0120             }
0121         }
0122 
0123         Item {
0124             width: swipeView.width
0125             height: swipeView.height
0126 
0127             signal focusRequested()
0128 
0129             GridAppList {
0130                 id: gridAppList
0131                 
0132                 anchors.fill: parent
0133 
0134                 property int horizontalMargin: Math.round(swipeView.width * 0.05)
0135                 interactive: root.interactive
0136                 leftMargin: horizontalMargin
0137                 rightMargin: horizontalMargin
0138 
0139                 leftEdgeCallback: () => {
0140                     swipeView.setCurrentIndex(0);
0141                     swipeView.focusChild();
0142                     currentIndex = -1;
0143                 }
0144             }
0145         }
0146     }
0147 }