Commit 8ea5c5ff authored by Marco Martin's avatar Marco Martin

brand new lockscreen

parent ad10cc00
/*
* Copyright 2016 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 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 Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.0
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
PlasmaComponents.Label {
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
font.pixelSize: units.gridUnit * 3
property alias sub: longHold.text
property var callback
Layout.fillWidth: true
MouseArea {
anchors.fill: parent
onClicked: {
if (callback) {
callback();
} else {
addNumber(parent.text);
}
}
onPressAndHold: {
if (longHold.visible) {
addNumber(longHold.text);
} else {
addNumber(parent.text);
}
}
}
PlasmaComponents.Label {
id: longHold
anchors {
top: parent.top
right: parent.right
}
height: parent.height
width: parent.width / 3
verticalAlignment: Qt.AlignVCenter
visible: text.length > 0
opacity: 0.7
font.pixelSize: parent.pixelSize * .8
}
}
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
Item {
width: units.iconSizes.smallMedium
height: width
property var callback
property string text
property string sub
property alias source: icon.source
PlasmaCore.IconItem {
id: icon
width: units.iconSizes.medium
height: width
anchors.centerIn: parent
colorGroup: PlasmaCore.ColorScope.colorGroup
}
MouseArea {
anchors.fill: parent
onClicked: {
if (callback) {
callback();
} else {
addNumber(parent.text);
}
}
onPressAndHold: {
if (parent.sub.length > 0) {
addNumber(parent.sub);
} else {
addNumber(parent.text);
}
}
}
}
/*
* Copyright 2014 David Edmundson <davidedmundson@kde.org>
* Copyright (C) 2014 by Aleix Pol Gonzalez <aleixpol@blue-systems.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 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 Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.2
import QtQuick.Layouts 1.1
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.workspace.components 2.0 as PW
ColumnLayout {
PlasmaComponents.Label { //should be a heading but we want it _loads_ bigger
text: Qt.formatTime(timeSource.data["Local"]["DateTime"])
//we fill the width then align the text so that we can make the text shrink to fit
Layout.fillWidth: true
horizontalAlignment: Text.AlignRight
font.weight: Font.DemiBold
fontSizeMode: Text.HorizontalFit
font.pointSize: 36
}
PlasmaComponents.Label {
text: Qt.formatDate(timeSource.data["Local"]["DateTime"], Qt.DefaultLocaleLongDate);
Layout.alignment: Qt.AlignRight
}
RowLayout {
Layout.alignment: Qt.AlignRight
visible: pmSource.data["Battery"]["Has Cumulative"]
PW.BatteryIcon {
id: battery
hasBattery: true
percent: pmSource.data["Battery"]["Percent"]
pluggedIn: pmSource.data["AC Adapter"] ? pmSource.data["AC Adapter"]["Plugged in"] : false
height: batteryLabel.height
width: batteryLabel.height
}
PlasmaComponents.Label {
id: batteryLabel
text: {
var state = pmSource.data["Battery"] ? pmSource.data["Battery"]["State"] : "";
switch(state) {
case "Charging":
return i18nd("plasma_lookandfeel_org.kde.lookandfeel","%1%. Charging", battery.percent)
case "FullyCharged":
return i18nd("plasma_lookandfeel_org.kde.lookandfeel","Fully charged")
default:
return i18nd("plasma_lookandfeel_org.kde.lookandfeel","%1% battery remaining", battery.percent)
}
}
Layout.alignment: Qt.AlignRight
wrapMode: Text.Wrap
}
}
PlasmaCore.DataSource {
id: pmSource
engine: "powermanagement"
connectedSources: ["Battery", "AC Adapter"]
}
PlasmaCore.DataSource {
id: timeSource
engine: "time"
connectedSources: ["Local"]
interval: 1000
}
}
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
Rectangle {
gradient: Gradient {
GradientStop { position: 0.0; color: "#FFEDDF00" }
GradientStop { position: 3.0; color: "#00EDDF00" }
}
opacity: 0.6
height: Math.max(100, units.gridUnit * 2.5)
width: parent.width
y: parent.height / 2 - height / 2
x: 0
}
This diff is collapsed.
[kdeglobals][KDE]
widgetStyle=breeze
[kdeglobals][General]
ColorScheme=Breeze
[kdeglobals][Icons]
Theme=breeze
[plasmarc][Theme]
name=default
/*
* Copyright 2014 Aaron Seigo <aseigo@kde.org>
* Copyright 2014 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.0
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import "../components"
GridLayout {
id: pad
columns: 3
Layout.fillWidth: true
Layout.fillHeight: true
function addNumber(number) {
passwordInput.text += number;
}
DialerButton { id: one; text: "1" }
DialerButton { text: "2" }
DialerButton { text: "3" }
DialerButton { text: "4" }
DialerButton { text: "5" }
DialerButton { text: "6" }
DialerButton { text: "7" }
DialerButton { text: "8" }
DialerButton { text: "9" }
DialerButton { text: "*"; }
DialerButton { text: "0"; sub: "+"; }
DialerButton { text: "#" }
}
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.0
import QtQuick.Particles 2.0
Item {
width: 360
height: 600
Image {
source: "images/backgroundLeaves.jpg"
anchors.fill: parent
}
ParticleSystem {
anchors.fill: parent
Emitter {
width: parent.width
emitRate: 4
lifeSpan: 14000
size: 80
velocity: PointDirection { y: 50 }
}
Wander {
anchors.fill: parent
anchors.bottomMargin: 100
xVariance: 60
pace: 60
}
//! [0]
Affector {
property real coefficient: 2.0
property real velocity: 1.5
width: parent.width
height: parent.height - 100
onAffectParticles: {
/* //Linear movement
if (particle.r == 0) {
particle.r = Math.random() > 0.5 ? -1 : 1;
} else if (particle.r == 1) {
particle.rotation += velocity * dt;
if (particle.rotation >= maxAngle)
particle.r = -1;
} else if (particle.r == -1) {
particle.rotation -= velocity * dt;
if (particle.rotation <= -1 * maxAngle)
particle.r = 1;
}
*/
//Wobbly movement
for (var i=0; i<particles.length; i++) {
var particle = particles[i];
if (particle.r == 0.0) {
particle.r = Math.random() + 0.01;
}
particle.rotation += velocity * particle.r * dt;
particle.r -= particle.rotation * coefficient;
if (particle.r == 0.0)
particle.r -= particle.rotation * 0.000001;
particle.update = 1;
}
}
}
//! [0]
//! [1]
Affector {//Custom Friction, adds some 'randomness'
x: -60
width: parent.width + 120
height: 100
anchors.bottom: parent.bottom
onAffectParticles: {
for (var i=0; i<particles.length; i++) {
var particle = particles[i];
var pseudoRand = (Math.floor(particle.t*1327) % 10) + 1;
var yslow = dt * pseudoRand * 0.5 + 1;
var xslow = dt * pseudoRand * 0.05 + 1;
if (particle.vy < 1)
particle.vy = 0;
else
particle.vy = (particle.vy / yslow);
if (particle.vx < 1)
particle.vx = 0;
else
particle.vx = (particle.vx / xslow);
particle.update = true;
}
}
}
//! [1]
ImageParticle {
anchors.fill: parent
id: particles
sprites: [Sprite {
source: "images/realLeaf1.png"
frameCount: 1
frameDuration: 1
to: {"a":1, "b":1, "c":1, "d":1}
}, Sprite {
name: "a"
source: "images/realLeaf1.png"
frameCount: 1
frameDuration: 10000
},
Sprite {
name: "b"
source: "images/realLeaf2.png"
frameCount: 1
frameDuration: 10000
},
Sprite {
name: "c"
source: "images/realLeaf3.png"
frameCount: 1
frameDuration: 10000
},
Sprite {
name: "d"
source: "images/realLeaf4.png"
frameCount: 1
frameDuration: 10000
}
]
z:4
}
}
}
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
Rectangle {
anchors.top: parent.top
color: "#00000000"
property int value: 0
property alias elementId: glyph.elementId
width: parent.width / 4
height: parent.height
PlasmaCore.SvgItem {
id: glyph
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
width: Math.min(parent.height, parent.width)
height: parent.height
svg: symbolsSvg
}
}
\ No newline at end of file
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import "../components"
/********************************************************************
This file is part of the KDE project.
Leaves {
id: lockscreen
signal tryUnlock(string code)
Copyright (C) 2014 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
PlasmaCore.Svg {
id: symbolsSvg
imagePath: Qt.resolvedUrl("images/symbols.svgz")
}
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.
MouseArea {
anchors.fill: parent
onPressed: {
stripe.opacity = 1;
}
}
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.
PlasmaCore.DataSource {
id: dataSource
engine: "time"
connectedSources: "Local"
interval: 30000
onDataChanged: {
var date = new Date(data["Local"]["DateTime"]);
hour.text = date.getHours();
minute.text = date.getMinutes();
}
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
Component.onCompleted: {
onDataChanged();
}
}
import QtQuick 2.0
import QtQuick.Controls 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.private.sessions 2.0
import "../components"
Text {
id: hour
Image {
id: root
property bool viewVisible: false
property bool debug: false
property string notification
property Item userSelect: null
property int interfaceVersion: org_kde_plasma_screenlocker_greeter_interfaceVersion ? org_kde_plasma_screenlocker_greeter_interfaceVersion : 0
signal clearPassword()
onTextChanged: {
if (text.length < 2) {
minute.text = "0" + text;
}
}
source: backgroundPath || "../components/artwork/background.png"
fillMode: Image.PreserveAspectCrop
asynchronous: true
anchors {
top: parent.top
left: parent.left
right: parent.right
bottom: stripe.top
onStatusChanged: {
if (status == Image.Error) {
source = "../components/artwork/background.png";
}
color: "white" // FIXME: base on wallpaper?
text: "00"
font.pixelSize: Math.floor((width - (units.largeSpacing)) / 2)
horizontalAlignment: Qt.AlignCenter
verticalAlignment: Qt.AlignVCenter
}
SatelliteStripe {
id: stripe
opacity: 0
property string code
function lockKeyPressed(id) {
hideTimer.stop();
code += id;
}
LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
LayoutMirroring.childrenInherit: true
function lockKeyReleased(id) {
hideTimer.start();
code += id;
Connections {
target: authenticator
onFailed: {
root.notification = i18nd("plasma_lookandfeel_org.kde.lookandfeel","Unlocking failed");
}
Behavior on opacity {
NumberAnimation {
duration: 500
easing.type: Easing.InOutQuad
onGraceLockedChanged: {
if (!authenticator.graceLocked) {
root.notification = "";
root.clearPassword();
}
}
MouseArea {
anchors.fill: parent
onPressed: {
if (stripe.opacity < 1) {
stripe.opacity = 1;
return;
}
stripe.lockKeyPressed(stripe.childAt(mouseX, mouseY).value);
}
onReleased: {
if (stripe.opacity < 1) {
return;
}
stripe.lockKeyReleased(stripe.childAt(mouseX, mouseY).value);
}
onMessage: {
root.notification = msg;
}
Timer {
id: hideTimer
interval: 1000
running: parent.opacity == 1
onTriggered: {
stripe.opacity = 0;
lockscreen.tryUnlock(stripe.code);
stripe.code = '';
}
}
LockKey {
id: square
value: 1
anchors.left: parent.left
elementId: "square"
}
LockKey {
id: circle
value: 2
anchors.left: square.right
elementId: "circle"
}
LockKey {
id: ex
value: 3
anchors.left: circle.right
elementId: "ex"
}
LockKey {
id: triangle
value: 4
anchors.left: ex.right
elementId: "triangle"
onError: {
root.notification = err;
}
}
SessionsModel {
id: sessionsModel
}
Text {
id: minute
onTextChanged: {
if (text.length < 2) {
minute.text = "0" + text;
}
}
anchors {
top: stripe.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
color: hour.color
text: "00"
font.pixelSize: Math.floor((width - (units.largeSpacing)) / 2)
horizontalAlignment: Qt.AlignCenter
verticalAlignment: Qt.AlignVCenter
PlasmaCore.DataSource {
id: keystateSource
engine: "keystate"
connectedSources: "Caps Lock"
}
Text {
id: emergencyCall
StackView {
id: stackView
anchors.fill: parent
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
initialItem: Loader {
active: root.viewVisible
source: "MainBlock.qml"
}
}
horizontalAlignment: Qt.AlignCenter
color: minute.color