AeRegeneratel38

Untitled

Jun 5th, 2021
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 10.42 KB | None | 0 0
  1. /*
  2. Copyright (C) 2019 Nicolas Fella <nicolas.fella@gmx.de>
  3.  
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13.  
  14. You should have received a copy of the GNU General Public License
  15. along with this program.  If not, see <http://www.gnu.org/licenses/>.
  16. */
  17.  
  18. import QtQuick 2.12
  19. import QtQuick.Controls 1.1
  20. import QtQuick.Layouts 1.1
  21. import QtGraphicalEffects 1.12
  22. import org.kde.plasma.components 2.0 as PlasmaComponents
  23. import org.kde.plasma.core 2.0 as PlasmaCore
  24. import org.kde.plasma.workspace.keyboardlayout 1.0
  25. import org.kde.notificationmanager 1.1 as Notifications
  26. import "../components"
  27.  
  28. PlasmaCore.ColorScope {
  29.     id: root
  30.  
  31.     property string password
  32.    
  33.     property bool isWidescreen: root.height < root.width * 0.75
  34.     property bool notificationsShown: false //phoneNotificationsList.count !== 0
  35.  
  36.     colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
  37.     anchors.fill: parent
  38.    
  39.     function isPinDrawerOpen() {
  40.         return passwordFlickable.contentY === passwordFlickable.columnHeight;
  41.     }
  42.     Image {
  43.         id:bgImage
  44.         anchors.fill: parent
  45.         source: "file:///usr/share/icons/jing/lockscreen_bg.png"
  46.     }
  47.    
  48.     // blur background once keypad is open
  49.     FastBlur {
  50.         id: blur
  51.         cached: true
  52.         anchors.fill: parent
  53.         source: bgImage //wallpaper
  54.         visible: true
  55.        
  56.         property bool doBlur: notificationsShown || isPinDrawerOpen() // only blur once animation finished for performance
  57.        
  58.         Behavior on doBlur {
  59.             NumberAnimation {
  60.                 target: blur
  61.                 property: "radius"
  62.                 duration: 1000
  63.                 to: blur.doBlur ? 0 : 90
  64.                 easing.type: Easing.InOutQuad
  65.             }
  66.             PropertyAction {
  67.                 target: blur
  68.                 property: "visible"
  69.                 value: blur.doBlur
  70.             }
  71.         }
  72.  
  73.         Rectangle {
  74.             anchors.fill: parent
  75.             color: "#000000"
  76.             opacity: visible ? 0.1 : 0
  77.             visible: blur.doBlur
  78.  
  79.             Behavior on opacity {
  80.                 NumberAnimation { duration: 500 }
  81.             }
  82.         }
  83.     }
  84.    
  85.     Notifications.WatchedNotificationsModel {
  86.         id: notifModel
  87.     }
  88.    
  89.     // header bar
  90.     SimpleHeaderBar {
  91.         anchors {
  92.             top: parent.top
  93.             left: parent.left
  94.             right: parent.right
  95.         }
  96.         height: units.gridUnit
  97.         opacity: 1 - (passwordFlickable.contentY / passwordFlickable.columnHeight)
  98.     }
  99.    
  100.     // phone clock component
  101.     ColumnLayout {
  102.         id: phoneClockComponent
  103.         visible: !isWidescreen
  104.        
  105.         anchors {
  106.             top: parent.top
  107.             topMargin: root.height / 2 - (height / 2 + units.gridUnit * 2)
  108.             left: parent.left
  109.             right: parent.right
  110.         }
  111.         spacing: 0
  112.         opacity: 1 - (passwordFlickable.contentY / passwordFlickable.columnHeight)
  113.        
  114.         states: State {
  115.             name: "notification"; when: notificationsShown
  116.             PropertyChanges { target: phoneClockComponent; anchors.topMargin: units.gridUnit * 5 }
  117.         }
  118.        
  119.         transitions: Transition {
  120.             NumberAnimation {
  121.                 properties: "anchors.topMargin"
  122.                 easing.type: Easing.InOutQuad
  123.             }
  124.         }
  125.        
  126.         Clock {
  127.             id: phoneClock
  128.             alignment: Qt.AlignCenter
  129.             Layout.alignment: Qt.AlignCenter
  130.  
  131.             Layout.topMargin: units.gridUnit * 2 // keep spacing even if media controls are gone
  132.         }
  133.         MediaControls {
  134.             Layout.alignment: Qt.AlignRight
  135.             Layout.fillWidth: true
  136.             Layout.maximumWidth: units.gridUnit * 25
  137.             Layout.minimumWidth: units.gridUnit * 15
  138.             Layout.leftMargin: units.gridUnit
  139.             Layout.rightMargin: units.gridUnit
  140.             z: 5
  141.         }
  142.     }
  143.    
  144.     // tablet clock component
  145.     Item {
  146.         id: tabletClockComponent
  147.         visible: isWidescreen
  148.        width: parent.width / 2  
  149.         anchors {
  150.             top: parent.top
  151.             bottom: parent.bottom
  152.             right: parent.right
  153.             rightMargin: units.gridUnit * 30
  154.         }
  155.        
  156.         ColumnLayout {
  157.             id: tabletLayout
  158.             // anchors.centerIn: parent
  159.             anchors.horizontalCenter: parent.horizontalCenter
  160.             anchors.top: parent.top
  161.             anchors.topMargin: tabletClock.height
  162.  
  163.             spacing: units.gridUnit * 10
  164.             opacity: 1 - (passwordFlickable.contentY / passwordFlickable.columnHeight)
  165.            
  166.             /* MediaControls {
  167.                 Layout.alignment: Qt.AlignRight
  168.                 Layout.fillWidth: true
  169.                 Layout.maximumWidth: units.gridUnit * 25
  170.                 Layout.minimumWidth: units.gridUnit * 20
  171.                 z: 5
  172.             }
  173.     */
  174.            
  175.             Clock {
  176.                 id: tabletClock
  177.                 alignment: Qt.AlignLeft | Qt.AlignTop
  178.                 Layout.fillWidth: true
  179.                 Layout.minimumWidth: units.gridUnit * 30
  180.             }
  181.         }
  182.     }
  183.    
  184.     // // phone notifications list
  185.     // NotificationsList {
  186.     //     id: phoneNotificationsList
  187.     //     visible: !isWidescreen
  188.     //     z: passwordFlickable.contentY === 0 ? 5 : 0 // prevent mousearea from interfering with pin drawer
  189.     //     anchors {
  190.     //         top: phoneClockComponent.bottom
  191.     //         topMargin: units.gridUnit
  192.     //         bottom: scrollUpIcon.top
  193.     //         bottomMargin: units.gridUnit
  194.     //         left: parent.left
  195.     //         leftMargin: units.gridUnit
  196.     //         right: parent.right
  197.     //         rightMargin: units.gridUnit
  198.     //     }
  199.     // }
  200.    
  201.     // tablet notifications list
  202.     // ColumnLayout {
  203.     //     visible: isWidescreen
  204.     //     z: passwordFlickable.contentY === 0 ? 5 : 0 // prevent mousearea from interfering with pin drawer
  205.     //     anchors {
  206.     //         top: parent.top
  207.     //         bottom: parent.bottom
  208.     //         right: tabletClockComponent.left
  209.     //         left: parent.left
  210.     //         leftMargin: units.gridUnit
  211.     //     }
  212.        
  213.     //     NotificationsList {
  214.     //         Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
  215.     //         Layout.fillWidth: true
  216.     //         Layout.minimumHeight: this.notificationListHeight
  217.     //         Layout.minimumWidth: units.gridUnit * 15
  218.     //         Layout.maximumWidth: units.gridUnit * 25
  219.     //     }
  220.     // }
  221.    
  222.     // scroll up icon
  223.     PlasmaCore.IconItem {
  224.         id: scrollUpIcon
  225.         anchors.bottom: parent.bottom
  226.         anchors.bottomMargin: units.gridUnit + passwordFlickable.contentY * 0.5
  227.         anchors.horizontalCenter: parent.horizontalCenter
  228.         opacity: 1 - (passwordFlickable.contentY / passwordFlickable.columnHeight)
  229.        
  230.         colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
  231.         source: "arrow-right"
  232.     }
  233.  
  234.     PlasmaCore.IconItem {
  235.         id: scrollUpIcon2
  236.         anchors.left: scrollUpIcon.right
  237.     anchors.bottom: parent.bottom
  238.     anchors.bottomMargin: units.gridUnit + passwordFlickable.contentY * 0.5  
  239.         opacity: 1 - (passwordFlickable.contentY / passwordFlickable.columnHeight)
  240.  
  241.         colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
  242.         source: "arrow-right"
  243.     }
  244.  
  245.     PlasmaCore.IconItem {
  246.         id: scrollUpIcon3
  247.         anchors.right: scrollUpIcon.left
  248.         anchors.bottom: parent.bottom
  249.         anchors.bottomMargin: units.gridUnit + passwordFlickable.contentY * 0.5
  250.         opacity: 1 - (passwordFlickable.contentY / passwordFlickable.columnHeight)
  251.  
  252.         colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
  253.         source: "arrow-right"
  254.     }
  255.  
  256.     Text {
  257.         id: scrollUpText
  258.         anchors.bottom: parent.bottom
  259.         anchors.bottomMargin: units.gridUnit*3 + passwordFlickable.contentY * 0.5
  260.         opacity: 1 - (passwordFlickable.contentY / passwordFlickable.columnHeight)
  261. // passwordFlickable.contentY
  262.         anchors.horizontalCenter: parent.horizontalCenter
  263.         color: "white"
  264.         text: "Slide to Unlock"
  265.     }
  266.  
  267.     Flickable {
  268.         id: passwordFlickable
  269.        
  270.         anchors.fill: parent
  271.        
  272.         property int columnHeight: units.gridUnit * 20
  273.        
  274.         height: columnHeight + root.height
  275.         contentHeight: columnHeight + root.height
  276.         boundsBehavior: Flickable.StopAtBounds
  277.        
  278.         // always snap to end (either hidden or shown)
  279.         onFlickEnded: {
  280.             if (!atYBeginning && !atYEnd) {
  281.                 if (contentY > columnHeight - contentY) {
  282.                     flick(0, -1000);
  283.                 } else {
  284.                     flick(0, 1000);
  285.                 }
  286.             }
  287.         }
  288.  
  289.         // wipe password if it is more than half way down the screen
  290.         onContentYChanged: {
  291.             if (contentY < columnHeight / 2) {
  292.                 root.password = "";
  293.                 keypad.pinLabel = qsTr("Enter PIN");
  294.                 keypad.focus = true
  295.                 keypad.forceActiveFocus();
  296.             }
  297.         }
  298.  
  299.         ColumnLayout {
  300.             id: passwordLayout
  301.             anchors.bottom: parent.bottom
  302.            
  303.             width: parent.width
  304.             spacing: units.gridUnit
  305.             opacity: Math.sin((Math.PI / 2) * (passwordFlickable.contentY / passwordFlickable.columnHeight) + 1.5 * Math.PI) + 1
  306.            
  307.             // scroll down icon
  308. //            PlasmaCore.IconItem {
  309. //                Layout.alignment: Qt.AlignHCenter
  310. //                colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
  311. //                source: "arrow-down"
  312. //            }
  313.  
  314.             Keypad {
  315.                 id: keypad
  316.                 focus: true // passwordFlickable.contentY === passwordFlickable.columnHeight
  317.                 Layout.fillWidth: true
  318.                 Layout.minimumHeight: root.height //units.gridUnit * 17
  319.                 Layout.maximumWidth: root.width
  320.             }
  321.         }
  322.     }
  323. }
Add Comment
Please, Sign In to add comment