Commit 87ec46be authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[Image Wallpaper] Just use Timer to determin when we're ready

This avoids fading the image source, or the fill mode, or the source size on startup while we're still setting things up.
While a Timer is usually a bad idea, this simplifies the code a lot.

Differential Revision: https://phabricator.kde.org/D9762
parent 755adc80
......@@ -34,7 +34,6 @@ Item {
property Item otherImage: imageA
property Item otherBlurBackground: blurBackgroundA
readonly property int fillMode: wallpaper.configuration.FillMode
property bool ready: false
property size sourceSize: Qt.size(root.width * Screen.devicePixelRatio, root.height * Screen.devicePixelRatio)
//public API, the C++ part will look for those
......@@ -52,13 +51,16 @@ Item {
}
//private
function fadeWallpaper() {
if (!ready && width > 0 && height > 0) { // shell startup, setup immediately
currentImage.sourceSize = root.sourceSize
currentImage.source = modelImage
function setupImage() {
currentImage.sourceSize = root.sourceSize;
currentImage.fillMode = root.fillMode;
currentImage.source = modelImage;
}
ready = true
return
function fadeWallpaper() {
if (startupTimer.running) {
setupImage();
return;
}
fadeAnim.running = false
......@@ -84,6 +86,11 @@ Item {
}
function fadeFillMode() {
if (startupTimer.running) {
setupImage();
return;
}
fadeAnim.running = false
swapImages()
currentImage.sourceSize = root.sourceSize
......@@ -110,6 +117,11 @@ Item {
return
}
if (startupTimer.running) {
setupImage();
return;
}
fadeAnim.running = false
swapImages()
currentImage.sourceSize = root.sourceSize
......@@ -148,6 +160,13 @@ Item {
onWidthChanged: startFadeSourceTimer()
onHeightChanged: startFadeSourceTimer()
// HACK prevent fades and transitions during startup
Timer {
id: startupTimer
interval: 100
running: true
}
Timer {
id: sourceSizeTimer
interval: 1000 // always delay reloading the image even when animations are turned off
......@@ -229,10 +248,11 @@ Item {
Rectangle {
id: backgroundColor
anchors.fill: parent
visible: ready && (currentImage.status === Image.Ready || otherImage.status === Image.Ready)
visible: currentImage.status === Image.Ready || otherImage.status === Image.Ready
color: wallpaper.configuration.Color
Behavior on color {
ColorAnimation { duration: units.longDuration }
enabled: !startupTimer.running
}
}
......
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