diff --git a/Helpers/Wallpapers.qml b/Helpers/Wallpapers.qml index 3febca8..c22920d 100644 --- a/Helpers/Wallpapers.qml +++ b/Helpers/Wallpapers.qml @@ -14,6 +14,7 @@ Searcher { property string actualCurrent: WallpaperPath.currentWallpaperPath readonly property string current: showPreview ? previewPath : actualCurrent property string previewPath + property bool recentlyChanged property bool showPreview: false function preview(path: string): void { diff --git a/Modules/Settings/Controls/WallpaperCropper.qml b/Modules/Settings/Controls/WallpaperCropper.qml index 7090ff5..a17acda 100644 --- a/Modules/Settings/Controls/WallpaperCropper.qml +++ b/Modules/Settings/Controls/WallpaperCropper.qml @@ -18,8 +18,8 @@ Item { property real displayY: (height - paintedHeight) * 0.5 property real scaleX: sourceW / displayW property real scaleY: sourceH / displayH - property real sourceH: sourceSize.height - property real sourceW: sourceSize.width + property real sourceH: Quickshell.screens[0].height + property real sourceW: Quickshell.screens[0].width anchors.fill: parent fillMode: Image.PreserveAspectFit @@ -85,6 +85,7 @@ Item { updateCrop(mouse.x, mouse.y); } onReleased: { + Wallpapers.recentlyChanged = false; Config.background.sourceClipX = cropRect.sourceRect.x; Config.background.sourceClipY = cropRect.sourceRect.y; Config.background.sourceClipW = cropRect.sourceRect.width; diff --git a/Modules/Wallpaper/WallBackground-old.qml b/Modules/Wallpaper/WallBackground-old.qml new file mode 100644 index 0000000..b8bb649 --- /dev/null +++ b/Modules/Wallpaper/WallBackground-old.qml @@ -0,0 +1,80 @@ +pragma ComponentBehavior: Bound + +import QtQuick +import qs.Components +import qs.Helpers +import qs.Config + +Item { + id: root + + property Image current: one + property string source: Wallpapers.current + + anchors.fill: parent + + Component.onCompleted: { + if (source) + Qt.callLater(() => one.update()); + } + onSourceChanged: { + if (!source) { + current = null; + } else if (current === one) { + two.update(); + } else { + one.update(); + } + } + + Img { + id: one + } + + Img { + id: two + } + + component Img: Image { + id: img + + function update(): void { + if (source === root.source) { + root.current = this; + } else { + source = root.source; + } + } + + anchors.fill: parent + asynchronous: true + fillMode: Image.PreserveAspectCrop + opacity: 0 + retainWhileLoading: true + scale: Wallpapers.showPreview ? 1 : 0.8 + sourceClipRect: Qt.rect(Config.background.sourceClipX, Config.background.sourceClipY, Config.background.sourceClipW, Config.background.sourceClipH) + + states: State { + name: "visible" + when: root.current === img + + PropertyChanges { + img.opacity: 1 + img.scale: 1 + } + } + transitions: Transition { + Anim { + duration: Config.background.wallFadeDuration + properties: "opacity,scale" + target: img + } + } + + onStatusChanged: { + if (status === Image.Ready) { + root.current = this; + } + } + } +} diff --git a/Modules/Wallpaper/WallBackground.qml b/Modules/Wallpaper/WallBackground.qml index b8bb649..9c95859 100644 --- a/Modules/Wallpaper/WallBackground.qml +++ b/Modules/Wallpaper/WallBackground.qml @@ -1,5 +1,6 @@ pragma ComponentBehavior: Bound +import Quickshell import QtQuick import qs.Components import qs.Helpers @@ -8,73 +9,34 @@ import qs.Config Item { id: root - property Image current: one + required property ShellScreen screen property string source: Wallpapers.current anchors.fill: parent - Component.onCompleted: { - if (source) - Qt.callLater(() => one.update()); - } - onSourceChanged: { - if (!source) { - current = null; - } else if (current === one) { - two.update(); - } else { - one.update(); - } - } - - Img { - id: one - } - - Img { - id: two - } - - component Img: Image { + Image { id: img - function update(): void { - if (source === root.source) { - root.current = this; - } else { - source = root.source; - } - } - anchors.fill: parent asynchronous: true fillMode: Image.PreserveAspectCrop - opacity: 0 + opacity: 1 retainWhileLoading: true - scale: Wallpapers.showPreview ? 1 : 0.8 - sourceClipRect: Qt.rect(Config.background.sourceClipX, Config.background.sourceClipY, Config.background.sourceClipW, Config.background.sourceClipH) + source: root.source + sourceClipRect: Wallpapers.recentlyChanged ? null : Qt.rect(Config.background.sourceClipX, Config.background.sourceClipY, Config.background.sourceClipW, Config.background.sourceClipH) + sourceSize.height: root.screen.height + sourceSize.width: root.screen.width - states: State { - name: "visible" - when: root.current === img - - PropertyChanges { - img.opacity: 1 - img.scale: 1 - } - } - transitions: Transition { - Anim { - duration: Config.background.wallFadeDuration - properties: "opacity,scale" - target: img - } - } - - onStatusChanged: { - if (status === Image.Ready) { - root.current = this; + onSourceChanged: { + if (Wallpapers.recentlyChanged) { + Config.background.sourceClipH = 0; + Config.background.sourceClipW = 0; + Config.background.sourceClipY = 0; + Config.background.sourceClipX = 0; + Config.background.zoom = 1.0; + Config.save(); } + Wallpapers.recentlyChanged = true; } } } diff --git a/Modules/Wallpaper/Wallpaper.qml b/Modules/Wallpaper/Wallpaper.qml index 44c44d2..9fac581 100644 --- a/Modules/Wallpaper/Wallpaper.qml +++ b/Modules/Wallpaper/Wallpaper.qml @@ -30,6 +30,7 @@ Loader { } WallBackground { + screen: root.screen } Loader {