test mimedata attachment and transport from drag to drop area
Works for me.
This commit is contained in:
parent
37e3ef99f0
commit
5a30426e07
@ -57,7 +57,7 @@ void DeclarativeDropArea::dragLeaveEvent(QDragLeaveEvent *event)
|
||||
void DeclarativeDropArea::dragMoveEvent(QDragMoveEvent *event)
|
||||
{
|
||||
DeclarativeDragDropEvent dde(event, this);
|
||||
qDebug() << "move.";
|
||||
//qDebug() << "move.";
|
||||
event->accept();
|
||||
emit dragMove(&dde);
|
||||
}
|
||||
|
@ -45,28 +45,57 @@ PlasmaComponents.Page {
|
||||
|
||||
DragAndDrop.DragArea {
|
||||
width: parent.width / 2
|
||||
delegate: Rectangle { width: 64; height: 64; color: "yellow"; opacity: 0.6; }
|
||||
anchors { left: parent.left; bottom: parent.bottom; top: parent.top; }
|
||||
Rectangle { anchors.fill: parent; color: "blue"; opacity: 0.2; }
|
||||
|
||||
mimeData.text: "Clownfish"
|
||||
mimeData.html: "<h2>Swimming in a sea of cheese</h2>"
|
||||
mimeData.color: "orange"
|
||||
mimeData.url: "http://plasma.kde.org"
|
||||
mimeData.urls: ["http://planetkde.org", "http://fsfe.org", "http://techbase.kde.org", "http://qt-project.org"]
|
||||
|
||||
//delegate: Rectangle { width: 64; height: 64; color: "yellow"; opacity: 0.6; }
|
||||
|
||||
onDragStarted: print("started");
|
||||
onDrop: print("drop: " + action);
|
||||
|
||||
Rectangle { anchors.fill: parent; color: "blue"; opacity: 1; }
|
||||
}
|
||||
|
||||
DragAndDrop.DropArea {
|
||||
width: parent.width / 2
|
||||
//visible: false
|
||||
anchors { right: parent.right; bottom: parent.bottom; top: parent.top; }
|
||||
Rectangle { anchors.fill: parent; color: "green"; opacity: 0.2; }
|
||||
Rectangle { id: clr; anchors.fill: parent; color: "green"; opacity: 1; }
|
||||
|
||||
onDrop: slabel.text = "item dropped"
|
||||
onDragEnter: slabel.text = "drop item here"
|
||||
onDragLeave: slabel.text = "drop left"
|
||||
onDragEnter: {
|
||||
slabel.text = "drop item here";
|
||||
clr.color = "turquoise";
|
||||
}
|
||||
onDragLeave: {
|
||||
slabel.text = "drop left";
|
||||
clr.color = "green";
|
||||
}
|
||||
onDrop: {
|
||||
var txt = event.mimeData.html;
|
||||
txt += event.mimeData.text;
|
||||
txt += "<br />Url: " + event.mimeData.url;
|
||||
var i = 0;
|
||||
var u;
|
||||
for (u in event.mimeData.urls) {
|
||||
i++;
|
||||
txt += "<br /> Url " + i + " : " + event.mimeData.urls[i];
|
||||
}
|
||||
clr.color = event.mimeData.color;
|
||||
slabel.text = txt + "<br />(item dropped)";
|
||||
}
|
||||
}
|
||||
PlasmaExtras.Heading {
|
||||
id: slabel
|
||||
level: 3
|
||||
text: "drag from left to right field."
|
||||
onTextChanged: print("droparea changed to " + text)
|
||||
anchors { right: parent.right; bottom: parent.bottom; }
|
||||
anchors { left: parent.left; right: parent.right; bottom: parent.bottom; }
|
||||
horizontalAlignment: Text.AlignRight
|
||||
}
|
||||
}
|
||||
// QtExtras.MouseEventListener {
|
||||
|
@ -46,12 +46,12 @@ Item {
|
||||
}
|
||||
height: _h
|
||||
|
||||
PlasmaComponents.TabButton { tab: dragPage; iconSource: "preferences-desktop-mouse"}
|
||||
PlasmaComponents.TabButton { tab: dialogsPage; iconSource: "preferences-system-windows"}
|
||||
PlasmaComponents.TabButton { tab: buttonsPage; iconSource: "preferences-desktop-theme"}
|
||||
PlasmaComponents.TabButton { tab: iconsPage; iconSource: "preferences-desktop-icons"}
|
||||
PlasmaComponents.TabButton { tab: plasmoidPage; iconSource: "plasma"}
|
||||
PlasmaComponents.TabButton { tab: mousePage; iconSource: "preferences-desktop-mouse"}
|
||||
PlasmaComponents.TabButton { tab: dragPage; iconSource: "preferences-desktop-mouse"}
|
||||
}
|
||||
|
||||
PlasmaComponents.TabGroup {
|
||||
@ -65,6 +65,9 @@ Item {
|
||||
|
||||
//currentTab: tabBar.currentTab
|
||||
|
||||
DragPage {
|
||||
id: dragPage
|
||||
}
|
||||
DialogsPage {
|
||||
id: dialogsPage
|
||||
}
|
||||
@ -85,9 +88,6 @@ Item {
|
||||
id: mousePage
|
||||
}
|
||||
|
||||
DragPage {
|
||||
id: dragPage
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
|
Loading…
Reference in New Issue
Block a user