Commit 05dfe712 authored by m2ko's avatar m2ko Committed by eekkelund

broken lockscreen

parent 3eb6ebd9
...@@ -27,6 +27,7 @@ BuildRequires: pkgconfig(Qt5Core) ...@@ -27,6 +27,7 @@ BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5Quick) BuildRequires: pkgconfig(Qt5Quick)
BuildRequires: pkgconfig(lipstick-qt5) >= 0.12.0 BuildRequires: pkgconfig(lipstick-qt5) >= 0.12.0
BuildRequires: pkgconfig(Qt5Compositor) BuildRequires: pkgconfig(Qt5Compositor)
BuildRequires: pkgconfig(nemodevicelock)
Provides: lipstick-colorful-home-qt5 Provides: lipstick-colorful-home-qt5
......
#include "glacierauthenticationinput.h"
/*GlacierAuthenticationInput::GlacierAuthenticationInput()
{
}
*/
#ifndef GLACIERAUTHENTICATIONINPUT_H
#define GLACIERAUTHENTICATIONINPUT_H
#include <nemo-devicelock/authenticationinput.h>
class GlacierAuthenticationInput: public NemoDeviceLock::AuthenticationInput
{
Q_OBJECT
public:
explicit GlacierAuthenticationInput(QObject *parent = nullptr)
: NemoDeviceLock::AuthenticationInput(DeviceLock, parent)
{
}
};
#endif // GLACIERAUTHENTICATIONINPUT_H
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include <QQmlContext> #include <QQmlContext>
#include "glacierwindowmodel.h" #include "glacierwindowmodel.h"
#include <QScreen> #include <QScreen>
#include "glacierauthenticationinput.h"
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
...@@ -60,6 +62,7 @@ int main(int argc, char **argv) ...@@ -60,6 +62,7 @@ int main(int argc, char **argv)
nativeOrientation = app.primaryScreen()->primaryOrientation(); nativeOrientation = app.primaryScreen()->primaryOrientation();
app.engine()->rootContext()->setContextProperty("nativeOrientation", nativeOrientation); app.engine()->rootContext()->setContextProperty("nativeOrientation", nativeOrientation);
qmlRegisterType<GlacierWindowModel>("org.nemomobile.glacier", 1, 0 ,"GlacierWindowModel"); qmlRegisterType<GlacierWindowModel>("org.nemomobile.glacier", 1, 0 ,"GlacierWindowModel");
qmlRegisterType<GlacierAuthenticationInput>("org.nemomobile.glacierauthentication", 1, 0, "GlacierAuthenticationInput");
app.setQmlPath("/usr/share/lipstick-glacier-home-qt5/qml/MainScreen.qml"); app.setQmlPath("/usr/share/lipstick-glacier-home-qt5/qml/MainScreen.qml");
// Give these to the environment inside the lipstick homescreen // Give these to the environment inside the lipstick homescreen
// Fixes a bug where some applications wouldn't launch, eg. terminal or browser // Fixes a bug where some applications wouldn't launch, eg. terminal or browser
......
...@@ -4,6 +4,7 @@ import QtQuick.Controls.Nemo 1.0 ...@@ -4,6 +4,7 @@ import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0 import QtQuick.Controls.Styles.Nemo 1.0
import QtQuick.Layouts 1.0 import QtQuick.Layouts 1.0
import org.nemomobile.glacierauthentication 1.0
import org.nemomobile.lipstick 0.1 import org.nemomobile.lipstick 0.1
import org.nemomobile.devicelock 1.0 import org.nemomobile.devicelock 1.0
...@@ -12,50 +13,51 @@ import "scripts/desktop.js" as Desktop ...@@ -12,50 +13,51 @@ import "scripts/desktop.js" as Desktop
Item { Item {
id: root id: root
property bool shouldAuthenticate: Lipstick.compositor.visible property bool shouldAuthenticate: Lipstick.compositor.visible //&& asd.availableMethods !== 0
&& authenticator.availableMethods !== 0
property int remainingAttempts property int remainingAttempts
property AuthenticationInput authenticationInput
signal codeEntered(string code)
onShouldAuthenticateChanged: { onShouldAuthenticateChanged: {
if (shouldAuthenticate) { if (shouldAuthenticate) {
DeviceLock.authorization.requestChallenge() //console.log("Requesting security code "+ authenticationInput.status)
//authenticationInput.requestSecurityCode()
//DeviceLock.authorization.requestChallenge()
} else { } else {
authenticator.cancel() //authenticator.cancel()
DeviceLock.authorization.relinquishChallenge() //DeviceLock.authorization.relinquishChallenge()
} }
} }
Component.onCompleted: { /*Component.onCompleted: {
DeviceLock.authorization.requestChallenge() console.log("Requesting security code "+ authenticationInput.Status)
} authenticationInput.requestSecurityCode()
}*/
Connections { /*Connections {
target: DeviceLock.authorization target: DeviceLock.authorization
onChallengeIssued: { onChallengeIssued: {
authenticator.authenticate( authenticator.authenticate(
DeviceLock.authorization.challengeCode, DeviceLock.authorization.challengeCode,
DeviceLock.authorization.allowedMethods) DeviceLock.authorization.allowedMethods)
} }
} }*/
Authenticator { Authenticator {
id: authenticator id: auth
onAuthenticated: { Component.onCompleted: {
DeviceLock.unlock(authenticationToken) console.log("Requesting challenge")
Desktop.instance.setLockScreen(false) Authorization.requestChallege()
Desktop.instance.codepadVisible = false
remainingAttempts = 0
} }
onFeedback: {
console.log('### still locked', feedback, attemptsRemaining) onAuthenticated: {
remainingAttempts = attemptsRemaining console.log("Authenticated: "+DeviceLock.state)
animation.start()
} }
} }
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
spacing: Theme.itemSpacingExtraSmall spacing: Theme.itemSpacingLarge
SequentialAnimation { SequentialAnimation {
id: animation; id: animation;
...@@ -91,18 +93,29 @@ Item { ...@@ -91,18 +93,29 @@ Item {
delegate: delegate:
Button { Button {
id:button id:button
opacity: 1
Layout.maximumWidth: Theme.itemWidthSmall Layout.maximumWidth: Theme.itemWidthSmall
Layout.maximumHeight: Theme.itemHeightHuge * 2 Layout.maximumHeight: Theme.itemHeightHuge * 2
Layout.minimumHeight: Theme.itemHeightHuge * 1.5 Layout.minimumHeight: Theme.itemHeightHuge * 1.5
Text {
id: numLabel
text: modelData text: modelData
font.pixelSize: Theme.fontSizeLarge
anchors.centerIn: parent
color: "white"
}
onClicked: { onClicked: {
if (button.text !== "Ca" && button.text !== "OK") { if (numLabel.text !== "Ca" && numLabel.text !== "OK") {
lockCodeField.insert(lockCodeField.cursorPosition, button.text) //console.log(authenticationInput.Status)
lockCodeField.insert(lockCodeField.cursorPosition, numLabel.text)
} else { } else {
if (button.text === "OK") { if (numLabel.text === "OK") {
authenticator.enterLockCode(lockCodeField.text) console.log("DeviceLockUI: "+auth.availableMethods)
auth.authenticate(Authorization.challengeCode, auth.availableMethods)
//authenticationInput.enterSecurityCode(lockCodeField.text)
//codeEntered(lockCodeField.text)
lockCodeField.text = "" lockCodeField.text = ""
} else if (button.text === "Ca"){ } else if (numLabel.text === "Ca"){
lockCodeField.text = "" lockCodeField.text = ""
} }
} }
...@@ -111,4 +124,18 @@ Item { ...@@ -111,4 +124,18 @@ Item {
} }
} }
} }
function displayFeedback(feedback, data) {
console.log("DisplayFeedBack "+feedback+" "+data)
}
function displayError(error) {
console.log("displayError "+error)
}
Connections {
target: root.authenticationInput
onFeedback: root.displayFeedback(feedback, data)
onError: root.displayError(error)
}
} }
...@@ -3,6 +3,7 @@ import QtQuick 2.6 ...@@ -3,6 +3,7 @@ import QtQuick 2.6
import org.nemomobile.lipstick 0.1 import org.nemomobile.lipstick 0.1
import org.nemomobile.devicelock 1.0 import org.nemomobile.devicelock 1.0
import org.nemomobile.configuration 1.0 import org.nemomobile.configuration 1.0
import org.nemomobile.glacierauthentication 1.0
import "notifications" import "notifications"
...@@ -27,15 +28,119 @@ Image { ...@@ -27,15 +28,119 @@ Image {
} }
} }
// Swipes on the lockscreen
MouseArea { MouseArea {
id:mouseArea id:mouseArea
property bool gestureStarted: false
property string gesture: ""
property int startX
property int threshold: Theme.itemHeightHuge * 2
property int swipeDistance
property string action: ""
anchors.fill: parent anchors.fill: parent
onPressed: {
startX = mouseX;
}
onMouseXChanged: {
// Checks which swipe
if(mouseX > (startX+threshold)) {
gesture = "right"
gestureStarted = true;
}
else if(mouseX < (startX+threshold)) {
gesture = "left"
gestureStarted = true;
}
// Makes codepad follow the swipe
if(codePad.inView) {
if(gesture == "right") {
swipeDistance = mouseX - startX
codePad.x = swipeDistance
}
if(gesture == "left") {
swipeDistance = startX - mouseX
codePad.x = -swipeDistance
}
}else {
if(gesture == "right") {
swipeDistance = mouseX - startX
codePad.x = swipeDistance - parent.width
}
else if(gesture == "left") {
swipeDistance = startX - mouseX
codePad.x = parent.width - swipeDistance
}
}
}
// Animation to sna codepad into view or out of view
onReleased: {
if(codePad.inView) {
if(gesture == "right") {
if(swipeDistance > threshold) {
startCodePadAnimation(parent.width)
codePad.inView = false
}else {
startCodePadAnimation(0)
codePad.inView = true
}
}else if(gesture == "left") {
if(swipeDistance > threshold) {
startCodePadAnimation(-parent.width)
codePad.inView = false
}else {
startCodePadAnimation(0)
codePad.inView = true
}
}
}else {
if(swipeDistance > threshold) {
startCodePadAnimation(0)
codePad.inView = true
}else {
if(gesture == "right") {
startCodePadAnimation(-parent.width)
codePad.inView = false
}
else {
startCodePadAnimation(parent.width)
codePad.inView = false
}
}
}
gestureStarted = false
}
function startCodePadAnimation(value) {
snapCodePadAnimation.valueTo = value
snapCodePadAnimation.start()
}
}
SequentialAnimation {
id: snapCodePadAnimation
property alias valueTo: codePadAnimation.to
NumberAnimation {
id: codePadAnimation
target: codePad
property: "x"
duration: 200
easing.type: Easing.OutQuint
}
} }
Connections { Connections {
target:Lipstick.compositor target:Lipstick.compositor
onDisplayOff: { onDisplayOff: {
displayOn = false displayOn = false
displayOffTimer.stop() displayOffTimer.stop()
codePad.x = -parent.width
codePad.inView = false
} }
onDisplayOn:{ onDisplayOn:{
displayOn = true displayOn = true
...@@ -66,7 +171,56 @@ Image { ...@@ -66,7 +171,56 @@ Image {
} }
} }
} }
DeviceLockUI {
id: codePad
property bool inView: false
property bool gestureStarted: mouseArea.gestureStarted
x: 1000
visible: DeviceLock.state == DeviceLock.Locked && lockscreenVisible()
width: lockScreen.width
height: lockScreen.height / 2
onCodeEntered: {
//authenticationInput.enterSecurityCode(code)
console.log("Security code entered: "+authenticationInput.minimumCodeLength)
}
authenticationInput: GlacierAuthenticationInput {
property bool unlocked: DeviceLock.state >= DeviceLock.Locked
registered: true
//active: lockscreenVisible()
onUnlockedChanged: console.log("Unlock")
onStatusChanged: {
console.log("Status changed")
}
onAuthenticationUnavailable: {
console.log("Authentication unavailable: "+error)
}
onFeedback: {
console.log("Feedback: "+feedback)
}
onAuthenticationStarted: {
console.log("Authentication started")
}
onAuthenticationEnded: {
console.log("Ended "+confirmed)
}
}
anchors {
verticalCenter: lockScreen.verticalCenter
}
onGestureStartedChanged: {
if(gestureStarted) {
mouseArea.z = 2
}else {
mouseArea.z = 0
}
}
}
ListView { ListView {
id: notificationColumn id: notificationColumn
opacity: codePad.visible ? 1 - codePad.opacity : 1 opacity: codePad.visible ? 1 - codePad.opacity : 1
......
...@@ -66,9 +66,10 @@ Page { ...@@ -66,9 +66,10 @@ Page {
id: desktop id: desktop
property alias lockscreen: lockScreen property alias lockscreen: lockScreen
property alias switcher: switcher property alias switcher: switcher
property alias codepad: codePad //property alias codepad: codePad
property int statusBarHeight: statusbar.height property int statusBarHeight: statusbar.height
property bool codepadVisible: false property bool codepadVisible: false
property bool deviceLocked: DeviceLock.state >= DeviceLock.Locked
// Implements back key navigation // Implements back key navigation
...@@ -80,7 +81,6 @@ Page { ...@@ -80,7 +81,6 @@ Page {
} else { Qt.quit(); } } else { Qt.quit(); }
} }
} }
Statusbar { Statusbar {
id: statusbar id: statusbar
enabled: DeviceLock.state !== DeviceLock.Locked enabled: DeviceLock.state !== DeviceLock.Locked
...@@ -165,7 +165,7 @@ Page { ...@@ -165,7 +165,7 @@ Page {
} }
Lockscreen { Lockscreen {
id: lockScreen id: lockScreen
visible: lockscreenVisible()//DeviceLock.state == DeviceLock.Locked visible: lockscreenVisible()
width: parent.width width: parent.width
height: parent.height height: parent.height
z: 200 z: 200
......
...@@ -137,7 +137,7 @@ Compositor { ...@@ -137,7 +137,7 @@ Compositor {
property real lockThreshold: 0.25 property real lockThreshold: 0.25
property int lockscreenX property int lockscreenX
property int lockscreenY property int lockscreenY
enabled: true//!Desktop.instance.codepadVisible//DeviceLock.state != DeviceLock.Locked enabled: DeviceLock.state != DeviceLock.Locked
onGestureStarted: { onGestureStarted: {
swipeAnimation.stop() swipeAnimation.stop()
...@@ -148,13 +148,13 @@ Compositor { ...@@ -148,13 +148,13 @@ Compositor {
state = "swipe" state = "swipe"
} }
else if (!root.appActive && DeviceLock.state !== DeviceLock.Locked) { else if (!root.appActive && DeviceLock.state !== DeviceLock.Locked) {
state = "lock" state = "cover"
} }
else if (Desktop.instance.lockscreenVisible() && DeviceLock.state === DeviceLock.Locked && !Desktop.instance.codepadVisible) { else if (Desktop.instance.lockscreenVisible() && DeviceLock.state === DeviceLock.Locked && !Desktop.instance.codepadVisible) {
state = "pullCodepad" //state = "pullCodepad"
} }
else if (Desktop.instance.lockscreenVisible() && DeviceLock.state === DeviceLock.Locked && Desktop.instance.codepadVisible) { else if (Desktop.instance.lockscreenVisible() && DeviceLock.state === DeviceLock.Locked && Desktop.instance.codepadVisible) {
state = "pushCodepad" //state = "pushCodepad"
} }
} }
...@@ -182,7 +182,7 @@ Compositor { ...@@ -182,7 +182,7 @@ Compositor {
if(gesture == "down") { if(gesture == "down") {
setDisplayOff() setDisplayOff()
} }
} }/*
// Brings up codepad, only left and right swipes allowed for it for now // Brings up codepad, only left and right swipes allowed for it for now
else if (Desktop.instance.lockscreenVisible() && !Desktop.instance.codepad.visible && DeviceLock.state == DeviceLock.Locked && (gesture !== "down" && gesture !== "up")) { else if (Desktop.instance.lockscreenVisible() && !Desktop.instance.codepad.visible && DeviceLock.state == DeviceLock.Locked && (gesture !== "down" && gesture !== "up")) {
Desktop.instance.codepadVisible = true Desktop.instance.codepadVisible = true
...@@ -190,7 +190,7 @@ Compositor { ...@@ -190,7 +190,7 @@ Compositor {
// Hides codepad but does not unlock the code, only left and right swipes allowed for now // Hides codepad but does not unlock the code, only left and right swipes allowed for now
else if (Desktop.instance.lockscreenVisible() && Desktop.instance.codepad.visible && DeviceLock.state == DeviceLock.Locked && gesture !== "down" && gesture !== "up") { else if (Desktop.instance.lockscreenVisible() && Desktop.instance.codepad.visible && DeviceLock.state == DeviceLock.Locked && gesture !== "down" && gesture !== "up") {
Desktop.instance.codepadVisible = false Desktop.instance.codepadVisible = false
} }*/
// Unlocks if no security code required // Unlocks if no security code required
else if (DeviceLock.state !== DeviceLock.Locked && Desktop.instance.lockscreenVisible()) { else if (DeviceLock.state !== DeviceLock.Locked && Desktop.instance.lockscreenVisible()) {
Desktop.instance.setLockScreen(false) Desktop.instance.setLockScreen(false)
...@@ -218,9 +218,9 @@ Compositor { ...@@ -218,9 +218,9 @@ Compositor {
y: gestureArea.horizontal ? 0 : gestureArea.value y: gestureArea.horizontal ? 0 : gestureArea.value
} }
}, },
// Lock state is for when screen is locked but no security code required, can be swiped from any edge // Cover state is for when screen is covered but no security code required, can be swiped from any edge
State { State {
name: "lock" name: "cover"
when: Desktop.instance.lockscreenVisible() when: Desktop.instance.lockscreenVisible()
PropertyChanges { PropertyChanges {
target: Desktop.instance.lockscreen target: Desktop.instance.lockscreen
...@@ -249,11 +249,11 @@ Compositor { ...@@ -249,11 +249,11 @@ Compositor {
Desktop.instance.lockscreen.height : Desktop.instance.lockscreen.height :
Desktop.instance.lockscreen.width)+gestureArea.value) ) ) Desktop.instance.lockscreen.width)+gestureArea.value) ) )
} }
}, }/*
// pullCodepad is when you are pulling codepad into view to enter security code // pullCodepad is when you are pulling codepad into view to enter security code
State { State {
name: "pullCodepad" name: "pullCodepad"
when: Desktop.instance.codepadVisible when: DeviceLock.state >= DeviceLock.Locked//Desktop.instance.codepadVisible
PropertyChanges { PropertyChanges {
target: Desktop.instance target: Desktop.instance
codepadVisible: true codepadVisible: true
...@@ -306,7 +306,7 @@ Compositor { ...@@ -306,7 +306,7 @@ Compositor {
opacity: 1 - (gestureArea.horizontal ? (gestureArea.value < 0 ? (gestureArea.value / -Desktop.instance.lockscreen.width) : opacity: 1 - (gestureArea.horizontal ? (gestureArea.value < 0 ? (gestureArea.value / -Desktop.instance.lockscreen.width) :
gestureArea.value / Desktop.instance.lockscreen.width) : 0) gestureArea.value / Desktop.instance.lockscreen.width) : 0)
} }
} }*/
] ]
......
...@@ -99,15 +99,19 @@ CONFIG += qt link_pkgconfig ...@@ -99,15 +99,19 @@ CONFIG += qt link_pkgconfig
QT += quick compositor QT += quick compositor
DEFINES += QT_COMPOSITOR_QUICK DEFINES += QT_COMPOSITOR_QUICK
HEADERS += \ HEADERS += \
glacierwindowmodel.h glacierwindowmodel.h \
glacierauthenticationinput.h
QT += dbus
LIBS += -lnemodevicelock
MOC_DIR = .moc MOC_DIR = .moc
SOURCES += \ SOURCES += \
main.cpp \ main.cpp \
glacierwindowmodel.cpp glacierwindowmodel.cpp \
glacierauthenticationinput.cpp
PKGCONFIG += lipstick-qt5 PKGCONFIG += lipstick-qt5 \
nemodevicelock
OTHER_FILES += qml/*.qml \ OTHER_FILES += qml/*.qml \
qml/MainScreen.qml \ qml/MainScreen.qml \
......
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