Commit 9923cde1 authored by Guo Yunhe's avatar Guo Yunhe

Wallpaper blur background filling effect feature

parent 2aa50434
......@@ -19,6 +19,7 @@
import QtQuick 2.0
import QtQuick.Controls.Private 1.0
import QtGraphicalEffects 1.0
import org.kde.kquickcontrolsaddons 2.0
import org.kde.plasma.components 2.0 as PlasmaComponents
......@@ -59,6 +60,23 @@ MouseArea {
icon: "view-preview"
visible: !walliePreview.visible
}
QPixmapItem {
id: blurBackgroundSource
visible: cfg_Blur
anchors.fill: parent
smooth: true
pixmap: model.screenshot
fillMode: QPixmapItem.PreserveAspectCrop
}
FastBlur {
visible: cfg_Blur
anchors.fill: parent
source: blurBackgroundSource
radius: 4
}
QPixmapItem {
id: walliePreview
anchors.fill: parent
......
......@@ -34,6 +34,7 @@ ColumnLayout {
property alias cfg_Color: colorDialog.color
property string cfg_Image
property int cfg_FillMode
property alias cfg_Blur: blurCheckBox.checked
property var cfg_SlidePaths: ""
property int cfg_SlideInterval: 0
......@@ -127,6 +128,24 @@ ColumnLayout {
}
}
Row {
//x: formAlignment - positionLabel.paintedWidth
spacing: units.largeSpacing / 2
QtControls.Label {
id: blurLabel
width: formAlignment - units.largeSpacing
anchors {
verticalCenter: blurCheckBox.verticalCenter
}
horizontalAlignment: Text.AlignRight
}
QtControls.CheckBox {
id: blurCheckBox
text: i18nd("plasma_applet_org.kde.image", "Use blur background filling")
checked: true
}
}
QtDialogs.ColorDialog {
id: colorDialog
modality: Qt.WindowModal
......
......@@ -19,6 +19,7 @@
*/
import QtQuick 2.5
import QtGraphicalEffects 1.0
import org.kde.plasma.wallpapers.image 2.0 as Wallpaper
import org.kde.plasma.core 2.0 as PlasmaCore
......@@ -28,7 +29,9 @@ Item {
readonly property string configuredImage: wallpaper.configuration.Image
readonly property string modelImage: imageWallpaper.wallpaperPath
property Item currentImage: imageB
property Item currentBlurBackground: blurBackgroundB
property Item otherImage: imageA
property Item otherBlurBackground: blurBackgroundA
readonly property int fillMode: wallpaper.configuration.FillMode
property bool ready: false
......@@ -63,6 +66,7 @@ Item {
// Prevent source size change when image has just been setup anyway
sourceSizeTimer.stop()
currentImage.opacity = 0
currentBlurBackground.opacity = 0
otherImage.z = 0
currentImage.z = 1
......@@ -84,6 +88,7 @@ Item {
sourceSizeTimer.stop()
currentImage.source = modelImage
currentImage.opacity = 0
currentBlurBackground.opacity = 0
otherImage.z = 0
currentImage.fillMode = fillMode
currentImage.z = 1
......@@ -107,6 +112,7 @@ Item {
swapImages()
currentImage.sourceSize = Qt.size(root.width, root.height)
currentImage.opacity = 0
currentBlurBackground.opacity = 0
currentImage.source = otherImage.source
otherImage.z = 0
currentImage.z = 1
......@@ -126,10 +132,14 @@ Item {
function swapImages() {
if (currentImage == imageA) {
currentImage = imageB
currentBlurBackground = blurBackgroundB
otherImage = imageA
otherBlurBackground = blurBackgroundA
} else {
currentImage = imageA
currentBlurBackground = blurBackgroundA
otherImage = imageB
otherBlurBackground = blurBackgroundB
}
}
......@@ -173,6 +183,21 @@ Item {
running: false
ParallelAnimation {
OpacityAnimator {
target: currentBlurBackground
from: 0
to: 1
duration: fadeOtherAnimator.duration
}
OpacityAnimator {
target: otherBlurBackground
from: 1
// cannot disable an animation individually, so we just fade from 1 to 1
to: enabled ? 0 : 1
//use configured duration if animations are enabled
duration: units.longDuration && wallpaper.configuration.TransitionAnimationDuration
}
OpacityAnimator {
target: currentImage
from: 0
......@@ -209,6 +234,48 @@ Item {
}
}
Image {
id: blurBackgroundSourceA
visible: wallpaper.configuration.Blur
anchors.fill: parent
asynchronous: true
cache: false
fillMode: Image.PreserveAspectCrop
source: imageA.source
z: -1
}
GaussianBlur {
id: blurBackgroundA
visible: wallpaper.configuration.Blur
anchors.fill: parent
source: blurBackgroundSourceA
radius: 32
samples: 65
z: imageA.z
}
Image {
id: blurBackgroundSourceB
visible: wallpaper.configuration.Blur
anchors.fill: parent
asynchronous: true
cache: false
fillMode: Image.PreserveAspectCrop
source: imageB.source
z: -1
}
GaussianBlur {
id: blurBackgroundB
visible: wallpaper.configuration.Blur
anchors.fill: parent
source: blurBackgroundSourceB
radius: 32
samples: 65
z: imageB.z
}
Image {
id: imageA
anchors.fill: parent
......@@ -217,6 +284,7 @@ Item {
fillMode: wallpaper.configuration.FillMode
autoTransform: true //new API in Qt 5.5, do not backport into Plasma 5.4.
}
Image {
id: imageB
anchors.fill: parent
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment