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

broken lockscreen

parent 3eb6ebd9
......@@ -27,6 +27,7 @@ BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5Quick)
BuildRequires: pkgconfig(lipstick-qt5) >= 0.12.0
BuildRequires: pkgconfig(Qt5Compositor)
BuildRequires: pkgconfig(nemodevicelock)
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 @@
#include <QQmlContext>
#include "glacierwindowmodel.h"
#include <QScreen>
#include "glacierauthenticationinput.h"
int main(int argc, char **argv)
{
......@@ -60,6 +62,7 @@ int main(int argc, char **argv)
nativeOrientation = app.primaryScreen()->primaryOrientation();
app.engine()->rootContext()->setContextProperty("nativeOrientation", nativeOrientation);
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");
// Give these to the environment inside the lipstick homescreen
// Fixes a bug where some applications wouldn't launch, eg. terminal or browser
......
......@@ -4,6 +4,7 @@ import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0
import QtQuick.Layouts 1.0
import org.nemomobile.glacierauthentication 1.0
import org.nemomobile.lipstick 0.1
import org.nemomobile.devicelock 1.0
......@@ -12,50 +13,51 @@ import "scripts/desktop.js" as Desktop
Item {
id: root
property bool shouldAuthenticate: Lipstick.compositor.visible
&& authenticator.availableMethods !== 0
property bool shouldAuthenticate: Lipstick.compositor.visible //&& asd.availableMethods !== 0
property int remainingAttempts
property AuthenticationInput authenticationInput
signal codeEntered(string code)
onShouldAuthenticateChanged: {
if (shouldAuthenticate) {
DeviceLock.authorization.requestChallenge()
//console.log("Requesting security code "+ authenticationInput.status)
//authenticationInput.requestSecurityCode()
//DeviceLock.authorization.requestChallenge()
} else {
authenticator.cancel()
DeviceLock.authorization.relinquishChallenge()
//authenticator.cancel()
//DeviceLock.authorization.relinquishChallenge()
}
}
Component.onCompleted: {
DeviceLock.authorization.requestChallenge()
}
/*Component.onCompleted: {
console.log("Requesting security code "+ authenticationInput.Status)
authenticationInput.requestSecurityCode()
}*/
Connections {
/*Connections {
target: DeviceLock.authorization
onChallengeIssued: {
authenticator.authenticate(
DeviceLock.authorization.challengeCode,
DeviceLock.authorization.allowedMethods)
}
}
}*/
Authenticator {
id: authenticator
onAuthenticated: {
DeviceLock.unlock(authenticationToken)
Desktop.instance.setLockScreen(false)
Desktop.instance.codepadVisible = false
remainingAttempts = 0
id: auth
Component.onCompleted: {
console.log("Requesting challenge")
Authorization.requestChallege()
}
onFeedback: {
console.log('### still locked', feedback, attemptsRemaining)
remainingAttempts = attemptsRemaining
animation.start()
onAuthenticated: {
console.log("Authenticated: "+DeviceLock.state)
}
}
ColumnLayout {
anchors.fill: parent
spacing: Theme.itemSpacingExtraSmall
spacing: Theme.itemSpacingLarge
SequentialAnimation {
id: animation;
......@@ -91,18 +93,29 @@ Item {
delegate:
Button {
id:button
opacity: 1
Layout.maximumWidth: Theme.itemWidthSmall
Layout.maximumHeight: Theme.itemHeightHuge * 2
Layout.minimumHeight: Theme.itemHeightHuge * 1.5
Text {
id: numLabel
text: modelData
font.pixelSize: Theme.fontSizeLarge
anchors.centerIn: parent
color: "white"
}
onClicked: {
if (button.text !== "Ca" && button.text !== "OK") {
lockCodeField.insert(lockCodeField.cursorPosition, button.text)
if (numLabel.text !== "Ca" && numLabel.text !== "OK") {
//console.log(authenticationInput.Status)
lockCodeField.insert(lockCodeField.cursorPosition, numLabel.text)
} else {
if (button.text === "OK") {
authenticator.enterLockCode(lockCodeField.text)
if (numLabel.text === "OK") {
console.log("DeviceLockUI: "+auth.availableMethods)
auth.authenticate(Authorization.challengeCode, auth.availableMethods)
//authenticationInput.enterSecurityCode(lockCodeField.text)
//codeEntered(lockCodeField.text)
lockCodeField.text = ""
} else if (button.text === "Ca"){
} else if (numLabel.text === "Ca"){
lockCodeField.text = ""
}
}
......@@ -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
import org.nemomobile.lipstick 0.1
import org.nemomobile.devicelock 1.0
import org.nemomobile.configuration 1.0
import org.nemomobile.glacierauthentication 1.0
import "notifications"
......@@ -27,15 +28,119 @@ Image {
}
}
// Swipes on the lockscreen
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
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 {
target:Lipstick.compositor
onDisplayOff: {
displayOn = false
displayOffTimer.stop()
codePad.x = -parent.width
codePad.inView = false
}
onDisplayOn:{
displayOn = true
......@@ -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 {
id: notificationColumn
opacity: codePad.visible ? 1 - codePad.opacity : 1
......
......@@ -66,9 +66,10 @@ Page {
id: desktop
property alias lockscreen: lockScreen
property alias switcher: switcher
property alias codepad: codePad
//property alias codepad: codePad
property int statusBarHeight: statusbar.height
property bool codepadVisible: false
property bool deviceLocked: DeviceLock.state >= DeviceLock.Locked
// Implements back key navigation
......@@ -80,7 +81,6 @@ Page {
} else { Qt.quit(); }
}
}
Statusbar {
id: statusbar
enabled: DeviceLock.state !== DeviceLock.Locked
......@@ -165,7 +165,7 @@ Page {
}
Lockscreen {
id: lockScreen
visible: lockscreenVisible()//DeviceLock.state == DeviceLock.Locked
visible: lockscreenVisible()
width: parent.width
height: parent.height
z: 200
......
......@@ -137,7 +137,7 @@ Compositor {
property real lockThreshold: 0.25
property int lockscreenX
property int lockscreenY
enabled: true//!Desktop.instance.codepadVisible//DeviceLock.state != DeviceLock.Locked
enabled: DeviceLock.state != DeviceLock.Locked
onGestureStarted: {
swipeAnimation.stop()
......@@ -148,13 +148,13 @@ Compositor {
state = "swipe"
}
else if (!root.appActive && DeviceLock.state !== DeviceLock.Locked) {
state = "lock"
state = "cover"
}
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) {
state = "pushCodepad"
//state = "pushCodepad"
}
}
......@@ -182,7 +182,7 @@ Compositor {
if(gesture == "down") {
setDisplayOff()
}
}
}/*
// 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")) {
Desktop.instance.codepadVisible = true
......@@ -190,7 +190,7 @@ Compositor {
// 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") {
Desktop.instance.codepadVisible = false
}
}*/
// Unlocks if no security code required
else if (DeviceLock.state !== DeviceLock.Locked && Desktop.instance.lockscreenVisible()) {
Desktop.instance.setLockScreen(false)
......@@ -218,9 +218,9 @@ Compositor {
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 {
name: "lock"
name: "cover"
when: Desktop.instance.lockscreenVisible()
PropertyChanges {
target: Desktop.instance.lockscreen
......@@ -249,11 +249,11 @@ Compositor {
Desktop.instance.lockscreen.height :
Desktop.instance.lockscreen.width)+gestureArea.value) ) )
}
},
}/*
// pullCodepad is when you are pulling codepad into view to enter security code
State {
name: "pullCodepad"
when: Desktop.instance.codepadVisible
when: DeviceLock.state >= DeviceLock.Locked//Desktop.instance.codepadVisible
PropertyChanges {
target: Desktop.instance
codepadVisible: true
......@@ -306,7 +306,7 @@ Compositor {
opacity: 1 - (gestureArea.horizontal ? (gestureArea.value < 0 ? (gestureArea.value / -Desktop.instance.lockscreen.width) :
gestureArea.value / Desktop.instance.lockscreen.width) : 0)
}
}
}*/
]
......
......@@ -99,15 +99,19 @@ CONFIG += qt link_pkgconfig
QT += quick compositor
DEFINES += QT_COMPOSITOR_QUICK
HEADERS += \
glacierwindowmodel.h
glacierwindowmodel.h \
glacierauthenticationinput.h
QT += dbus
LIBS += -lnemodevicelock
MOC_DIR = .moc
SOURCES += \
main.cpp \
glacierwindowmodel.cpp
glacierwindowmodel.cpp \
glacierauthenticationinput.cpp
PKGCONFIG += lipstick-qt5
PKGCONFIG += lipstick-qt5 \
nemodevicelock
OTHER_FILES += qml/*.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