diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a1fc59a..59bec562 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,7 @@ set(QML_FILES qml/Helper.qml qml/Main.qml qml/FullscreenFrame.qml + qml/WrapView.qml qml/AppItemMenu.qml qml/GridViewContainer.qml qml/DrawerFolder.qml diff --git a/qml.qrc b/qml.qrc index e245bcb5..265001a9 100644 --- a/qml.qrc +++ b/qml.qrc @@ -1,6 +1,6 @@ - images/application-x-desktop.svg + images/application-x-desktop.svg images/exit_fullscreen.dci diff --git a/qml/FullscreenFrame.qml b/qml/FullscreenFrame.qml index c7d3dd7e..b2be2995 100644 --- a/qml/FullscreenFrame.qml +++ b/qml/FullscreenFrame.qml @@ -145,7 +145,7 @@ Control { anchors.horizontalCenter: parent.horizontalCenter // visible: pages.visible - count: searchResultGridViewContainer.visible ? 1 : pages.count + count: searchResultGridViewContainer.visible ? 1 : pages.model.count currentIndex: searchResultGridViewContainer.visible ? 1 : pages.currentIndex interactive: true delegate: Rectangle { @@ -219,13 +219,120 @@ Control { } } - SwipeView { + DelegateModel { + id: topLevelDelegateModel + + property int pageCount: ItemArrangementProxyModel.pageCount(0) + Binding on pageCount { + when: ItemArrangementProxyModel.onTopLevelPageCountChanged + value: ItemArrangementProxyModel.pageCount(0) + } + + model: pageCount + + delegate: Loader { + width: parent.width + height: parent.height + + objectName: "WrapViewDelegateModel GridViewLoader" + + sourceComponent: Rectangle { + color: "grey" + id: gvcHolder + + property int curPageNo: index + + Text { + anchors.centerIn: parent + font.pointSize: 26 + text: gvcHolder.curPageNo + } + + GridViewContainer { + id: gridViewContainer + anchors.fill: parent + rows: 4 + columns: 7 + paddingColumns: 1 + model: MultipageSortFilterProxyModel { + sourceModel: ItemArrangementProxyModel + pageId: gvcHolder.curPageNo // FIXME: why can't we use `index - 1` directly here? + folderId: 0 + } + padding: 10 + interactive: false + focus: true + opacity: folderGridViewPopup.visible ? 0.4 : 1 + // activeGridViewFocusOnTab: gridViewLoader.SwipeView.isCurrentItem + itemMove: Transition { NumberAnimation { properties: "x,y"; duration: 250 } } + delegate: DropArea { + width: gridViewContainer.cellWidth + height: gridViewContainer.cellHeight + onEntered: { + if (folderGridViewPopup.opened) { + folderGridViewPopup.close() + } + } + onDropped: { + let dragId = drop.getDataAsString("text/x-dde-launcher-dnd-desktopId") + let op = 0 + let sideOpPadding = width / 4 + if (drop.x < sideOpPadding) { + op = -1 + } else if (drop.x > (width - sideOpPadding)) { + op = 1 + } + dropOnItem(dragId, model.desktopId, op) + } + + IconItemDelegate { + id: iconItemDelegate + anchors.fill: parent + dndEnabled: true + Drag.mimeData: { + "text/x-dde-launcher-dnd-desktopId": model.desktopId + } + visible: dndItem.currentlyDraggedId !== model.desktopId + iconSource: iconName + icons: folderIcons + padding: 5 + onItemClicked: { + launchApp(desktopId) + } + onFolderClicked: { + let idStr = model.desktopId + let idNum = Number(idStr.replace("internal/folders/", "")) + folderLoader.currentFolderId = idNum + folderGridViewPopup.open() + folderLoader.folderName = model.display.startsWith("internal/category/") ? getCategoryName(model.display.substring(18)) : model.display + console.log("open folder id:" + idNum) + } + onMenuTriggered: { + showContextMenu(this, model, folderIcons, false, true) + } + } + } + } + } + } + } + + WrapView { id: pages anchors.fill: parent - visible: searchEdit.text === "" + model: topLevelDelegateModel currentIndex: indicator.currentIndex + } + + SwipeView { + // id: pages + + anchors.fill: parent + visible: false//searchEdit.text === "" + + // currentIndex: indicator.currentIndex // To ensure toplevelRepeater's model (page count) updated correctly // Caution! Don't put it directly under a Repeater{}, that will prevent Connections from working diff --git a/qml/WrapView.qml b/qml/WrapView.qml new file mode 100644 index 00000000..d35587fb --- /dev/null +++ b/qml/WrapView.qml @@ -0,0 +1,45 @@ +// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +import QtQuick 2.15 +import QtQml.Models 2.15 +import QtQuick.Layouts 1.15 +import QtQuick.Controls 2.15 + +Item { + id: root + + width: 200 + height: 200 + + required property DelegateModel model + property alias currentIndex: view.currentIndex + + function incrementCurrentIndex() { view.incrementCurrentIndex() } + function decrementCurrentIndex() { view.decrementCurrentIndex() } + + PathView { + id: view + + anchors.fill: parent + + snapMode: PathView.SnapOneItem + highlightRangeMode: PathView.StrictlyEnforceRange + currentIndex: -1 + pathItemCount: Math.min(3, root.model.count) + + model: root.model.model + delegate: root.model.delegate + + path: Path { + startX: -view.width / 2 + startY: view.height / 2 + + PathLine { + relativeX: view.width * view.pathItemCount + relativeY: 0 + } + } + } +}