adding a blurred rect for background but it's not doing what I want

This commit is contained in:
Chris Cochrun 2022-10-13 13:23:47 -05:00
parent 478792913c
commit 1cac1e071a

View file

@ -7,6 +7,7 @@ import QtQuick.Layouts 1.2
import QtQml.Models 2.12 import QtQml.Models 2.12
/* import QtMultimedia 5.15 */ /* import QtMultimedia 5.15 */
/* import QtAudioEngine 1.15 */ /* import QtAudioEngine 1.15 */
import QtGraphicalEffects 1.15
import org.kde.kirigami 2.13 as Kirigami import org.kde.kirigami 2.13 as Kirigami
import "./" as Presenter import "./" as Presenter
import org.presenter 1.0 import org.presenter 1.0
@ -20,402 +21,419 @@ Item {
id: background id: background
color: Kirigami.Theme.backgroundColor color: Kirigami.Theme.backgroundColor
anchors.fill: parent anchors.fill: parent
ColumnLayout { }
id: layout
anchors.fill: parent
Rectangle { FastBlur {
id: headerBackground id: backgroundBlur
color: Kirigami.Theme.backgroundColor source: background
height: 40 anchors.fill: parent
opacity: 1.0 radius: 82
Layout.fillWidth: true }
Kirigami.Heading { ColumnLayout {
id: serviceTitle id: layout
text: "Service List" anchors.fill: parent
anchors.centerIn: headerBackground
padding: 5 Rectangle {
level: 3 id: headerBackground
color: Kirigami.Theme.backgroundColor
height: 40
opacity: 1.0
Layout.fillWidth: true
Kirigami.Heading {
id: serviceTitle
text: "Service List"
anchors.centerIn: headerBackground
padding: 5
level: 3
}
}
DropArea {
id: serviceDropEnd
Layout.fillHeight: true
Layout.fillWidth: true
onDropped: (drag) => {
print("DROPPED AT END");
showPassiveNotification(drag.source.title);
appendItem(dragItemTitle,
dragItemType,
dragItemBackground,
dragItemBackgroundType,
dragItemText,
dragItemAudio,
dragItemFont,
dragItemFontSize,
dragItemIndex);
dropHighlightLine.visible = false;
}
keys: ["library"]
onEntered: (drag) => {
if (drag.keys[0] === "library") {
dropHighlightLine.visible = true;
var lastItem = serviceItemList.itemAtIndex(serviceItemModel.rowCount() - 1);
dropHighlightLine.y = lastItem.y + lastItem.height;
} }
} }
DropArea { /* onExited: dropHighlightLine.visible = false; */
id: serviceDropEnd
Layout.fillHeight: true ListView {
Layout.fillWidth: true id: serviceItemList
onDropped: (drag) => { anchors.fill: parent
print("DROPPED AT END"); clip: true
showPassiveNotification(drag.source.title); spacing: 3
appendItem(dragItemTitle, property int indexDragged
dragItemType, property int moveToIndex
dragItemBackground, property int draggedY
dragItemBackgroundType,
dragItemText, addDisplaced: Transition {
dragItemAudio, NumberAnimation {properties: "x, y"; duration: 100}
dragItemFont, }
dragItemFontSize, moveDisplaced: Transition {
dragItemIndex); NumberAnimation { properties: "x, y"; duration: 100 }
dropHighlightLine.visible = false; }
remove: Transition {
NumberAnimation { properties: "x, y"; duration: 100 }
NumberAnimation { properties: "opacity"; duration: 100 }
} }
keys: ["library"] removeDisplaced: Transition {
NumberAnimation { properties: "x, y"; duration: 100 }
onEntered: (drag) => {
if (drag.keys[0] === "library") {
dropHighlightLine.visible = true;
var lastItem = serviceItemList.itemAtIndex(serviceItemModel.rowCount() - 1);
dropHighlightLine.y = lastItem.y + lastItem.height;
}
} }
/* onExited: dropHighlightLine.visible = false; */ displaced: Transition {
NumberAnimation {properties: "x, y"; duration: 100}
}
ListView { model: serviceItemModel
id: serviceItemList
anchors.fill: parent
clip: true
spacing: 3
property int indexDragged
property int moveToIndex
property int draggedY
addDisplaced: Transition { delegate: DropArea {
NumberAnimation {properties: "x, y"; duration: 100} id: serviceDrop
} implicitWidth: serviceItemList.width
moveDisplaced: Transition { height: 30
NumberAnimation { properties: "x, y"; duration: 100 } /* enabled: false */
}
remove: Transition { onEntered: (drag) => {
NumberAnimation { properties: "x, y"; duration: 100 } if (drag.keys[0] === "library") {
NumberAnimation { properties: "opacity"; duration: 100 } dropHighlightLine.visible = true;
dropHighlightLine.y = y - 2;
}
} }
removeDisplaced: Transition { /* onExited: dropHighlightLine.visible = false; */
NumberAnimation { properties: "x, y"; duration: 100 }
onDropped: (drag) => {
print("DROPPED IN ITEM AREA: " + drag.keys);
print(dragItemIndex + " " + index);
const hlIndex = serviceItemList.currentIndex;
if (drag.keys[0] === "library") {
addItem(index,
dragItemTitle,
dragItemType,
dragItemBackground,
dragItemBackgroundType,
dragItemText,
dragItemAudio,
dragItemFont,
dragItemFontSize,
dragItemIndex);
} else if (drag.keys[0] === "serviceitem") {
serviceItemModel.move(serviceItemList.indexDragged,
serviceItemList.moveToIndex);
serviceItemList.currentIndex = moveToIndex;
}
dropHighlightLine.visible = false;
} }
displaced: Transition { keys: ["library","serviceitem"]
NumberAnimation {properties: "x, y"; duration: 100}
}
model: serviceItemModel Rectangle {
id: visServiceItem
delegate: DropArea { width: serviceDrop.width
id: serviceDrop height: serviceDrop.height
implicitWidth: serviceItemList.width anchors {
height: 30 horizontalCenter: parent.horizontalCenter
/* enabled: false */ verticalCenter: parent.verticalCenter
}
onEntered: (drag) => { color: {
if (drag.keys[0] === "library") { if (active)
dropHighlightLine.visible = true; Kirigami.Theme.highlightColor;
dropHighlightLine.y = y - 2; else if (selected)
} Kirigami.Theme.focusColor;
else if (mouseHandler.containsMouse)
Kirigami.Theme.hoverColor;
else
Kirigami.Theme.backgroundColor;
} }
/* onExited: dropHighlightLine.visible = false; */ Controls.Label {
id: label
onDropped: (drag) => { anchors.left: parent.left
print("DROPPED IN ITEM AREA: " + drag.keys); anchors.verticalCenter: parent.verticalCenter
print(dragItemIndex + " " + index); anchors.leftMargin: 5
const hlIndex = serviceItemList.currentIndex; text: name
if (drag.keys[0] === "library") { elide: Text.ElideRight
addItem(index, width: parent.width - trailing.width - 15
dragItemTitle,
dragItemType,
dragItemBackground,
dragItemBackgroundType,
dragItemText,
dragItemAudio,
dragItemFont,
dragItemFontSize,
dragItemIndex);
} else if (drag.keys[0] === "serviceitem") {
serviceItemModel.move(serviceItemList.indexDragged,
serviceItemList.moveToIndex);
serviceItemList.currentIndex = moveToIndex;
}
dropHighlightLine.visible = false;
}
keys: ["library","serviceitem"]
Rectangle {
id: visServiceItem
width: serviceDrop.width
height: serviceDrop.height
anchors {
horizontalCenter: parent.horizontalCenter
verticalCenter: parent.verticalCenter
}
color: { color: {
if (active) if (selected ||
Kirigami.Theme.highlightColor; mouseHandler.containsMouse || active)
else if (selected) Kirigami.Theme.highlightedTextColor;
Kirigami.Theme.focusColor;
else if (mouseHandler.containsMouse)
Kirigami.Theme.hoverColor;
else else
Kirigami.Theme.backgroundColor; Kirigami.Theme.textColor;
} }
}
Controls.Label { Controls.Label {
id: label id: trailing
anchors.left: parent.left anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
text: name anchors.rightMargin: 5
elide: Text.ElideRight text: type
width: parent.width - trailing.width - 10 color: {
color: { if (selected ||
if (selected || mouseHandler.containsMouse || active)
mouseHandler.containsMouse || active) Kirigami.Theme.highlightedTextColor;
Kirigami.Theme.highlightedTextColor; else
else Kirigami.Theme.disabledTextColor;
Kirigami.Theme.textColor;
}
} }
}
Controls.Label { onYChanged: serviceItemList.updateDrag(Math.round(y));
id: trailing
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
text: type
color: Kirigami.Theme.disabledTextColor
}
onYChanged: serviceItemList.updateDrag(Math.round(y)); states: [
State {
states: [ when: mouseHandler.drag.active
State { ParentChange {
when: mouseHandler.drag.active
ParentChange {
target: visServiceItem
parent: serviceItemList
}
PropertyChanges {
target: visServiceItem
backgroundColor: Kirigami.Theme.backgroundColor
textColor: Kirigami.Theme.textColor
anchors.verticalCenter: undefined
anchors.horizontalCenter: undefined
}
}
]
/* Drag.dragType: Drag.Automatic */
Drag.active: mouseHandler.drag.active
Drag.hotSpot.x: width / 2
Drag.hotSpot.y: height / 2
Drag.keys: ["serviceitem"]
MouseArea {
id: mouseHandler
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
preventStealing: true
drag {
target: visServiceItem target: visServiceItem
axis: Drag.YAxis parent: serviceItemList
/* minimumY: root.y */
/* maximumY: serviceItemList.height - serviceDrop.height */
smoothed: false
} }
drag.onActiveChanged: { PropertyChanges {
if (mouseHandler.drag.active) { target: visServiceItem
serviceItemList.indexDragged = index; backgroundColor: Kirigami.Theme.backgroundColor
} textColor: Kirigami.Theme.textColor
anchors.verticalCenter: undefined
anchors.horizontalCenter: undefined
} }
}
]
/* onPositionChanged: { */ /* Drag.dragType: Drag.Automatic */
/* if (!pressed) { */ Drag.active: mouseHandler.drag.active
/* return; */ Drag.hotSpot.x: width / 2
/* } */ Drag.hotSpot.y: height / 2
/* mouseArea.arrangeItem(); */ Drag.keys: ["serviceitem"]
/* } */
onPressed: { MouseArea {
serviceItemList.interactive = false; id: mouseHandler
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
preventStealing: true
drag {
target: visServiceItem
axis: Drag.YAxis
/* minimumY: root.y */
/* maximumY: serviceItemList.height - serviceDrop.height */
smoothed: false
}
drag.onActiveChanged: {
if (mouseHandler.drag.active) {
serviceItemList.indexDragged = index;
} }
}
onClicked: { /* onPositionChanged: { */
if (mouse.button === Qt.RightButton) /* if (!pressed) { */
rightClickMenu.popup(); /* return; */
else { /* } */
/* serviceItemList.currentIndex = index; */ /* mouseArea.arrangeItem(); */
serviceItemModel.select(index); /* } */
/* currentServiceItem = index; */
/* changeItem(index); */
}
}
onDoubleClicked: { onPressed: {
/* showPassiveNotification("Double Clicked") */ serviceItemList.interactive = false;
}
onClicked: {
if (mouse.button === Qt.RightButton)
rightClickMenu.popup();
else {
/* serviceItemList.currentIndex = index; */ /* serviceItemList.currentIndex = index; */
changeServiceItem(index); serviceItemModel.select(index);
} /* currentServiceItem = index; */
/* changeItem(index); */
onReleased: {
print("should drop");
visServiceItem.Drag.drop();
} }
} }
}
Controls.Menu { onDoubleClicked: {
id: rightClickMenu /* showPassiveNotification("Double Clicked") */
x: mouseHandler.mouseX /* serviceItemList.currentIndex = index; */
y: mouseHandler.mouseY + 10 changeServiceItem(index);
Kirigami.Action { }
text: "delete"
onTriggered: removeItem(index); onReleased: {
print("should drop");
visServiceItem.Drag.drop();
} }
} }
} }
Controls.Menu {
id: rightClickMenu
Kirigami.WheelHandler { x: mouseHandler.mouseX
id: wheelHandler y: mouseHandler.mouseY + 10
target: serviceItemList Kirigami.Action {
filterMouseEvents: true text: "delete"
/* keyNavigationEnabled: true */ onTriggered: removeItem(index);
}
} }
Controls.ScrollBar.vertical: Controls.ScrollBar {
anchors.right: serviceItemList.right
anchors.rightMargin: 0
active: hovered || pressed
}
function updateDrag(y) {
if (moveToIndex === serviceItemList.indexAt(0,y))
return;
else
moveToIndex = serviceItemList.indexAt(0,y);
moveRequested(indexDragged, moveToIndex);
}
function moveRequested(oldIndex, newIndex) {
if (newIndex === oldIndex)
return;
if (newIndex === -1)
newIndex = 0;
if (newIndex >= serviceItemList.count)
newIndex = serviceItemList.count;
print("moveRequested: ", oldIndex, newIndex);
serviceItemModel.move(oldIndex, newIndex);
indexDragged = newIndex;
serviceItemList.currentIndex = newIndex;
}
} }
Rectangle {
id: dropHighlightLine
width: parent.width
height: 4
color: Kirigami.Theme.hoverColor
visible: false
Kirigami.WheelHandler {
id: wheelHandler
target: serviceItemList
filterMouseEvents: true
/* keyNavigationEnabled: true */
} }
Canvas {
/* asynchronous: true; */ Controls.ScrollBar.vertical: Controls.ScrollBar {
x: dropHighlightLine.width - 8 anchors.right: serviceItemList.right
y: dropHighlightLine.y - 17 anchors.rightMargin: 0
z: 1 active: hovered || pressed
width: 100; height: 100;
contextType: "2d"
onPaint: {
var ctx = getContext("2d");
ctx.fillStyle = Kirigami.Theme.hoverColor;
ctx.rotate(30);
ctx.transform(0.8, 0, 0, 0.8, 0, 30)
ctx.path = tearDropPath;
ctx.fill();
}
visible: dropHighlightLine.visible
} }
Path {
id: tearDropPath function updateDrag(y) {
startX: dropHighlightLine.width if (moveToIndex === serviceItemList.indexAt(0,y))
startY: dropHighlightLine.y + 4 return;
PathSvg { else
path: "M15 3 moveToIndex = serviceItemList.indexAt(0,y);
moveRequested(indexDragged, moveToIndex);
}
function moveRequested(oldIndex, newIndex) {
if (newIndex === oldIndex)
return;
if (newIndex === -1)
newIndex = 0;
if (newIndex >= serviceItemList.count)
newIndex = serviceItemList.count;
print("moveRequested: ", oldIndex, newIndex);
serviceItemModel.move(oldIndex, newIndex);
indexDragged = newIndex;
serviceItemList.currentIndex = newIndex;
}
}
Rectangle {
id: dropHighlightLine
width: parent.width
height: 4
color: Kirigami.Theme.hoverColor
visible: false
}
Canvas {
/* asynchronous: true; */
x: dropHighlightLine.width - 8
y: dropHighlightLine.y - 17
z: 1
width: 100; height: 100;
contextType: "2d"
onPaint: {
var ctx = getContext("2d");
ctx.fillStyle = Kirigami.Theme.hoverColor;
ctx.rotate(30);
ctx.transform(0.8, 0, 0, 0.8, 0, 30)
ctx.path = tearDropPath;
ctx.fill();
}
visible: dropHighlightLine.visible
}
Path {
id: tearDropPath
startX: dropHighlightLine.width
startY: dropHighlightLine.y + 4
PathSvg {
path: "M15 3
Q16.5 6.8 25 18 Q16.5 6.8 25 18
A12.8 12.8 0 1 1 5 18 A12.8 12.8 0 1 1 5 18
Q13.5 6.8 15 3z" Q13.5 6.8 15 3z"
}
} }
} }
Kirigami.ActionToolBar {
id: serviceToolBar
Layout.fillWidth: true
opacity: 1.0
actions: [
Kirigami.Action {
/* text: "Up" */
icon.name: "arrow-up"
onTriggered: {
const oldid = serviceItemList.currentIndex;
if (oldid <= 0)
{
showPassiveNotification("wow stop trying to go nego");
return;
}
const newid = serviceItemList.currentIndex - 1;
showPassiveNotification(oldid + " " + newid);
showPassiveNotification("Up");
const ans = serviceItemModel.move(oldid, newid);
if (ans)
{
serviceItemList.currentIndex = newid;
showPassiveNotification("move was successful, newid: "
+ serviceItemList.currentIndex);
}
else
showPassiveNotification("move was unsuccessful")
}
},
Kirigami.Action {
/* text: "Down" */
icon.name: "arrow-down"
onTriggered: {
const id = serviceItemList.currentIndex;
if (id + 1 >= serviceItemList.count)
{
showPassiveNotification("wow you dummy you can't got further down");
return;
};
showPassiveNotification("moving ", id, " down");
const ans = serviceItemModel.moveDown(id);
if (ans)
{
serviceItemList.currentIndex = id + 1;
showPassiveNotification("move was successful, newid: "
+ serviceItemList.currentIndex);
}
else
showPassiveNotification("move was unsuccessful, id: "
+ id);
}
},
Kirigami.Action {
/* text: "Remove" */
icon.name: "delete"
onTriggered: {
showPassiveNotification("remove");
removeItem(serviceItemList.currentIndex);
}
}
]
}
} }
Kirigami.ActionToolBar {
id: serviceToolBar
Layout.fillWidth: true
opacity: 1.0
actions: [
Kirigami.Action {
/* text: "Up" */
icon.name: "arrow-up"
onTriggered: {
const oldid = serviceItemList.currentIndex;
if (oldid <= 0)
{
showPassiveNotification("wow stop trying to go nego");
return;
}
const newid = serviceItemList.currentIndex - 1;
showPassiveNotification(oldid + " " + newid);
showPassiveNotification("Up");
const ans = serviceItemModel.move(oldid, newid);
if (ans)
{
serviceItemList.currentIndex = newid;
showPassiveNotification("move was successful, newid: "
+ serviceItemList.currentIndex);
}
else
showPassiveNotification("move was unsuccessful")
}
},
Kirigami.Action {
/* text: "Down" */
icon.name: "arrow-down"
onTriggered: {
const id = serviceItemList.currentIndex;
if (id + 1 >= serviceItemList.count)
{
showPassiveNotification("wow you dummy you can't got further down");
return;
};
showPassiveNotification("moving ", id, " down");
const ans = serviceItemModel.moveDown(id);
if (ans)
{
serviceItemList.currentIndex = id + 1;
showPassiveNotification("move was successful, newid: "
+ serviceItemList.currentIndex);
}
else
showPassiveNotification("move was unsuccessful, id: "
+ id);
}
},
Kirigami.Action {
/* text: "Remove" */
icon.name: "delete"
onTriggered: {
showPassiveNotification("remove");
removeItem(serviceItemList.currentIndex);
}
}
]
}
} }
Component.onCompleted: { Component.onCompleted: {
totalServiceItems = serviceItemList.count; totalServiceItems = serviceItemList.count;
print("THE TOTAL SERVICE ITEMS: " + totalServiceItems); print("THE TOTAL SERVICE ITEMS: " + totalServiceItems);