/*SPDX-FileCopyrightText: 2023 Tanbir Jishan <tantalising007@gmail.com>SPDX-License-Identifier: GPL-2.0-or-later*/pragma ComponentBehavior: Boundimport QtQuickimport QtQuick.Templates as Timport org.kde.plasma.extras as PlasmaExtrasKickoffGridView {id: rootproperty int gridIndex: -1 // To know the index of the grid when used inside a listivewproperty bool isCurrentSectionGrid: falseproperty bool isSearchFieldActive: false // needed since check doesn't work here when gridview used in all appsproperty ListView parentView // needed when used inside a listview e.g. all apps viewsignal showSectionView(string sectionName)// When nested insdie a listivew, other items will still treat it as a delegate(because this was the truth always till now), so just call the appropriate functionreadonly property QtObject action: QtObject {function triggered(): void {root.view.currentItem.action.triggered();root.view.currentItem.forceActiveFocus();}}view.height: view.cellHeight * Math.ceil(count / view.columns)view.implicitHeight: view.contentHeightblockTargetWheel: falseview.highlight: PlasmaExtras.Highlight {visible: root.isCurrentSectionGrid// The default Z value for delegates is 1. The default Z value for the section delegate is 2.// The highlight gets a value of 3 while the drag is active and then goes back to the default value of 0.z: (root.currentItem?.Drag.active ?? false) ? 3 : 0pressed: (root.view.currentItem as T.AbstractButton)?.down ?? falsewidth: root.view.cellWidthheight: root.view.cellHeightactive: root.view.activeFocus|| (kickoff.contentArea === root&& kickoff.searchField.activeFocus)}delegate: KickoffGridDelegate {id: itemDelegatewidth: view.cellWidthAccessible.role: Accessible.CellConnections {target: itemDelegate.mouseAreafunction onPositionChanged(mouse) {if (!root.parentView.movedWithKeyboard) {root.parentView.currentIndex = root.gridIndexroot.parentView.currentItem.forceActiveFocus()}}}}}