Commit e21d716d authored by Aleksi Suomalainen's avatar Aleksi Suomalainen

Merge pull request #12 from locusf/new_lockscreen

New lockscreen
parents 42a75b4d 9e3e2fb5
......@@ -9,31 +9,9 @@ Image {
* the lockscreen is "down" (obscures the view) and 1 means the
* lockscreen is "up" (not visible).
**/
property real openingState: y / -height
visible: openingState < 1
onHeightChanged: {
if (mouseArea.fingerDown)
return // we'll fix this up on touch release via the animations
if (snapOpenAnimation.running)
snapOpenAnimation.to = -height
else if (!snapClosedAnimation.running && !LipstickSettings.lockscreenVisible)
y = -height
}
visible: LipstickSettings.lockscreenVisible
function snapPosition() {
if (LipstickSettings.lockscreenVisible) {
snapOpenAnimation.stop()
snapClosedAnimation.start()
} else {
snapClosedAnimation.stop()
snapOpenAnimation.start()
}
}
function cancelSnap() {
snapClosedAnimation.stop()
snapOpenAnimation.stop()
}
Connections {
......@@ -41,60 +19,6 @@ Image {
onLockscreenVisibleChanged: snapPosition()
}
PropertyAnimation {
id: snapClosedAnimation
target: lockScreen
property: "y"
to: 0
easing.type: Easing.OutBounce
duration: 400
}
PropertyAnimation {
id: snapOpenAnimation
target: lockScreen
property: "y"
to: -height
easing.type: Easing.OutExpo
duration: 400
}
MouseArea {
id: mouseArea
property int pressY: 0
property bool fingerDown
property bool ignoreEvents
anchors.fill: parent
onPressed: {
fingerDown = true
cancelSnap()
pressY = mouseY
}
onPositionChanged: {
var delta = pressY - mouseY
pressY = mouseY + delta
if (parent.y - delta > 0)
return
parent.y = parent.y - delta
}
function snapBack() {
fingerDown = false
if (!LipstickSettings.lockscreenVisible || Math.abs(parent.y) > parent.height / 3) {
LipstickSettings.lockscreenVisible = false
} else if (LipstickSettings.lockscreenVisible) {
LipstickSettings.lockscreenVisible = true
}
lockScreen.snapPosition()
}
onCanceled: snapBack()
onReleased: snapBack()
}
LockscreenClock {
anchors {
top: parent.top
......
......@@ -54,7 +54,7 @@ Page {
defaultValue: "images/graphics-wallpaper-home.jpg"
}
id: desktop
property alias lockscreen: lockScreen
// Implements back key navigation
Keys.onReleased: {
if (event.key === Qt.Key_Back) {
......@@ -131,9 +131,6 @@ Page {
Pager {
id: pager
scale: 0.7 + 0.3 * lockScreen.openingState
opacity: lockScreen.openingState
anchors.fill: parent
model: VisualItemModel {
......@@ -162,20 +159,6 @@ Page {
width: parent.width
height: parent.height
z: 200
onOpeningStateChanged: {
// When fully closed, reset the current page
if (openingState !== 0)
return
// Focus the switcher if any applications are running, otherwise the launcher
if (switcher.runningAppsCount > 0) {
pager.currentIndex = 2
} else {
pager.currentIndex = 1
}
}
}
}
......@@ -122,11 +122,17 @@ Compositor {
property real swipeThreshold: 0.15
property real lockThreshold: 0.25
onGestureStarted: {
swipeAnimation.stop()
cancelAnimation.stop()
state = "swipe"
lockAnimation.stop()
if (root.appActive) {
state = "swipe"
} else if (root.homeActive) {
state = "lock"
}
}
onGestureFinished: {
......@@ -141,13 +147,19 @@ Compositor {
cancelAnimation.start()
}
} else if (root.homeActive){
if (gestureArea.progress >= swipeThreshold) {
if (gestureArea.progress >= lockThreshold) {
lockAnimation.valueTo = (gestureArea.gesture == "left" ?
Desktop.instance.lockscreen.width :
-Desktop.instance.lockscreen.width)
lockAnimation.start()
// Locks or unlocks depending if the screen is locked.
if (!Desktop.instance.lockscreenVisible()) {
Desktop.instance.setLockScreen(true)
} else {
Desktop.instance.setLockScreen(false)
}
} else {
cancelAnimation.start()
}
}
}
......@@ -166,7 +178,30 @@ Compositor {
x: gestureArea.horizontal ? gestureArea.value : 0
y: gestureArea.horizontal ? 0 : gestureArea.value
}
},
State {
name: "lock"
PropertyChanges {
target: Desktop.instance.lockscreen
visible: true
}
PropertyChanges {
target: gestureArea
delayReset: true
}
PropertyChanges {
target: Desktop.instance.lockscreen
x: gestureArea.horizontal ? (Desktop.instance.lockscreenVisible()?(gestureArea.value):
(gestureArea.gesture == "right" ?
-Desktop.instance.lockscreen.width+Math.abs(gestureArea.value) :
Desktop.instance.lockscreen.width+gestureArea.value) ) : 0
y: gestureArea.horizontal ? 0 : (Desktop.instance.lockscreenVisible()?(gestureArea.value):
(gestureArea.gesture == "down" ?
-Desktop.instance.lockscreen.height+Math.abs(gestureArea.value) :
Desktop.instance.lockscreen.height+gestureArea.value) )
}
}
]
SequentialAnimation {
......@@ -187,6 +222,28 @@ Compositor {
}
}
SequentialAnimation {
id: lockAnimation
property alias valueTo: valueAnimationLock.to
SmoothedAnimation {
id: valueAnimationLock
target: Desktop.instance.lockscreen
property: "x"
easing.type: Easing.OutQuint
}
ScriptAction {
script: Desktop.instance.setLockScreen(Desktop.instance.lockscreenVisible())
}
PropertyAction {
target: gestureArea
property: "state"
value: ""
}
}
SequentialAnimation {
id: swipeAnimation
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment