1.7 KiB · text History 0fc5cce
import QtQuick
import org.kde.plasma.plasmoid
import "schedule.js" as Schedule

WallpaperItem {
    id: root

    readonly property var cfg: root.configuration
    property var scheme: Schedule.palette(cfg, new Date())

    function refresh() {
        scheme = Schedule.palette(cfg, new Date())
    }

    // The sun moves slowly enough that once a minute is smooth, and the
    // Field eases between the steps.
    Timer {
        running: root.cfg.ThemeMode === "sun"
        interval: 60000
        repeat: true
        onTriggered: root.refresh()
    }

    Connections {
        target: root.cfg
        function onValueChanged() { root.refresh() }
    }

    Field {
        anchors.fill: parent
        // Following the sun, the phases' patterns blend as their themes
        // do; the mixture moves once a minute and Field eases the steps.
        pattern: root.cfg.ThemeMode === "sun" ? "mix" : root.cfg.Pattern
        mixture: root.scheme.patterns
        fadeFrom: root.cfg.FadeFrom
        fadeTo: root.cfg.FadeTo
        bokehLights: root.cfg.BokehLights
        foreground: root.cfg.ForegroundBokeh
        glints: root.cfg.Glints
        breathing: root.cfg.Breathing
        grain: root.cfg.Grain
        dither: root.cfg.Dither
        wordmarkOpacity: root.cfg.WordmarkOpacity
        wordmarkGlow: root.cfg.WordmarkGlow
        speed: root.cfg.Speed
        frameRate: root.cfg.FrameRate
        wordmark: root.cfg.Wordmark
        base: root.scheme.base
        deep: root.scheme.deep
        ink: root.scheme.ink
        tone: root.scheme.tone

        // Lets Plasma re-derive its accent colour when the palette moves.
        onBaseChanged: root.accentColorChanged()
    }
}