Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
glacier-home
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
NemoMobile
glacier-home
Commits
4622bc51
Unverified
Commit
4622bc51
authored
Feb 22, 2018
by
Aleksi Suomalainen
Committed by
GitHub
Feb 22, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #69 from eekkelund/master
[DeviceLock] Fix #67 and add beautiful sliding gesture to codepad
parents
3eb6ebd9
6ebe08f1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
257 additions
and
132 deletions
+257
-132
lipstick-glacier-home-qt5.spec
rpm/lipstick-glacier-home-qt5.spec
+1
-0
main.cpp
src/main.cpp
+1
-0
DeviceLockUI.qml
src/qml/DeviceLockUI.qml
+63
-49
Lockscreen.qml
src/qml/Lockscreen.qml
+182
-0
MainScreen.qml
src/qml/MainScreen.qml
+2
-3
compositor.qml
src/qml/compositor.qml
+4
-77
src.pro
src/src.pro
+4
-3
No files found.
rpm/lipstick-glacier-home-qt5.spec
View file @
4622bc51
...
...
@@ -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
...
...
src/main.cpp
View file @
4622bc51
...
...
@@ -30,6 +30,7 @@
#include "glacierwindowmodel.h"
#include <QScreen>
int
main
(
int
argc
,
char
**
argv
)
{
HomeApplication
app
(
argc
,
argv
,
QString
());
...
...
src/qml/DeviceLockUI.qml
View file @
4622bc51
...
...
@@ -6,6 +6,7 @@ import QtQuick.Layouts 1.0
import
org
.
nemomobile
.
lipstick
0.1
import
org
.
nemomobile
.
devicelock
1.0
import
org
.
nemomobile
.
dbus
1.0
import
"
scripts/desktop.js
"
as
Desktop
...
...
@@ -13,49 +14,12 @@ Item {
id
:
root
property
bool
shouldAuthenticate
:
Lipstick
.
compositor
.
visible
&&
authenticator
.
availableMethods
!==
0
property
int
remainingAttempts
onShouldAuthenticateChanged
:
{
if
(
shouldAuthenticate
)
{
DeviceLock
.
authorization
.
requestChallenge
()
}
else
{
authenticator
.
cancel
()
DeviceLock
.
authorization
.
relinquishChallenge
()
}
}
Component.onCompleted
:
{
DeviceLock
.
authorization
.
requestChallenge
()
}
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
}
onFeedback
:
{
console
.
log
(
'
### still locked
'
,
feedback
,
attemptsRemaining
)
remainingAttempts
=
attemptsRemaining
animation
.
start
()
}
}
property
AuthenticationInput
authenticationInput
ColumnLayout
{
anchors.fill
:
parent
spacing
:
Theme
.
itemSpacing
ExtraSmall
spacing
:
Theme
.
itemSpacing
Large
SequentialAnimation
{
id
:
animation
;
...
...
@@ -66,14 +30,23 @@ Item {
}
NumberAnimation
{
target
:
codePad
;
property
:
"
anchors.horizontalCenterOffset
"
;
to
:
0
;
duration
:
100
}
}
Label
{
font.pixelSize
:
Theme
.
fontSizeMedium
width
:
parent
.
width
text
:
remainingAttempts
>
0
?
qsTr
(
"
Attempts remaining:
"
)
+
"
"
+
remainingAttempts
:
""
Row
{
anchors.horizontalCenter
:
parent
.
horizontalCenter
width
:
parent
.
width
Label
{
id
:
feedbackLabel
font.pixelSize
:
Theme
.
fontSizeMedium
text
:
"
"
}
Label
{
id
:
attemptsRemainingLabel
font.pixelSize
:
Theme
.
fontSizeMedium
text
:
"
"
}
}
TextField
{
id
:
lockCodeField
anchors.topMargin
:
Theme
.
itemSpacingMedium
anchors.horizontalCenter
:
parent
.
horizontalCenter
readOnly
:
true
echoMode
:
TextInput
.
PasswordEchoOnEdit
...
...
@@ -91,18 +64,28 @@ Item {
delegate
:
Button
{
id
:
button
opacity
:
1
Layout.maximumWidth
:
Theme
.
itemWidthSmall
Layout.maximumHeight
:
Theme
.
itemHeightHuge
*
2
Layout.minimumHeight
:
Theme
.
itemHeightHuge
*
1.5
text
:
modelData
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
)
displayOffTimer
.
restart
()
feedbackLabel
.
text
=
"
"
attemptsRemainingLabel
.
text
=
"
"
if
(
numLabel
.
text
!==
"
Ca
"
&&
numLabel
.
text
!==
"
OK
"
)
{
lockCodeField
.
insert
(
lockCodeField
.
cursorPosition
,
numLabel
.
text
)
}
else
{
if
(
button
.
text
===
"
OK
"
)
{
authenticat
or
.
enterLock
Code
(
lockCodeField
.
text
)
if
(
numLabel
.
text
===
"
OK
"
)
{
authenticat
ionInput
.
enterSecurity
Code
(
lockCodeField
.
text
)
lockCodeField
.
text
=
""
}
else
if
(
button
.
text
===
"
Ca
"
){
}
else
if
(
numLabel
.
text
===
"
Ca
"
){
lockCodeField
.
text
=
""
}
}
...
...
@@ -111,4 +94,35 @@ Item {
}
}
}
function
displayFeedback
(
feedback
,
data
)
{
switch
(
feedback
)
{
case
AuthenticationInput.EnterSecurityCode
:
feedbackLabel
.
text
=
qsTr
(
"
Enter security code
"
)
break
case
AuthenticationInput.IncorrectSecurityCode
:
feedbackLabel
.
text
=
qsTr
(
"
Incorrect code
"
)
if
(
authenticationInput
.
maximumAttempts
!==
-
1
)
{
attemptsRemainingLabel
.
text
=
qsTr
(
"
(
"
+
(
authenticationInput
.
maximumAttempts
-
data
.
attemptsRemaining
)
+
"
/
"
+
authenticationInput
.
maximumAttempts
+
"
)
"
)
}
animation
.
start
()
break
case
AuthenticationInput.TemporarilyLocked
:
feedbackLabel
.
text
=
qsTr
(
"
Temporarily locked
"
)
}
}
function
displayError
(
error
)
{
console
.
log
(
"
displayError
"
+
error
)
}
Connections
{
target
:
root
.
authenticationInput
onFeedback
:
root
.
displayFeedback
(
feedback
,
data
)
onError
:
root
.
displayError
(
error
)
}
}
src/qml/Lockscreen.qml
View file @
4622bc51
...
...
@@ -27,15 +27,139 @@ 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 was it left or right 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 snap codepad into view or out of view
onReleased
:
{
displayOffTimer
.
restart
()
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
}
}
SequentialAnimation
{
id
:
unlockAnimation
property
alias
valueTo
:
unlockNumAnimation
.
to
property
alias
setProperty
:
unlockNumAnimation
.
property
NumberAnimation
{
id
:
unlockNumAnimation
target
:
lockScreen
property
:
"
y
"
to
:
-
height
duration
:
250
easing.type
:
Easing
.
OutQuint
}
onStopped
:
{
setLockScreen
(
false
)
}
}
Connections
{
target
:
Lipstick
.
compositor
onDisplayOff
:
{
displayOn
=
false
displayOffTimer
.
stop
()
codePad
.
x
=
-
parent
.
width
codePad
.
inView
=
false
}
onDisplayOn
:{
displayOn
=
true
...
...
@@ -66,7 +190,65 @@ Image {
}
}
}
DeviceLockUI
{
id
:
codePad
property
bool
inView
:
false
property
bool
gestureStarted
:
mouseArea
.
gestureStarted
x
:
width
*
2
visible
:
DeviceLock
.
state
==
DeviceLock
.
Locked
&&
lockscreenVisible
()
width
:
lockScreen
.
width
height
:
lockScreen
.
height
/
2
opacity
:
(
1
-
Math
.
abs
((
1
-
(
-
1
))
*
(
x
-
(
-
parent
.
width
))
/
(
parent
.
width
-
(
-
parent
.
width
))
+
(
-
1
)))
authenticationInput
:
DeviceLockAuthenticationInput
{
readonly
property
bool
unlocking
:
registered
&&
DeviceLock
.
state
>=
DeviceLock
.
Locked
&&
DeviceLock
.
state
<
DeviceLock
.
Undefined
registered
:
lockscreenVisible
()
active
:
lockscreenVisible
()
onUnlockingChanged
:
{
if
(
unlocking
)
{
DeviceLock
.
unlock
()
}
else
{
DeviceLock
.
cancel
()
}
}
onAuthenticationEnded
:
{
if
(
confirmed
)
{
unlockAnimationHelper
(
mouseArea
.
gesture
)
}
else
{
}
}
function
unlockAnimationHelper
(
gesture
)
{
if
(
gesture
==
"
left
"
)
{
unlockAnimation
.
setProperty
=
"
x
"
unlockAnimation
.
valueTo
=
-
width
unlockAnimation
.
start
()
}
if
(
gesture
==
"
right
"
)
{
unlockAnimation
.
setProperty
=
"
x
"
unlockAnimation
.
valueTo
=
width
unlockAnimation
.
start
()
}
}
}
anchors
{
verticalCenter
:
lockScreen
.
verticalCenter
}
onGestureStartedChanged
:
{
if
(
gestureStarted
)
{
mouseArea
.
z
=
2
}
else
{
mouseArea
.
z
=
0
}
}
}
ListView
{
id
:
notificationColumn
opacity
:
codePad
.
visible
?
1
-
codePad
.
opacity
:
1
...
...
src/qml/MainScreen.qml
View file @
4622bc51
...
...
@@ -66,9 +66,9 @@ Page {
id
:
desktop
property
alias
lockscreen
:
lockScreen
property
alias
switcher
:
switcher
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 +80,6 @@ Page {
}
else
{
Qt
.
quit
();
}
}
}
Statusbar
{
id
:
statusbar
enabled
:
DeviceLock
.
state
!==
DeviceLock
.
Locked
...
...
@@ -165,7 +164,7 @@ Page {
}
Lockscreen
{
id
:
lockScreen
visible
:
lockscreenVisible
()
//DeviceLock.state == DeviceLock.Locked
visible
:
lockscreenVisible
()
width
:
parent
.
width
height
:
parent
.
height
z
:
200
...
...
src/qml/compositor.qml
View file @
4622bc51
...
...
@@ -114,7 +114,6 @@ Compositor {
id
:
overlayLayer
z
:
5
//visible: root.appActive
}
Item
{
...
...
@@ -137,7 +136,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 +147,7 @@ Compositor {
state
=
"
swipe
"
}
else
if
(
!
root
.
appActive
&&
DeviceLock
.
state
!==
DeviceLock
.
Locked
)
{
state
=
"
lock
"
}
else
if
(
Desktop
.
instance
.
lockscreenVisible
()
&&
DeviceLock
.
state
===
DeviceLock
.
Locked
&&
!
Desktop
.
instance
.
codepadVisible
)
{
state
=
"
pullCodepad
"
}
else
if
(
Desktop
.
instance
.
lockscreenVisible
()
&&
DeviceLock
.
state
===
DeviceLock
.
Locked
&&
Desktop
.
instance
.
codepadVisible
)
{
state
=
"
pushCodepad
"
state
=
"
cover
"
}
}
...
...
@@ -183,14 +176,6 @@ Compositor {
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
}
// 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 +203,9 @@ Compositor {
y
:
gestureArea
.
horizontal
?
0
:
gestureArea
.
value
}
},
//
Lock state is for when screen is lock
ed but no security code required, can be swiped from any edge
//
Cover state is for when screen is cover
ed 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,65 +234,7 @@ 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
PropertyChanges
{
target
:
Desktop
.
instance
codepadVisible
:
true
}
PropertyChanges
{
target
:
gestureArea
delayReset
:
true
}
PropertyChanges
{
target
:
Desktop
.
instance
.
codepad
// Confusing logic and math to get the codepad follow your finger
x
:
gestureArea
.
lockscreenX
+
(
gestureArea
.
value
<
0
?
Desktop
.
instance
.
lockscreen
.
width
:
-
Desktop
.
instance
.
lockscreen
.
width
)
+
((
gestureArea
.
horizontal
)
?
(
Desktop
.
instance
.
lockscreenVisible
()?(
gestureArea
.
value
)
:
(
gestureArea
.
gesture
==
"
right
"
?
((
Desktop
.
instance
.
lockscreen
.
width
===
topmostWindow
.
width
)
?
-
Desktop
.
instance
.
lockscreen
.
width
:
-
Desktop
.
instance
.
lockscreen
.
height
)
+
Math
.
abs
(
gestureArea
.
value
)
:
((
Desktop
.
instance
.
lockscreen
.
width
===
topmostWindow
.
width
)
?
Desktop
.
instance
.
lockscreen
.
width
:
Desktop
.
instance
.
lockscreen
.
height
)
+
gestureArea
.
value
)
)
:
0
)
// Bringing up the codepad opacity from 0 to 1
opacity
:
gestureArea
.
horizontal
?
(
gestureArea
.
value
<
0
?
(
gestureArea
.
value
/
-
Desktop
.
instance
.
lockscreen
.
width
)
:
gestureArea
.
value
/
Desktop
.
instance
.
lockscreen
.
width
)
:
0
}
},
// pushCodepad is when you are pushing the codepad away without entering a security code
State
{
name
:
"
pushCodepad
"
when
:
Desktop
.
instance
.
lockscreenVisible
()
&&
DeviceLock
.
state
===
DeviceLock
.
Locked
&&
Desktop
.
instance
.
codepadVisible
PropertyChanges
{
target
:
gestureArea
delayReset
:
true
}
PropertyChanges
{
target
:
Desktop
.
instance
.
codepad
// Confusing logic for the codepad to follow your swipe
x
:
gestureArea
.
lockscreenX
+
((
gestureArea
.
horizontal
)
?
(
Desktop
.
instance
.
lockscreenVisible
()?(
gestureArea
.
value
)
:
(
gestureArea
.
gesture
==
"
right
"
?
((
Desktop
.
instance
.
lockscreen
.
width
===
topmostWindow
.
width
)
?
-
Desktop
.
instance
.
lockscreen
.
width
:
-
Desktop
.
instance
.
lockscreen
.
height
)
+
Math
.
abs
(
gestureArea
.
value
)
:
((
Desktop
.
instance
.
lockscreen
.
width
===
topmostWindow
.
width
)
?
Desktop
.
instance
.
lockscreen
.
width
:
Desktop
.
instance
.
lockscreen
.
height
)
+
gestureArea
.
value
)
)
:
0
)
// Hiding the codepad with opacity fading from 1 to 0
opacity
:
1
-
(
gestureArea
.
horizontal
?
(
gestureArea
.
value
<
0
?
(
gestureArea
.
value
/
-
Desktop
.
instance
.
lockscreen
.
width
)
:
gestureArea
.
value
/
Desktop
.
instance
.
lockscreen
.
width
)
:
0
)
}
}
]
SequentialAnimation
{
...
...
src/src.pro
View file @
4622bc51
...
...
@@ -100,14 +100,15 @@ QT += quick compositor
DEFINES += QT_COMPOSITOR_QUICK
HEADERS += \
glacierwindowmodel.h
QT += dbus
LIBS += -lnemodevicelock
MOC_DIR = .moc
SOURCES += \
main.cpp \
glacierwindowmodel.cpp
PKGCONFIG += lipstick-qt5
PKGCONFIG += lipstick-qt5 \
nemodevicelock
OTHER_FILES += qml
/*
.qml \
qml/MainScreen.qml \
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment