From e0d4360f6fcaae15ff366fd55fa8c6661771ce33 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Tue, 1 Mar 2022 15:29:26 -0600 Subject: [PATCH] Finally getting leftdock into shape --- .dir-locals.el | 4 +-- src/qml/presenter/DragHandle.qml | 8 +++-- src/qml/presenter/LeftDock.qml | 61 +++++++++++++++++++++++--------- src/qml/presenter/Library.qml | 8 ++--- 4 files changed, 55 insertions(+), 26 deletions(-) diff --git a/.dir-locals.el b/.dir-locals.el index e29a5f1..cca5fb8 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -3,6 +3,4 @@ ((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)))))) + (projectile-project-compilation-cmd . "cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -B buld/ . && make --dir build/")))) diff --git a/src/qml/presenter/DragHandle.qml b/src/qml/presenter/DragHandle.qml index f4f957d..ad3aa0c 100644 --- a/src/qml/presenter/DragHandle.qml +++ b/src/qml/presenter/DragHandle.qml @@ -17,6 +17,7 @@ Item { * The id of the ListView the delegates belong to. */ property ListView listView + property bool containsMouse /** * Emitted when the drag handle wants to move the item in the model @@ -36,7 +37,7 @@ Item { signal dropped() // Emitted when clicking to activate underneath mousearea - signal activated() + signal clicked() MouseArea { id: mouseArea @@ -126,7 +127,10 @@ Item { MouseArea { id: clickArea anchors.fill: parent - onClicked: root.activated() + onClicked: root.clicked() + hoverEnabled: true + onEntered: root.containsMouse = true + onExited: root.containsMouse = false } } } diff --git a/src/qml/presenter/LeftDock.qml b/src/qml/presenter/LeftDock.qml index 55d547a..b48a9bd 100644 --- a/src/qml/presenter/LeftDock.qml +++ b/src/qml/presenter/LeftDock.qml @@ -71,38 +71,48 @@ ColumnLayout { Component { id: itemDelegate Item { - implicitWidth: ListView.view.width + id: serviceItem + implicitWidth: serviceItemList.width height: 50 Kirigami.BasicListItem { - id: serviceItem - width: serviceItemList.width - height: 50 + anchors.fill: parent label: name subtitle: type hoverEnabled: true supportsMouseEvents: false backgroundColor: { - if (serviceDrop.containsDrag | isCurrentItem) { - Kirigami.Theme.highlightColor - } else - Kirigami.Theme.viewBackgroundColor + if (parent.ListView.isCurrentItem) { + Kirigami.Theme.highlightColor; + /* } else if (serviceDrop.constainsDrag){ */ + /* Kirigami.Theme.hoverColor; */ + } else if (mouseHandler.containsMouse){ + Kirigami.Theme.highlightColor; + } else { + Kirigami.Theme.backgroundColor; + } + } + textColor: { + if (parent.ListView.isCurrentItem || mouseHandler.containsMouse) + activeTextColor; + else + Kirigami.Theme.textColor; } - /* onClicked: serviceItemList.currentIndex = index && showPassiveNotification(serviceItemList.currentIndex) */ - } Presenter.DragHandle { - width: serviceItemList.width - height: 50 - /* anchors.fill: parent */ + id: mouseHandler + anchors.fill: parent listItem: serviceItem listView: serviceItemList onMoveRequested: serviceListModel.move(oldIndex, newIndex, 1) - onActivated: serviceItemList.currentIndex = index && showPassiveNotification(serviceItemList.currentIndex) + onClicked: { + serviceItemList.currentIndex = index; + showPassiveNotification(serviceItemList.currentIndex); + } } + DropArea { id: serviceDrop - width: serviceItemList.width - height: 50 + anchors.fill: parent onDropped: { serviceListModel.insert(index, {"name": dragSongTitle, "type": "song"}); showPassiveNotification(index); @@ -121,9 +131,10 @@ ColumnLayout { Controls.ScrollBar.vertical: Controls.ScrollBar { anchors.right: serviceItemList.right - anchors.leftMargin: 10 + anchors.rightMargin: 0 active: hovered || pressed } + ListModel { id: serviceListModel ListElement { @@ -142,6 +153,22 @@ ColumnLayout { name: "Marvelous Light" type: "song" } + 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" + } } } diff --git a/src/qml/presenter/Library.qml b/src/qml/presenter/Library.qml index 7bc6609..36f251e 100644 --- a/src/qml/presenter/Library.qml +++ b/src/qml/presenter/Library.qml @@ -107,7 +107,7 @@ Item { Kirigami.ActionToolBar { height: selectedLibrary == "songs" ? 40 : 0 width: parent.width - display: IconOnly + display: Button.IconOnly actions: [ Kirigami.Action { icon.name: "document-new" @@ -148,7 +148,7 @@ Item { property bool rightMenu: false - implicitWidth: ListView.view.width + implicitWidth: songLibraryList.width height: selectedLibrary == "songs" ? 50 : 0 clip: true label: title @@ -158,8 +158,8 @@ Item { if (parent.ListView.isCurrentItem) { Kirigami.Theme.highlightColor; } else if (dragHandler.containsMouse){ - Kirigami.Theme.hoverColor; - } else { + Kirigami.Theme.highlightColor; + } else { Kirigami.Theme.backgroundColor; } }