Fixing the leftdock to accept Library items

This commit is contained in:
Chris Cochrun 2022-03-01 09:47:07 -06:00
parent 48f051045f
commit e1c7e319c7
7 changed files with 149 additions and 81 deletions

View file

@ -1,3 +1,8 @@
;; ((nil . ((projectile-project-run-cmd . "cmake -B buld/ . && make --dir build/ && ./build/bin/presenter") ;;; Directory Local Variables
;; (compilation-read-command nil) ;;; For more information see (info "(emacs) Directory Variables")
;; (projectile-project-compilation-cmd . "cmake -B buld/ . && make --dir build/"))))
((nil . ((projectile-project-run-cmd . "./build/bin/presenter")
(compilation-read-command . (nil))
(projectile-project-compilation-cmd . "cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -B buld/ . && make --dir build/")))
(qml-mode . ((completion-at-point-functions . (list
(cape-super-capf #'cape-dabbrev #'cape-dict))))))

View file

@ -21,6 +21,10 @@ Kirigami.ApplicationWindow {
width: 1800 width: 1800
height: 900 height: 900
Rectangle {
}
Presenter.MainWindow { Presenter.MainWindow {
id: mainPage id: mainPage
} }

View file

@ -35,6 +35,9 @@ Item {
*/ */
signal dropped() signal dropped()
// Emitted when clicking to activate underneath mousearea
signal activated()
MouseArea { MouseArea {
id: mouseArea id: mouseArea
anchors.fill: parent anchors.fill: parent
@ -43,6 +46,7 @@ Item {
axis: Drag.YAxis axis: Drag.YAxis
minimumY: 0 minimumY: 0
maximumY: listView.height - listItem.height maximumY: listView.height - listItem.height
filterChildren: true
} }
/* cursorShape: pressed ? Qt.ClosedHandCursor : Qt.OpenHandCursor */ /* cursorShape: pressed ? Qt.ClosedHandCursor : Qt.OpenHandCursor */
@ -60,8 +64,9 @@ Item {
} }
} }
preventStealing: true preventStealing: false
onPressed: { onPressed: {
listView.interactive = false;
mouseArea.originalParent = listItem.parent; mouseArea.originalParent = listItem.parent;
listItem.parent = listView; listItem.parent = listView;
listItem.y = mouseArea.originalParent.mapToItem(listItem.parent, listItem.x, listItem.y).y; listItem.y = mouseArea.originalParent.mapToItem(listItem.parent, listItem.x, listItem.y).y;
@ -81,6 +86,7 @@ Item {
listItem.y > listView.height - mouseArea.autoScrollThreshold); listItem.y > listView.height - mouseArea.autoScrollThreshold);
} }
onReleased: { onReleased: {
listView.interactive = true;
listItem.y = mouseArea.originalParent.mapFromItem(listItem, 0, 0).y; listItem.y = mouseArea.originalParent.mapFromItem(listItem, 0, 0).y;
listItem.parent = mouseArea.originalParent; listItem.parent = mouseArea.originalParent;
dropAnimation.running = true; dropAnimation.running = true;
@ -116,5 +122,11 @@ Item {
mouseArea.arrangeItem(); mouseArea.arrangeItem();
} }
} }
MouseArea {
id: clickArea
anchors.fill: parent
onClicked: root.activated()
}
} }
} }

View file

