From f9e40bac37fa600861363335a705eff59596a217 Mon Sep 17 00:00:00 2001 From: eximus Date: Tue, 6 Nov 2018 02:30:21 +0000 Subject: [PATCH] added blur to the background --- .gitignore | 2 +- Main.qml | 15 ++- components/WallpaperFader.qml | 181 ++++++++++++++++++++++++++++++++++ 3 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 components/WallpaperFader.qml diff --git a/.gitignore b/.gitignore index a0597e9..1bbebfe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -Main.qmlc +**/*.qmlc /playlist_videos/* !/playlist_videos/*.md diff --git a/Main.qml b/Main.qml index 68b6882..41cf624 100644 --- a/Main.qml +++ b/Main.qml @@ -2,6 +2,8 @@ import QtQuick 2.0 import SddmComponents 2.0 import QtMultimedia 5.8 +import "components" + Rectangle { // Main Container id: container @@ -64,7 +66,8 @@ Rectangle { MouseArea { id: mouseArea1 anchors.fill: parent; - onPressed: {playlist1.shuffle(); playlist1.next();} + //onPressed: {playlist1.shuffle(); playlist1.next();} + onPressed: { fader.state = fader.state == "off" ? "on" : "off" ; } } } @@ -136,6 +139,16 @@ Rectangle { mediaplayer2.stop() } } + WallpaperFader { + id: fader + visible: true + anchors.fill: parent + state: "off" + source: video1 + mainStack: login_container + footer: login_container + clock: clock + } diff --git a/components/WallpaperFader.qml b/components/WallpaperFader.qml new file mode 100644 index 0000000..f52c33c --- /dev/null +++ b/components/WallpaperFader.qml @@ -0,0 +1,181 @@ +/******************************************************************** + This file is part of the KDE project. + +Copyright (C) 2014 Aleix Pol Gonzalez + +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 . +*********************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 1.1 +import QtQuick.Layouts 1.1 +import QtGraphicalEffects 1.0 + +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents + +import org.kde.plasma.private.sessions 2.0 + +Item { + id: wallpaperFader + property Item clock + property Item mainStack + property Item footer + property alias source: wallpaperBlur.source + state: lockScreenRoot.uiVisible ? "on" : "off" + property real factor: 20 + readonly property bool lightBackground: Math.max(PlasmaCore.ColorScope.backgroundColor.r, PlasmaCore.ColorScope.backgroundColor.g, PlasmaCore.ColorScope.backgroundColor.b) > 0.5 + + Behavior on factor { + NumberAnimation { + target: wallpaperFader + property: "factor" + duration: 1000 + easing.type: Easing.InOutQuad + } + } + FastBlur { + id: wallpaperBlur + anchors.fill: parent + radius: 40 * wallpaperFader.factor + } + ShaderEffect { + id: wallpaperShader + anchors.fill: parent + supportsAtlasTextures: true + property var source: ShaderEffectSource { + sourceItem: wallpaperBlur + live: true + hideSource: true + textureMirroring: ShaderEffectSource.NoMirroring + } + + readonly property real contrast: 0.45 * wallpaperFader.factor + (1 - wallpaperFader.factor) + readonly property real saturation: 1.7 * wallpaperFader.factor + (1 - wallpaperFader.factor) + readonly property real intensity: (wallpaperFader.lightBackground ? 1.7 : 0.45) * wallpaperFader.factor + (1 - wallpaperFader.factor) + + readonly property real transl: (1.0 - contrast) / 2.0; + readonly property real rval: (1.0 - saturation) * 0.2126; + readonly property real gval: (1.0 - saturation) * 0.7152; + readonly property real bval: (1.0 - saturation) * 0.0722; + + property var colorMatrix: Qt.matrix4x4( + contrast, 0, 0, 0.0, + 0, contrast, 0, 0.0, + 0, 0, contrast, 0.0, + transl, transl, transl, 1.0).times(Qt.matrix4x4( + rval + saturation, rval, rval, 0.0, + gval, gval + saturation, gval, 0.0, + bval, bval, bval + saturation, 0.0, + 0, 0, 0, 1.0)).times(Qt.matrix4x4( + intensity, 0, 0, 0, + 0, intensity, 0, 0, + 0, 0, intensity, 0, + 0, 0, 0, 1 + )); + + + fragmentShader: " + uniform mediump mat4 colorMatrix; + uniform mediump sampler2D source; + varying mediump vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + + void main(void) + { + mediump vec4 tex = texture2D(source, qt_TexCoord0); + gl_FragColor = tex * colorMatrix * qt_Opacity; + }" + } + + states: [ + State { + name: "on" + PropertyChanges { + target: mainStack + opacity: 1 + } + PropertyChanges { + target: footer + opacity: 1 + } + PropertyChanges { + target: wallpaperFader + factor: 1 + } + PropertyChanges { + target: clock.shadow + opacity: 0 + } + }, + State { + name: "off" + PropertyChanges { + target: mainStack + opacity: 0 + } + PropertyChanges { + target: footer + opacity: 0 + } + PropertyChanges { + target: wallpaperFader + factor: 0 + } + PropertyChanges { + target: clock.shadow + opacity: 1 + } + } + ] + transitions: [ + Transition { + from: "off" + to: "on" + //Note: can't use animators as they don't play well with parallelanimations + ParallelAnimation { + NumberAnimation { + target: mainStack + property: "opacity" + duration: units.longDuration + easing.type: Easing.InOutQuad + } + NumberAnimation { + target: footer + property: "opacity" + duration: units.longDuration + easing.type: Easing.InOutQuad + } + } + }, + Transition { + from: "on" + to: "off" + ParallelAnimation { + NumberAnimation { + target: mainStack + property: "opacity" + duration: 500 + easing.type: Easing.InOutQuad + } + NumberAnimation { + target: footer + property: "opacity" + duration: 500 + easing.type: Easing.InOutQuad + } + } + } + ] +}