activity switching animation

This commit is contained in:
Marco Martin 2013-10-18 13:07:28 +02:00
parent 76fcaeae69
commit 9b002a8bea
2 changed files with 71 additions and 6 deletions

View File

@ -72,7 +72,6 @@ void PlasmaQuickViewPrivate::setContainment(Plasma::Containment *cont)
qDebug() << "Old graphics Object:" << oldGraphicObject << "Old containment" << containment.data();
//make sure the graphic object won't die with us
//FIXME:we need a way to reparent to *NO* graphics item, but this makes Qt crash
oldGraphicObject->setProperty("visible", false);
oldGraphicObject->setParent(containment.data());
}
}
@ -112,7 +111,6 @@ void PlasmaQuickViewPrivate::setContainment(Plasma::Containment *cont)
(cont->containmentType() == Plasma::Types::DesktopContainment ||
cont->containmentType() == Plasma::Types::CustomContainment));
graphicObject->setProperty("parent", QVariant::fromValue(q->rootObject()));
graphicObject->setProperty("visible", true);
q->rootObject()->setProperty("containment", QVariant::fromValue(graphicObject));
} else {
qWarning() << "Containment graphic object not valid";

View File

@ -31,15 +31,82 @@ Rectangle {
property Item containment
onContainmentChanged: {
print("New Containment: " + containment)
//containment.parent = root
containment.visible = true
containment.anchors.fill = root
print("New Containment: " + containment);
print("Old Containment: " + internal.oldContainment);
//containment.parent = root;
containment.visible = true;
internal.newContainment = containment;
if (internal.oldContainment && internal.oldContainment != containment) {
switchAnim.running = true;
} else {
internal.oldContainment = containment;
}
}
//some properties that shouldn't be accessible from elsewhere
QtObject {
id: internal;
property Item oldContainment;
property Item newContainment;
}
SequentialAnimation {
id: switchAnim
ScriptAction {
script: {
containment.anchors.left = undefined;
containment.anchors.top = undefined;
containment.anchors.right = undefined;
containment.anchors.bottom = undefined;
internal.oldContainment.anchors.left = undefined;
internal.oldContainment.anchors.top = undefined;
internal.oldContainment.anchors.right = undefined;
internal.oldContainment.anchors.bottom = undefined;
internal.oldContainment.z = 0;
internal.oldContainment.x = 0;
containment.z = 1;
containment.x = root.width;
}
}
ParallelAnimation {
NumberAnimation {
target: internal.oldContainment
properties: "x"
to: -root.width
duration: 400
easing.type: Easing.InOutQuad
}
NumberAnimation {
target: internal.newContainment
properties: "x"
to: 0
duration: 250
easing.type: Easing.InOutQuad
}
}
ScriptAction {
script: {
containment.anchors.left = root.left;
containment.anchors.top = root.top;
containment.anchors.right = root.right;
containment.anchors.bottom = root.bottom;
internal.oldContainment.visible = false;
internal.oldContainment = containment;
}
}
}
Component.onCompleted: {
//configure the view behavior
desktop.stayBehind = true;
desktop.fillScreen = true;
print("View QML loaded")
}
}