@ -29,90 +29,123 @@ ColumnLayout {
} }
} }
ListView { DropArea {
id: serviceItemList id: serviceDropEnd
Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
model: listModel Layout.fillWidth: true
delegate: Kirigami.DelegateRecycler { onDropped: {
width: serviceItemList.width serviceListModel.append({"name": dragSongTitle, "type": "song"});
sourceComponent: itemDelegate
}
clip: true
spacing: 2
addDisplaced: Transition {
NumberAnimation {properties: "x, y"; duration: 100}
}
moveDisplaced: Transition {
NumberAnimation { properties: "x, y"; duration: 100 }
}
remove: Transition {
NumberAnimation { properties: "x, y"; duration: 100 }
NumberAnimation { properties: "opacity"; duration: 100 }
} }
keys: ["library"]
removeDisplaced: Transition { ListView {
NumberAnimation { properties: "x, y"; duration: 100 } id: serviceItemList
} anchors.fill: parent
model: serviceListModel
displaced: Transition { delegate: Kirigami.DelegateRecycler {
NumberAnimation {properties: "x, y"; duration: 100}
}
Component {
id: itemDelegate
Kirigami.BasicListItem {
id: serviceItem
width: serviceItemList.width width: serviceItemList.width
height:50 sourceComponent: itemDelegate
label: itemName }
subtitle: type clip: true
hoverEnabled: true spacing: 3
backgroundColor: serviceDrop.containsDrag ? Kirigami.Theme.highlightColor : Kirigami.Theme.viewBackgroundColor
onClicked: serviceItemList.currentIndex = index
Presenter.DragHandle { addDisplaced: Transition {
listItem: serviceItem NumberAnimation {properties: "x, y"; duration: 100}
listView: serviceItemList }
onMoveRequested: listModel.move(oldIndex, newIndex, 1) moveDisplaced: Transition {
anchors.fill: parent NumberAnimation { properties: "x, y"; duration: 100 }
}
remove: Transition {
NumberAnimation { properties: "x, y"; duration: 100 }
NumberAnimation { properties: "opacity"; duration: 100 }
}
removeDisplaced: Transition {
NumberAnimation { properties: "x, y"; duration: 100 }
}
displaced: Transition {
NumberAnimation {properties: "x, y"; duration: 100}
}
Component {
id: itemDelegate
Item {
implicitWidth: ListView.view.width
height: 50
Kirigami.BasicListItem {
id: serviceItem
width: serviceItemList.width
height: 50
label: name
subtitle: type
hoverEnabled: true
supportsMouseEvents: false
backgroundColor: {
if (serviceDrop.containsDrag | isCurrentItem) {
Kirigami.Theme.highlightColor
} else
Kirigami.Theme.viewBackgroundColor
}
/* onClicked: serviceItemList.currentIndex = index && showPassiveNotification(serviceItemList.currentIndex) */
}
Presenter.DragHandle {
width: serviceItemList.width
height: 50
/* anchors.fill: parent */
listItem: serviceItem
listView: serviceItemList
onMoveRequested: serviceListModel.move(oldIndex, newIndex, 1)
onActivated: serviceItemList.currentIndex = index && showPassiveNotification(serviceItemList.currentIndex)
}
DropArea {
id: serviceDrop
width: serviceItemList.width
height: 50
onDropped: {
serviceListModel.insert(index, {"name": dragSongTitle, "type": "song"});
showPassiveNotification(index);
}
keys: ["library"]
}
} }
}
DropArea { Kirigami.WheelHandler {
id: serviceDrop id: wheelHandler
Layout.fillHeight: true target: serviceItemList
Layout.fillWidth: true filterMouseEvents: true
onEntered: showPassiveNotification(drag.source + " has entered") keyNavigationEnabled: true
onDropped: listModel.append(drag.source) }
Controls.ScrollBar.vertical: Controls.ScrollBar {
anchors.right: serviceItemList.right
anchors.leftMargin: 10
active: hovered || pressed
}
ListModel {
id: serviceListModel
ListElement {
name: "10,000 Reason"
type: "song"
}
ListElement {
name: "Marvelous Light"
type: "song"
}
ListElement {
name: "10,000 Reason"
type: "song"
}
ListElement {
name: "Marvelous Light"
type: "song"
} }
} }
} }
Kirigami.WheelHandler {
id: wheelHandler
target: serviceItemList
filterMouseEvents: true
keyNavigationEnabled: true
}
Controls.ScrollBar.vertical: Controls.ScrollBar {
anchors.right: serviceItemList.right
anchors.leftMargin: 10
active: hovered || pressed
}
ListModel {
id: listModel
ListElement {
itemName: "10,000 Reason"
type: "song"
}
ListElement {
itemName: "Marvelous Light"
type: "song"
}
}
} }
} }

View file

@ -189,6 +189,7 @@ Item {
Drag.active: dragHandler.drag.active Drag.active: dragHandler.drag.active
Drag.hotSpot.x: width / 2 Drag.hotSpot.x: width / 2
Drag.hotSpot.y: height / 2 Drag.hotSpot.y: height / 2
Drag.keys: [ "library" ]
states: State { states: State {
name: "dragged" name: "dragged"
@ -210,8 +211,10 @@ Item {
target: songListItem target: songListItem
onActiveChanged: { onActiveChanged: {
if (dragHandler.drag.active) { if (dragHandler.drag.active) {
draggedLibraryItem = songLibraryList.currentItem dragSongTitle = title
showPassiveNotification(index) showPassiveNotification(dragSongTitle)
} else {
songListItem.Drag.drop()
} }
} }
filterChildren: true filterChildren: true

View file

@ -20,6 +20,8 @@ Controls.Page {
property string songVorder: "" property string songVorder: ""
property int blurRadius: 0 property int blurRadius: 0
property string dragSongTitle: ""
property Item slideItem property Item slideItem
property var song property var song
property var draggedLibraryItem property var draggedLibraryItem
@ -42,7 +44,7 @@ Controls.Page {
Rectangle { Rectangle {
height: parent.height height: parent.height
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
implicitWidth: 1 width: 1
color: Controls.SplitHandle.hovered ? Kirigami.Theme.hoverColor : Kirigami.Theme.backgroundColor color: Controls.SplitHandle.hovered ? Kirigami.Theme.hoverColor : Kirigami.Theme.backgroundColor
} }
} }

View file

@ -97,6 +97,15 @@ Item {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
Layout.columnSpan: 2 Layout.columnSpan: 2
handle: Item{
implicitWidth: 6
Rectangle {
height: parent.height
anchors.horizontalCenter: parent.horizontalCenter
width: 1
color: Controls.SplitHandle.hovered ? Kirigami.Theme.hoverColor : Kirigami.Theme.backgroundColor
}
}
ColumnLayout { ColumnLayout {
Controls.SplitView.fillHeight: true Controls.SplitView.fillHeight: true