Skip to content

Commit

Permalink
[lock] Lock/unlock the screen from anywhere in the homescreen. Also k…
Browse files Browse the repository at this point in the history
…ill application by dragging it down.
  • Loading branch information
locusf committed Apr 23, 2014
1 parent 3b6707c commit 0a07786
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 13 deletions.
15 changes: 15 additions & 0 deletions src/qml/MainScreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import QtQuick.Window 2.1
import org.nemomobile.time 1.0
import org.nemomobile.configuration 1.0
import org.freedesktop.contextkit 1.0
import "scripts/desktop.js" as Desktop

Page {

Expand Down Expand Up @@ -112,6 +113,20 @@ Page {
font.pointSize: 8
}
}
Component.onCompleted: {
Desktop.instance = desktop
}
function lockscreenVisible() {
return LipstickSettings.lockscreenVisible === true
}
function lockScreen(enabled) {
if (enabled) {
LipstickSettings.lockScreen(true)
} else {
LipstickSettings.lockscreenVisible = false
}

}

Pager {
id: pager
Expand Down
33 changes: 21 additions & 12 deletions src/qml/compositor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import QtQuick 2.0
import org.nemomobile.lipstick 0.1

import "compositor"
import "scripts/desktop.js" as Desktop

Compositor {
id: root
Expand Down Expand Up @@ -118,7 +119,7 @@ Compositor {
id: gestureArea
z: 2
anchors.fill: parent
enabled: root.appActive


property real swipeThreshold: 0.15

Expand All @@ -129,11 +130,25 @@ Compositor {
}

onGestureFinished: {
if (gestureArea.progress >= swipeThreshold) {
swipeAnimation.valueTo = inverted ? -max : max
swipeAnimation.start()
} else {
cancelAnimation.start()
if (root.appActive) {
if (gestureArea.progress >= swipeThreshold) {
swipeAnimation.valueTo = inverted ? -max : max
swipeAnimation.start()
} else {
cancelAnimation.start()
}
if (gestureArea.gesture == "down") {
Lipstick.compositor.closeClientForWindowId(topmostWindow.window.windowId)
}
} else if (root.homeActive){
if (gestureArea.progress >= swipeThreshold) {
// Locks or unlocks depending if the screen is locked.
if (!Desktop.instance.lockscreenVisible()) {
Desktop.instance.lockScreen(true)
} else {
Desktop.instance.lockScreen(false)
}
}
}
}

Expand All @@ -151,12 +166,6 @@ Compositor {
x: gestureArea.horizontal ? gestureArea.value : 0
y: gestureArea.horizontal ? 0 : gestureArea.value
}

PropertyChanges {
target: homeLayer
opacity: 0.6 + 0.4 * gestureArea.progress
scale: 0.8 + 0.2 * gestureArea.progress
}
}
]

Expand Down
3 changes: 3 additions & 0 deletions src/qml/scripts/desktop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.pragma library

var instance
1 change: 1 addition & 0 deletions src/resources-qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
<file>qml/theme/icon-m-framework-close-thumbnail.png</file>
<file>qml/NotificationPreview.qml</file>
<file>qml/images/notification-circle.png</file>
<file>qml/scripts/desktop.js</file>
</qresource>
</RCC>
3 changes: 2 additions & 1 deletion src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ OTHER_FILES += qml/*.qml \
qml/compositor/WindowWrapperBase.qml \
qml/compositor/WindowWrapperAlpha.qml \
qml/compositor/ScreenGestureArea.qml \
qml/NotificationPreview.qml
qml/NotificationPreview.qml \
qml/scripts/desktop.js


0 comments on commit 0a07786

Please sign in to comment.