Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Copyright (C) 2019 Nicolas Fella <nicolas.fella@gmx.de>
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- import QtQuick 2.12
- import QtQuick.Controls 1.1
- import QtQuick.Layouts 1.1
- import QtGraphicalEffects 1.12
- import org.kde.plasma.components 2.0 as PlasmaComponents
- import org.kde.plasma.core 2.0 as PlasmaCore
- import org.kde.plasma.workspace.keyboardlayout 1.0
- import org.kde.notificationmanager 1.1 as Notifications
- import "../components"
- PlasmaCore.ColorScope {
- id: root
- property string password
- property bool isWidescreen: root.height < root.width * 0.75
- property bool notificationsShown: false //phoneNotificationsList.count !== 0
- colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
- anchors.fill: parent
- function isPinDrawerOpen() {
- return passwordFlickable.contentY === passwordFlickable.columnHeight;
- }
- Image {
- id:bgImage
- anchors.fill: parent
- source: "file:///usr/share/icons/jing/lockscreen_bg.png"
- }
- // blur background once keypad is open
- FastBlur {
- id: blur
- cached: true
- anchors.fill: parent
- source: bgImage //wallpaper
- visible: true
- property bool doBlur: notificationsShown || isPinDrawerOpen() // only blur once animation finished for performance
- Behavior on doBlur {
- NumberAnimation {
- target: blur
- property: "radius"
- duration: 1000
- to: blur.doBlur ? 0 : 90
- easing.type: Easing.InOutQuad
- }
- PropertyAction {
- target: blur
- property: "visible"
- value: blur.doBlur
- }
- }
- Rectangle {
- anchors.fill: parent
- color: "#000000"
- opacity: visible ? 0.1 : 0
- visible: blur.doBlur
- Behavior on opacity {
- NumberAnimation { duration: 500 }
- }
- }
- }
- Notifications.WatchedNotificationsModel {
- id: notifModel
- }
- // header bar
- SimpleHeaderBar {
- anchors {
- top: parent.top
- left: parent.left
- right: parent.right
- }
- height: units.gridUnit
- opacity: 1 - (passwordFlickable.contentY / passwordFlickable.columnHeight)
- }
- // phone clock component
- ColumnLayout {
- id: phoneClockComponent
- visible: !isWidescreen
- anchors {
- top: parent.top
- topMargin: root.height / 2 - (height / 2 + units.gridUnit * 2)
- left: parent.left
- right: parent.right
- }
- spacing: 0
- opacity: 1 - (passwordFlickable.contentY / passwordFlickable.columnHeight)
- states: State {
- name: "notification"; when: notificationsShown
- PropertyChanges { target: phoneClockComponent; anchors.topMargin: units.gridUnit * 5 }
- }
- transitions: Transition {
- NumberAnimation {
- properties: "anchors.topMargin"
- easing.type: Easing.InOutQuad
- }
- }
- Clock {
- id: phoneClock
- alignment: Qt.AlignCenter
- Layout.alignment: Qt.AlignCenter
- Layout.topMargin: units.gridUnit * 2 // keep spacing even if media controls are gone
- }
- MediaControls {
- Layout.alignment: Qt.AlignRight
- Layout.fillWidth: true
- Layout.maximumWidth: units.gridUnit * 25
- Layout.minimumWidth: units.gridUnit * 15
- Layout.leftMargin: units.gridUnit
- Layout.rightMargin: units.gridUnit
- z: 5
- }
- }
- // tablet clock component
- Item {
- id: tabletClockComponent
- visible: isWidescreen
- width: parent.width / 2
- anchors {
- top: parent.top
- bottom: parent.bottom
- right: parent.right
- rightMargin: units.gridUnit * 30
- }
- ColumnLayout {
- id: tabletLayout
- // anchors.centerIn: parent
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.top: parent.top
- anchors.topMargin: tabletClock.height
- spacing: units.gridUnit * 10
- opacity: 1 - (passwordFlickable.contentY / passwordFlickable.columnHeight)
- /* MediaControls {
- Layout.alignment: Qt.AlignRight
- Layout.fillWidth: true
- Layout.maximumWidth: units.gridUnit * 25
- Layout.minimumWidth: units.gridUnit * 20
- z: 5
- }
- */
- Clock {
- id: tabletClock
- alignment: Qt.AlignLeft | Qt.AlignTop
- Layout.fillWidth: true
- Layout.minimumWidth: units.gridUnit * 30
- }
- }
- }
- // // phone notifications list
- // NotificationsList {
- // id: phoneNotificationsList
- // visible: !isWidescreen
- // z: passwordFlickable.contentY === 0 ? 5 : 0 // prevent mousearea from interfering with pin drawer
- // anchors {
- // top: phoneClockComponent.bottom
- // topMargin: units.gridUnit
- // bottom: scrollUpIcon.top
- // bottomMargin: units.gridUnit
- // left: parent.left
- // leftMargin: units.gridUnit
- // right: parent.right
- // rightMargin: units.gridUnit
- // }
- // }
- // tablet notifications list
- // ColumnLayout {
- // visible: isWidescreen
- // z: passwordFlickable.contentY === 0 ? 5 : 0 // prevent mousearea from interfering with pin drawer
- // anchors {
- // top: parent.top
- // bottom: parent.bottom
- // right: tabletClockComponent.left
- // left: parent.left
- // leftMargin: units.gridUnit
- // }
- // NotificationsList {
- // Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
- // Layout.fillWidth: true
- // Layout.minimumHeight: this.notificationListHeight
- // Layout.minimumWidth: units.gridUnit * 15
- // Layout.maximumWidth: units.gridUnit * 25
- // }
- // }
- // scroll up icon
- PlasmaCore.IconItem {
- id: scrollUpIcon
- anchors.bottom: parent.bottom
- anchors.bottomMargin: units.gridUnit + passwordFlickable.contentY * 0.5
- anchors.horizontalCenter: parent.horizontalCenter
- opacity: 1 - (passwordFlickable.contentY / passwordFlickable.columnHeight)
- colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
- source: "arrow-right"
- }
- PlasmaCore.IconItem {
- id: scrollUpIcon2
- anchors.left: scrollUpIcon.right
- anchors.bottom: parent.bottom
- anchors.bottomMargin: units.gridUnit + passwordFlickable.contentY * 0.5
- opacity: 1 - (passwordFlickable.contentY / passwordFlickable.columnHeight)
- colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
- source: "arrow-right"
- }
- PlasmaCore.IconItem {
- id: scrollUpIcon3
- anchors.right: scrollUpIcon.left
- anchors.bottom: parent.bottom
- anchors.bottomMargin: units.gridUnit + passwordFlickable.contentY * 0.5
- opacity: 1 - (passwordFlickable.contentY / passwordFlickable.columnHeight)
- colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
- source: "arrow-right"
- }
- Text {
- id: scrollUpText
- anchors.bottom: parent.bottom
- anchors.bottomMargin: units.gridUnit*3 + passwordFlickable.contentY * 0.5
- opacity: 1 - (passwordFlickable.contentY / passwordFlickable.columnHeight)
- // passwordFlickable.contentY
- anchors.horizontalCenter: parent.horizontalCenter
- color: "white"
- text: "Slide to Unlock"
- }
- Flickable {
- id: passwordFlickable
- anchors.fill: parent
- property int columnHeight: units.gridUnit * 20
- height: columnHeight + root.height
- contentHeight: columnHeight + root.height
- boundsBehavior: Flickable.StopAtBounds
- // always snap to end (either hidden or shown)
- onFlickEnded: {
- if (!atYBeginning && !atYEnd) {
- if (contentY > columnHeight - contentY) {
- flick(0, -1000);
- } else {
- flick(0, 1000);
- }
- }
- }
- // wipe password if it is more than half way down the screen
- onContentYChanged: {
- if (contentY < columnHeight / 2) {
- root.password = "";
- keypad.pinLabel = qsTr("Enter PIN");
- keypad.focus = true
- keypad.forceActiveFocus();
- }
- }
- ColumnLayout {
- id: passwordLayout
- anchors.bottom: parent.bottom
- width: parent.width
- spacing: units.gridUnit
- opacity: Math.sin((Math.PI / 2) * (passwordFlickable.contentY / passwordFlickable.columnHeight) + 1.5 * Math.PI) + 1
- // scroll down icon
- // PlasmaCore.IconItem {
- // Layout.alignment: Qt.AlignHCenter
- // colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
- // source: "arrow-down"
- // }
- Keypad {
- id: keypad
- focus: true // passwordFlickable.contentY === passwordFlickable.columnHeight
- Layout.fillWidth: true
- Layout.minimumHeight: root.height //units.gridUnit * 17
- Layout.maximumWidth: root.width
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment