Skip to content

Commit

Permalink
Disable DropArea for our own drags
Browse files Browse the repository at this point in the history
It doesn't make sense to drag our own items back into the app itself in
sink mode and it only creates a confusing animation, when starting to
drag items.

The animation is still enabled when dropping.

It is a shame that direct QML bindings do not work inside into another
ListView.

An example of the confusing animation can be seen as an unrelated
sideeffect in the demo of #5.
  • Loading branch information
vimpostor committed Apr 7, 2024
1 parent dea22dd commit 9dd0aa5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ ApplicationWindow {
onActivated: Qt.quit();
}
DropArea {
enabled: !pathView.dragActive
onDropped: (drop) => {
Backend.handle_dropped_urls(drop.urls);
}
Expand Down
14 changes: 12 additions & 2 deletions src/qml/PathView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Backend

ListView {
id: pathView
property bool dragActive: false

model: PathModel
visible: count
spacing: 6
Expand Down Expand Up @@ -33,10 +35,14 @@ ListView {
onPreDragStarted: {
PathModel.refresh_folded_paths();
}
onDragStarted: Settings.alwaysOnBottom = true
onDragStarted: {
Settings.alwaysOnBottom = true;
pathView.dragActive = true;
}
onDragFinished: (dropAction) => {
PathModel.taint_all_used();
Settings.alwaysOnBottom = false;
pathview.dragActive = false;
}
}
}
Expand Down Expand Up @@ -98,10 +104,14 @@ ListView {
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: PathModel.open(index);
onDragStarted: Settings.alwaysOnBottom = true
onDragStarted: {
Settings.alwaysOnBottom = true;
pathView.dragActive = true;
}
onDragFinished: (dropAction) => {
PathModel.taint_used(index)
Settings.alwaysOnBottom = false;
pathView.dragActive = false;
}
}
}
Expand Down

0 comments on commit 9dd0aa5

Please sign in to comment.