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")
;; (compilation-read-command nil)
;; (projectile-project-compilation-cmd . "cmake -B buld/ . && make --dir build/"))))
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
((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
height: 900
Rectangle {
}
Presenter.MainWindow {
id: mainPage
}

View file

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

View file

@ -29,17 +29,26 @@ ColumnLayout {
}
}
DropArea {
id: serviceDropEnd
Layout.fillHeight: true
Layout.fillWidth: true
onDropped: {
serviceListModel.append({"name": dragSongTitle, "type": "song"});
}
keys: ["library"]
ListView {
id: serviceItemList
Layout.fillWidth: true
Layout.fillHeight: true
model: listModel
anchors.fill: parent
model: serviceListModel
delegate: Kirigami.DelegateRecycler {
width: serviceItemList.width
sourceComponent: itemDelegate
}
clip: true
spacing: 2
spacing: 3
addDisplaced: Transition {
NumberAnimation {properties: "x, y"; duration: 100}
}
@ -61,31 +70,45 @@ ColumnLayout {
Component {
id: itemDelegate
Item {
implicitWidth: ListView.view.width
height: 50
Kirigami.BasicListItem {
id: serviceItem
width: serviceItemList.width
height: 50
label: itemName
label: name
subtitle: type
hoverEnabled: true
backgroundColor: serviceDrop.containsDrag ? Kirigami.Theme.highlightColor : Kirigami.Theme.viewBackgroundColor
onClicked: serviceItemList.currentIndex = index
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: listModel.move(oldIndex, newIndex, 1)
anchors.fill: parent
onMoveRequested: serviceListModel.move(oldIndex, newIndex, 1)
onActivated: serviceItemList.currentIndex = index && showPassiveNotification(serviceItemList.currentIndex)
}
DropArea {
id: serviceDrop
Layout.fillHeight: true
Layout.fillWidth: true
onEntered: showPassiveNotification(drag.source + " has entered")
onDropped: listModel.append(drag.source)
width: serviceItemList.width
height: 50
onDropped: {
serviceListModel.insert(index, {"name": dragSongTitle, "type": "song"});
showPassiveNotification(index);
}
keys: ["library"]
}
}
}
@ -102,17 +125,27 @@ ColumnLayout {
active: hovered || pressed
}
ListModel {
id: listModel
id: serviceListModel
ListElement {
itemName: "10,000 Reason"
name: "10,000 Reason"
type: "song"
}
ListElement {
itemName: "Marvelous Light"
name: "Marvelous Light"
type: "song"
}
ListElement {
name: "10,000 Reason"
type: "song"
}
ListElement {
name: "Marvelous Light"
type: "song"
}
}
}
}
}

View file

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

View file

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

View file

@ -97,6 +97,15 @@ Item {
Layout.fillHeight: true
Layout.fillWidth: true
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 {
Controls.SplitView.fillHeight: true