Commit 7d12429e authored by Nicolas Fella's avatar Nicolas Fella Committed by Bhushan Shah
Browse files

Remove prototypes

parent 3d9e43b1
import QtQuick 2.1
Rectangle {
id: cardRoot
color: "red"
width: parent.width
height: parent.height
y: Math.max(Math.min((height - root.cardMargins * (parent.children.length - step)), (root.scrollValue + height * step)),
root.cardMargins*step)
property int step: 0
property bool current: root.scrollValue + cardRoot.height * step == 0
Image {
anchors {
left: parent.left
right: parent.right
bottom: parent.top
}
opacity: (root.cardMargins/20)*0.4
source: "top-shadow.png"
}
}
import QtQuick 2.1
import org.kde.kquickcontrolsaddons 2.0
Rectangle {
id: root
width: 300
height: 500
property real scrollValue: 0
property real cardMargins: 20
property bool scrollingEnabled: true
Behavior on scrollValue {
id: scrollAnim
NumberAnimation {
duration: 150
}
}
Behavior on cardMargins {
PropertyAnimation {
duration: 500
}
}
Text {
anchors.centerIn: parent
text: "Settings stuff"
font.pointSize: 20
}
MouseEventListener {
anchors.fill: parent
property real oldY: 0
onPressed: {
scrollAnim.enabled = false;
oldY = mouse.y
}
onPositionChanged: {
if (!root.scrollingEnabled) {
return;
}
scrollValue += (mouse.y - oldY)
oldY = mouse.y
}
onReleased: {
scrollAnim.enabled = true;
scrollValue = Math.round(scrollValue / root.height) * root.height
}
Card {
step: 0
color: "red"
Text {
anchors.centerIn: parent
text: "13:37"
font.pointSize: 40
}
}
Card {
id: appCard
step: 1
color: "green"
property bool switching: true
onSwitchingChanged: {
if (switching) {
root.cardMargins = 20
} else {
root.cardMargins = 0
}
}
onCurrentChanged: {
if (!current) {
switching = true;
}
}
Item {
width: parent.width
height: parent.height
scale: !appCard.current || appCard.switching ? 0.4 : 1
y: appCard.switching ? -70 : 0
Behavior on scale {
PropertyAnimation {
duration: 150
}
}
Behavior on y {
PropertyAnimation {
duration: 150
}
}
Rectangle {
z: 2
anchors.top: parent.top
width: parent.width
height: parent.height
Text {
anchors.centerIn: parent
text: "APP"
font.pointSize: 40
}
MouseArea {
anchors.fill: parent
onClicked: appCard.switching = false
}
}
}
ListView {
orientation: ListView.Horizontal
spacing: 4
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
}
height: parent.height/2.5
model: 4
delegate: Rectangle {
height: parent.height
width: height / (root.height/root.width)
}
}
}
Card {
id: appsCard
step: 2
color: "blue"
GridView {
id: grid
clip: true
anchors.fill: parent
model: 50
onAtYBeginningChanged: {
root.scrollingEnabled = atYBeginning || !appsCard.current;
}
delegate: Item {
width: grid.cellWidth
height: grid.cellHeight
Rectangle {
anchors.centerIn: parent
width: 48
height: 48
}
}
}
}
}
}
\ No newline at end of file
import QtQuick 2.1
Rectangle {
id: cardRoot
color: "red"
width: root.width
height: root.height
y: Math.max(Math.min((height - root.cardMargins * (parent.children.length - step)), (-root.contentY + height * step)),
root.cardMargins*step)
property int step: 0
property bool current: -root.contentY + cardRoot.height * step == 0
Image {
anchors {
left: parent.left
right: parent.right
bottom: parent.top
}
opacity: (root.cardMargins/20)*0.4
source: "top-shadow.png"
}
}
import QtQuick 2.1
import org.kde.kquickcontrolsaddons 2.0
Flickable {
id: root
width: 300
height: 500
contentWidth: width
contentHeight: mainColumn.height
property real cardMargins: 20
onMovementEnded: {
if (contentY > root.height * 3) {
return;
}
slideAnim.enabled = true;
contentY = Math.round(contentY/root.height) * root.height
}
Behavior on contentY {
id: slideAnim
enabled: false
SequentialAnimation {
PropertyAnimation {
duration: 150
}
ScriptAction {
script: slideAnim.enabled = false;
}
}
}
Behavior on cardMargins {
PropertyAnimation {
duration: 500
}
}
Item {
id: mainColumn
width: root.width
height: root.height * cardHolder.children.length
Item {
id: cardHolder
y: root.contentY
width: root.width
height: root.height
Card {
step: 0
Text {
anchors.centerIn: parent
text: "Settings stuff"
font.pointSize: 20
}
}
Card {
step: 1
color: "blue"
Text {
anchors.centerIn: parent
text: "13:37"
font.pointSize: 40
}
}
Card {
step: 2
id: tasksCard
color: "green"
property bool switching: true
onCurrentChanged: {
if (!current) {
switching = true;
}
}
onSwitchingChanged: {
if (switching) {
root.cardMargins = 20;
} else {
root.cardMargins = 0;
}
}
Item {
scale: tasksCard.switching ? 0.333 : 1
anchors.fill: parent
ListView {
orientation: ListView.Horizontal
anchors {
fill: parent
leftMargin: -root.width
rightMargin: -root.width
}
model: 8
spacing: 4
delegate: Rectangle {
width: root.width
height: root.height
Text {
anchors.centerIn: parent
text: "App " + (modelData+1)
font.pointSize: 40
}
MouseArea {
anchors.fill: parent
onClicked: tasksCard.switching = false;
}
}
}
Behavior on scale {
PropertyAnimation {
duration: 150
}
}
}
}
Card {
step: 3
Flow {
id: appsFlow
anchors.horizontalCenter: parent.horizontalCenter
width: Math.floor(parent.width/64) * 64
Repeater {
model: 40
delegate: Item {
width: 64
height: 64
Rectangle {
width: 48
height: 48
anchors.centerIn: parent
}
}
}
}
}
}
}
}
\ No newline at end of file
import QtQuick 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
Rectangle {
id: root
width: 300
height: 500
property Item currentApp
state: "switcher"
Text {
anchors.centerIn: parent
text: "Homescreen"
}
Rectangle {
anchors.fill: parent
color: "black"
opacity: 0.6 * Math.min(1, mainFlickable.contentY/(root.height*2))
}
Flickable {
id: mainFlickable
//Scale adjusted in the 0-1 range
property real zoomFactor: Math.max(mainFlickable.scale/0.5, 1) - 1
width: root.width * 2 + 5
height: root.height * 2 + 5
scale: 0.5
contentWidth: width
contentHeight: mainContent.height
Behavior on scale {
NumberAnimation {
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}
onMovingChanged: {
if (!moving && contentY < root.height * 2) {
root.state = "dragging";
}
if (contentY < root.height) {
root.state = "homescreen"
} else {
root.state = "switcher"
}
}
Item {
id: mainContent
width: parent.width
height: flow.y + flow.height + root.height
Flow {
id: flow
anchors {
left: parent.left
right: parent.right
}
y: root.height*2
spacing: 5
Repeater {
model: 5
delegate: Rectangle {
id: appRect
color: "red"
width: root.width
height: root.height
MouseArea {
anchors.fill: parent
onClicked: {
root.state = "scrolling"
root.currentApp = appRect
root.state = "app"
}
Text {
anchors.centerIn: parent
text: "App " + modelData
}
}
}
}
}
}
}
Rectangle {
id: bottomBar
z: 99
color: "blue"
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
}
height: 50
MouseArea {
anchors.fill: parent
property int oldY
property real startY
onClicked: {
root.state = "switcher"
}
onPressed: {
if (root.state == "app") {
root.state = "zooming";
} else {
root.state = "dragging";
}
oldY = mouse.y;
startY = mouse.y;
}
onPositionChanged: {
if (root.state == "app" || root.state == "zooming") {
mainFlickable.scale = (1 - (startY - mouse.y) / root.height);
} else {
mainFlickable.contentY += oldY - mouse.y;
}
oldY = mouse.y;
}
onReleased: {
if (root.state == "app" || root.state == "zooming") {
if (mainFlickable.scale < 0.7) {
root.state = "switcher"
} else {
root.state = "app"
}
} else {
if (mainFlickable.contentY < root.height) {
root.state = "homescreen"
} else {
root.state = "switcher"
}
}
}
Row {
PlasmaComponents.ToolButton {
height: bottomBar.height
width: height
iconSource: "applications-other"
onClicked: root.state = "switcher"
}
PlasmaComponents.ToolButton {
height: bottomBar.height
width: height
iconSource: "go-home"
onClicked: root.state = "homescreen"
}
}
}
}
states: [
State {
name: "switcher"
PropertyChanges {
target: mainFlickable
scale: 0.5
x: -root.width / 2
y: -root.height / 2
interactive: true
contentY: root.height*2 + (root.currentApp ? root.currentApp.y : 0)
visible: true
}
},
State {
name: "dragging"
PropertyChanges {
target: mainFlickable
scale: 0.5
x: -root.width / 2
y: -root.height / 2
interactive: true
contentY: contentY
visible: true
}
},
State {
name: "zooming"
PropertyChanges {
target: mainFlickable
scale: scale
x: (-root.currentApp.x * mainFlickable.zoomFactor ) + (1 - mainFlickable.zoomFactor) * (-root.width / 2)
y: (-root.height / 2) * (1 - mainFlickable.zoomFactor)
interactive: true
contentY: (root.height*2 + (root.currentApp ? root.currentApp.y : 0)) * (1 - mainFlickable.zoomFactor) + (root.height*2 + root.currentApp.y) * mainFlickable.zoomFactor
visible: true
}
},
State {
name: "app"
PropertyChanges {
target: mainFlickable
scale: 1
x: -root.currentApp.x
y: 0
interactive: false
contentY: root.height*2 + root.currentApp.y
visible: true
}
},
State {
name: "homescreen"
PropertyChanges {
target: mainFlickable
scale: 0.5
x: -root.width / 2
y: -root.height / 2
interactive: true
contentY: 0
visible: true
}
}
]
transitions: [
Transition {
to: "dragging"
ScriptAction {
script: {
root.currentApp = null;
}
}
},
Transition {
to: "zooming"
},
Transition {
SequentialAnimation {
ScriptAction {
script: {
if (root.state != "homescreen") {
mainFlickable.visible = true;
}
}
}
PropertyAnimation {
target: mainFlickable
duration: units.longDuration
easing.type: Easing.InOutQuad
properties: "x,y,scale,contentY"
}
ScriptAction {
script: {
if (root.state == "homescreen") {
mainFlickable.visible = false;
root.currentApp = null;
}
}
}
}
}
]
}
\ No newline at end of file
import QtQuick 2.1
Rectangle {
id: cardRoot
color: "red"
width: root.width
height: root.height
property int step: 0
property bool current: root.contentY == y
}
import QtQuick 2.1
import org.kde.kquickcontrolsaddons 2.0