Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 67 additions & 4 deletions qml/FolderGridViewPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,35 @@ Popup {

MultipageSortFilterProxyModel {
id: folderProxyModel
filterOnlyMode: true
sourceModel: ItemArrangementProxyModel
pageId: modelData
folderId: folderLoader.currentFolderId
}

SortProxyModel {
id: sortProxyModel
sourceModel: folderProxyModel
sortRole: ItemArrangementProxyModel.IndexInPageRole
Component.onCompleted: {
Comment thread
wjyrich marked this conversation as resolved.
sortProxyModel.sort(0)
}
}

//gridViewContainer
Loader {
id: gridViewContainerLoader
anchors.fill: parent

sourceComponent: isWindowedMode ? listViewGridViewContainer : fullScreenGridViewContainer

// Define common itemMove transition to avoid duplication
property Transition itemMove: Transition {
NumberAnimation {
properties: "x,y"
duration: 200
easing.type: Easing.OutQuad
}
}
}

Component {
Expand All @@ -295,13 +313,13 @@ Popup {
anchors.fill: parent
rows: 3
columns: 4
model: folderProxyModel
model: sortProxyModel
padding: 10
interactive: false
focus: true
gridViewClip: false // TODO it maybe a bug for dtk, https://github.com/linuxdeepin/developer-center/issues/8468
activeGridViewFocusOnTab: folderGridViewLoader.SwipeView.isCurrentItem
itemMove: Transition { NumberAnimation { properties: "x,y"; duration: 250 } }
itemMove: parent.itemMove
delegate: DelegateDropArea {
width: folderGridViewContainer.cellWidth
height: folderGridViewContainer.cellHeight
Expand All @@ -316,14 +334,15 @@ Popup {
anchors.fill: parent
rows: 3
columns: 4
model: folderProxyModel
model: sortProxyModel
paddingRows: 6
cellHeight: 86
paddingColumns: 2
interactive: false
focus: true
gridViewClip: false
activeGridViewFocusOnTab: folderGridViewLoader.SwipeView.isCurrentItem
itemMove: parent.itemMove
delegate: DelegateDropArea {
width: folderGridViewContainer.cellWidth
height: folderGridViewContainer.cellHeight
Expand All @@ -332,7 +351,28 @@ Popup {
}

component DelegateDropArea: DropArea {
onEntered: function(drag) {
folderDragApplyTimer.dragId = drag.getDataAsString("text/x-dde-launcher-dnd-desktopId")
Comment thread
wjyrich marked this conversation as resolved.
folderDragApplyTimer.restart()
}
onPositionChanged: function(drag) {
let dragId = drag.getDataAsString("text/x-dde-launcher-dnd-desktopId")
if (dragId === model.desktopId) {
return
}
folderDragApplyTimer.dragId = dragId
folderDragApplyTimer.currentDropX = drag.x
if (!folderDragApplyTimer.running) {
folderDragApplyTimer.restart()
}
}
onExited: {
folderDragApplyTimer.stop()
folderDragApplyTimer.dragId = ""
}
onDropped: function(drop) {
folderDragApplyTimer.stop()
folderDragApplyTimer.dragId = ""
let dragId = drop.getDataAsString("text/x-dde-launcher-dnd-desktopId")
if (dragId === model.desktopId) {
return
Expand All @@ -345,6 +385,29 @@ Popup {
}

dropOnItem(dragId, model.desktopId, op)
sortProxyModel.sort(0)
}

Timer {
id: folderDragApplyTimer
interval: 500
property string dragId: ""
property real currentDropX: 0
onTriggered: function() {
if (dragId === "") return
let op = 0
let sideOpPadding = parent.width / 4
if (currentDropX < sideOpPadding) {
op = -1
} else if (currentDropX > (parent.width - sideOpPadding)) {
op = 1
}
// 只有在需要插入操作时才执行预览移动
if (op !== 0) {
dropOnItem(dragId, model.desktopId, op)
sortProxyModel.sort(0)
}
}
}
Keys.forwardTo: [innerItem]

Expand Down
15 changes: 11 additions & 4 deletions qml/GridViewContainer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,19 @@ FocusScope {
Rectangle {
anchors.centerIn: parent
width: {
if (root.objectName === "folderGridViewContainer")
return model.rowCount() > root.columns - 1 ? item.cellWidth * root.columns : model.rowCount() * item.cellWidth
else
if (root.objectName === "folderGridViewContainer") {
return item.cellWidth * root.columns + root.paddingColumns * Math.max(0, root.columns - 1) + root.paddingColumns
} else {
return item.cellWidth * root.columns
}
}
height: {
if (root.objectName === "folderGridViewContainer") {
return item.cellHeight * root.rows + root.paddingColumns * Math.max(0, root.rows - 1)
} else {
return root.rows == 0 ? parent.height : (item.cellHeight * root.rows)
}
}
height: rows == 0 ? parent.height : (item.cellHeight * root.rows)
color: "transparent"

GridView {
Expand Down
5 changes: 5 additions & 0 deletions qml/windowed/GridViewContainer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ FocusScope {
property int paddingRows: Helper.frequentlyUsed.cellPaddingRows
property real cellHeight: 82
property real cellWidth: 80
property Transition itemMove

readonly property alias currentItem: gridView.currentItem
readonly property alias gridViewWidth: gridView.width
Expand Down Expand Up @@ -84,6 +85,10 @@ FocusScope {
cellHeight: root.cellHeight + paddingRows
cellWidth: root.cellWidth + paddingColumns

displaced: root.itemMove
move: root.itemMove
moveDisplaced: root.itemMove

highlight: Item {
FocusBoxBorder {
anchors {
Expand Down