Skip to content

Commit

Permalink
feat: support wrap between 1st and last page in FullscreenFrame
Browse files Browse the repository at this point in the history
支持首尾贯穿滚动

Log:
  • Loading branch information
BLumia committed Mar 14, 2024
1 parent dd4f863 commit f8203c0
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 4 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion qml.qrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<RCC>
<qresource prefix="/">
<file>images/application-x-desktop.svg</file>
<file>images/application-x-desktop.svg</file>
</qresource>
<qresource prefix="/dsg/built-in-icons">
<file alias="exit_fullscreen.dci">images/exit_fullscreen.dci</file>
Expand Down
113 changes: 110 additions & 3 deletions qml/FullscreenFrame.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
45 changes: 45 additions & 0 deletions qml/WrapView.qml
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}

0 comments on commit f8203c0

Please sign in to comment.