Make the wallpaper picker a full-screen live preview
The screen previews the selected wallpaper with the real transition (TransitionStage, now shared with the desktop background) under a frosted sheet with a 16:9 thumbnail grid. Click or arrows preview, double-click or Enter applies and switches the picker's output directly, Space peeks, typing searches. Thumbnails mark outline wallpapers (wallfx status). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b6d0da4679
commit
de9b863f3f
7 files changed
+486
-221
No files matched your search
@@ -18,6 +18,7 @@ JSON object:
|
||||
{"kind": "colonies", "pending": true} when IMG is not
|
||||
processed yet, {"kind": "colonies"} when it has no subject.
|
||||
Uses only the standard library, so it answers at once.
|
||||
status IMG... {IMG: "outline" | "colonies" | "pending"}; standard library only.
|
||||
warm IMG... processes every image not cached yet; one warm at a time.
|
||||
outline IMG [--force]
|
||||
|
||||
@@ -225,7 +226,7 @@ def warm(paths):
|
||||
|
||||
|
||||
def main(argv):
|
||||
if len(argv) < 2 or argv[0] not in ("choose", "warm", "outline"):
|
||||
if len(argv) < 2 or argv[0] not in ("choose", "status", "warm", "outline"):
|
||||
print(__doc__, file=sys.stderr)
|
||||
return 2
|
||||
cmd, rest = argv[0], argv[1:]
|
||||
@@ -238,6 +239,14 @@ def main(argv):
|
||||
out = {"kind": "outline", "field": hit[0], "line": hit[1]}
|
||||
else:
|
||||
out = {"kind": "colonies", "pending": hit is None and bool(MODEL)}
|
||||
elif cmd == "status":
|
||||
out = {}
|
||||
for path in rest:
|
||||
try:
|
||||
hit = cached(path)
|
||||
except OSError:
|
||||
continue
|
||||
out[path] = "outline" if hit else ("pending" if hit is None else "colonies")
|
||||
elif not MODEL or not os.path.exists(MODEL):
|
||||
print("wallfx: GLASSMXRPH_WALLFX_MODEL is not set or missing", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
@@ -48,11 +48,18 @@ Singleton {
|
||||
next[output] = path;
|
||||
observed = next;
|
||||
}
|
||||
function apply(path) {
|
||||
// Output -> path that switches without a change, because the picker's live
|
||||
// preview already shows it there (see WallpaperBackground).
|
||||
property var instant: ({})
|
||||
function apply(path, instantOutput) {
|
||||
const outputs = selectedMonitor === "all" ? Quickshell.screens.map(s => s.name) : [monitor];
|
||||
if (!ConfigService.ready || !ConfigService.writable || !outputs.length || !outputs[0] || busy)
|
||||
return false;
|
||||
error = "";
|
||||
const nextInstant = {};
|
||||
if (instantOutput)
|
||||
nextInstant[instantOutput] = path;
|
||||
instant = nextInstant;
|
||||
prepareTransition(path);
|
||||
// Native rendering needs no provider round trip: decode once, then switch
|
||||
// every output in one write so their transitions start together.
|
||||
@@ -108,6 +115,7 @@ Singleton {
|
||||
if (result.ok) {
|
||||
root.images = result.images;
|
||||
root.warmOutlines(result.images.map(image => image.path));
|
||||
root.refreshOutlineStatus();
|
||||
root.notice = (result.notice || "") + (result.limited ? " Showing the first 1,000 images." : "");
|
||||
} else
|
||||
root.error = result.error;
|
||||
@@ -215,6 +223,34 @@ Singleton {
|
||||
Process {
|
||||
id: warmJob
|
||||
environment: ({LD_LIBRARY_PATH: null})
|
||||
onExited: root.refreshOutlineStatus()
|
||||
}
|
||||
// Path -> "outline", "colonies" or "pending", for the picker's badges.
|
||||
property var outlineStatus: ({})
|
||||
function refreshOutlineStatus() {
|
||||
if (!outlinesAvailable || !images.length)
|
||||
return;
|
||||
if (statusJob.running)
|
||||
return void (statusJob.again = true);
|
||||
statusJob.command = [wallfxPython, Quickshell.shellPath("helpers/wallfx.py"), "status"].concat(images.map(image => image.path));
|
||||
statusJob.running = true;
|
||||
}
|
||||
Process {
|
||||
id: statusJob
|
||||
property bool again: false
|
||||
environment: ({LD_LIBRARY_PATH: null})
|
||||
stdout: StdioCollector {
|
||||
id: statusOutput
|
||||
}
|
||||
onExited: {
|
||||
try {
|
||||
root.outlineStatus = JSON.parse(statusOutput.text);
|
||||
} catch (error) {}
|
||||
if (statusJob.again) {
|
||||
statusJob.again = false;
|
||||
Qt.callLater(root.refreshOutlineStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Native backgrounds report when their new image has decoded; the reveal
|
||||
// starts on every output together once all of them are ready.
|
||||
|
||||
@@ -116,10 +116,11 @@ Item {
|
||||
}
|
||||
function pickerQuery(text: string): void {input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperSearch").text=text;}
|
||||
function pickerSelect(index: int): bool {
|
||||
const view=input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperCarousel");
|
||||
view.positionViewAtIndex(index,ListView.Contain);input.wait(50);
|
||||
const view=input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperGrid");
|
||||
view.positionViewAtIndex(index,GridView.Contain);input.wait(50);
|
||||
const item=view.itemAtIndex(index);if(!item)return false;
|
||||
input.mouseClick(item,item.width/2,item.height/2);return true;
|
||||
// Click previews; double-click applies.
|
||||
input.mouseDoubleClickSequence(item,item.width/2,item.height/2);return true;
|
||||
}
|
||||
function pickerScreenshot(path: string): bool {return input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperPickerSurface").grabToImage(result=>result.saveToFile(path));}
|
||||
function geometry(name: string): string {
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import "../services"
|
||||
import "../theme"
|
||||
// A full-size wallpaper that changes with shaders/transition.frag: colonies, or
|
||||
// the new wallpaper's subject outline when helpers/wallfx.py has its maps.
|
||||
// The desktop background and the picker's live preview both draw with it.
|
||||
Item {
|
||||
id: root
|
||||
// The wallpaper to show. Changing it starts a change once the new image
|
||||
// (and its outline maps, if any) are loaded.
|
||||
property string path: ""
|
||||
// false: a change starts as soon as it is ready. true: it emits ready()
|
||||
// and waits for go(), so several outputs can start together.
|
||||
property bool waitForGo: false
|
||||
// Show the next path directly, without a change (consumed by that change).
|
||||
property bool instantNext: false
|
||||
signal loading()
|
||||
signal ready()
|
||||
// 0..1 while the new wallpaper takes over.
|
||||
property real progress: 0
|
||||
readonly property bool transitioning: incoming.source.toString() !== ""
|
||||
readonly property bool running: reveal.running
|
||||
readonly property string target: path ? "file://" + encodeURI(path).replace(/#/g, "%23").replace(/\?/g, "%3F") : ""
|
||||
// The first wallpaper (and reduced motion) appears directly; later changes
|
||||
// load into `incoming` and are revealed once decoded.
|
||||
onTargetChanged: {
|
||||
if (!shown.source.toString() || Theme.duration === 0 || instantNext) {
|
||||
instantNext = false;
|
||||
reveal.stop(); progress = 0; incoming.source = ""; shown.source = target;
|
||||
return;
|
||||
}
|
||||
// Mid-change: land on the wallpaper it was heading to (it is decoded and
|
||||
// cached), then head for the next one from there.
|
||||
if (reveal.running) {
|
||||
reveal.stop();
|
||||
shown.source = incoming.source;
|
||||
}
|
||||
progress = 0;
|
||||
if (target === shown.source.toString()) {
|
||||
incoming.source = "";
|
||||
return;
|
||||
}
|
||||
reported = false;
|
||||
loading();
|
||||
WallpaperService.prepareTransition(path, true);
|
||||
incomingPath = path;
|
||||
incoming.source = target;
|
||||
}
|
||||
Component.onCompleted: shown.source = target
|
||||
function settle() {
|
||||
if (!reveal.running && shown.status === Image.Ready && shown.source.toString() === incoming.source.toString())
|
||||
incoming.source = "";
|
||||
}
|
||||
Image {
|
||||
id: shown
|
||||
anchors.fill: parent
|
||||
sourceSize: Qt.size(root.width, root.height)
|
||||
asynchronous: true
|
||||
retainWhileLoading: true
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
// Drop the overlay only once the base layer shows the new image.
|
||||
onStatusChanged: root.settle()
|
||||
}
|
||||
// The incoming image and the outline maps are only textures: the shader
|
||||
// draws the change over `shown`.
|
||||
Image {
|
||||
id: incoming
|
||||
visible: false
|
||||
sourceSize: Qt.size(root.width, root.height)
|
||||
asynchronous: true
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
onStatusChanged: {
|
||||
if (status === Image.Error)
|
||||
incoming.source = "";
|
||||
else
|
||||
root.reportIfReady();
|
||||
}
|
||||
}
|
||||
// The outline plan for the incoming wallpaper (WallpaperService), once known.
|
||||
property string incomingPath: ""
|
||||
readonly property var plan: root.transitioning ? WallpaperService.transitions[root.incomingPath] : undefined
|
||||
readonly property bool wantsOutline: !!root.plan && root.plan.kind === "outline"
|
||||
readonly property bool outlineReady: root.wantsOutline && fieldMap.status === Image.Ready && lineMap.status === Image.Ready
|
||||
// Settled: colonies, outline maps loaded, or maps that failed (colonies then).
|
||||
readonly property bool planSettled: root.plan !== undefined && (!root.wantsOutline || root.outlineReady
|
||||
|| fieldMap.status === Image.Error || lineMap.status === Image.Error)
|
||||
onPlanSettledChanged: reportIfReady()
|
||||
property bool reported: false
|
||||
function reportIfReady() {
|
||||
if (reported || incoming.status !== Image.Ready || !incoming.source.toString() || !planSettled)
|
||||
return;
|
||||
reported = true;
|
||||
ready();
|
||||
if (!waitForGo)
|
||||
go();
|
||||
}
|
||||
// Starts the change if the new image is decoded. Without a settled plan
|
||||
// (the owner's fallback fired first) it uses colonies.
|
||||
function go() {
|
||||
if (incoming.status !== Image.Ready || !incoming.source.toString() || reveal.running || progress !== 0)
|
||||
return;
|
||||
seed = Math.random() * 100;
|
||||
ember = Theme.accentVivid;
|
||||
mode = outlineReady ? 1 : 0;
|
||||
reveal.duration = mode ? 2000 : 1800;
|
||||
reveal.restart();
|
||||
}
|
||||
// Maps hold numbers, not colours, at their own size; the shader interpolates.
|
||||
Image {
|
||||
id: fieldMap
|
||||
visible: false
|
||||
asynchronous: true
|
||||
cache: false
|
||||
source: root.wantsOutline ? "file://" + root.plan.field : ""
|
||||
}
|
||||
Image {
|
||||
id: lineMap
|
||||
visible: false
|
||||
asynchronous: true
|
||||
cache: false
|
||||
source: root.wantsOutline ? "file://" + root.plan.line : ""
|
||||
}
|
||||
// PreserveAspectCrop decodes to cover the item, so the texture can be
|
||||
// larger than the item on one axis: sample its centred window.
|
||||
function crop(img) {
|
||||
const iw = Math.max(img.implicitWidth, 1), ih = Math.max(img.implicitHeight, 1);
|
||||
const s = Math.max(root.width / iw, root.height / ih);
|
||||
const w = root.width / (iw * s), h = root.height / (ih * s);
|
||||
return Qt.vector4d((1 - w) / 2, (1 - h) / 2, w, h);
|
||||
}
|
||||
ShaderEffect {
|
||||
anchors.fill: parent
|
||||
visible: root.transitioning && incoming.status === Image.Ready && root.progress > 0
|
||||
property var oldTex: shown
|
||||
property var newTex: incoming
|
||||
property real t: root.progress
|
||||
property real sw: width
|
||||
property real sh: height
|
||||
property real cell: 4
|
||||
property real glow: 0.9
|
||||
property real seed: root.seed
|
||||
property vector4d cropOld: root.crop(shown)
|
||||
property vector4d cropNew: root.crop(incoming)
|
||||
property color ember: root.ember
|
||||
property color ink: Theme.text
|
||||
property real mode: root.mode
|
||||
// Unused in colonies mode, but every sampler needs a texture.
|
||||
property var fieldTex: root.outlineReady ? fieldMap : incoming
|
||||
property var lineTex: root.outlineReady ? lineMap : incoming
|
||||
property real fw: Math.max(fieldMap.implicitWidth, 1)
|
||||
property real fh: Math.max(fieldMap.implicitHeight, 1)
|
||||
property real lineW: 1.5
|
||||
property real sdRange: 16
|
||||
fragmentShader: Qt.resolvedUrl("shaders/transition.frag.qsb")
|
||||
}
|
||||
// Captured when a change starts, so the burn keeps its colour even if the
|
||||
// palette regenerates from the new wallpaper halfway through.
|
||||
property real seed: 0
|
||||
property color ember: Theme.accentVivid
|
||||
property real mode: 0
|
||||
NumberAnimation {
|
||||
id: reveal
|
||||
target: root
|
||||
property: "progress"
|
||||
from: 0
|
||||
to: 1
|
||||
// Linear time: the shader eases its own phases. Set per change.
|
||||
easing.type: Easing.Linear
|
||||
onFinished: {
|
||||
shown.source = incoming.source;
|
||||
Qt.callLater(root.settle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,137 +16,23 @@ PanelWindow {
|
||||
WlrLayershell.namespace:"glassMxrph-wallpaper"
|
||||
mask:Region {}
|
||||
readonly property string targetPath:ConfigService.ready ? (ConfigService.data.wallpaper.byMonitor[root.modelData.name] || "") : ""
|
||||
readonly property string target:targetPath ? "file://"+encodeURI(targetPath).replace(/#/g,"%23").replace(/\?/g,"%3F") : ""
|
||||
// 0..1 while the new wallpaper takes over (shaders/transition.frag).
|
||||
property real progress:0
|
||||
readonly property bool transitioning:incoming.source.toString()!==""
|
||||
// The first wallpaper (and reduced motion) appears directly; later changes
|
||||
// load into `incoming` and are revealed once decoded.
|
||||
onTargetChanged:{
|
||||
if(!shown.source.toString() || Theme.duration===0) {reveal.stop();incoming.source="";shown.source=target;}
|
||||
else if(target===shown.source.toString()) {reveal.stop();incoming.source="";}
|
||||
else {
|
||||
reveal.stop();progress=0;reported=false;
|
||||
WallpaperService.revealLoading(modelData.name);
|
||||
WallpaperService.prepareTransition(targetPath,true);
|
||||
incomingPath=targetPath;incoming.source=target;
|
||||
}
|
||||
}
|
||||
Component.onCompleted:shown.source=target
|
||||
function settle() {
|
||||
if(!reveal.running && shown.status===Image.Ready && shown.source.toString()===incoming.source.toString())incoming.source="";
|
||||
}
|
||||
Image {
|
||||
id:shown
|
||||
TransitionStage {
|
||||
id:stage
|
||||
anchors.fill:parent
|
||||
sourceSize:Qt.size(parent.width,parent.height)
|
||||
asynchronous:true
|
||||
retainWhileLoading:true
|
||||
fillMode:Image.PreserveAspectCrop
|
||||
// Drop the overlay only once the base layer shows the new image.
|
||||
onStatusChanged:root.settle()
|
||||
// Every output starts its change together (WallpaperService.revealSerial).
|
||||
waitForGo:true
|
||||
onLoading:WallpaperService.revealLoading(root.modelData.name)
|
||||
onReady:WallpaperService.revealReady(root.modelData.name)
|
||||
}
|
||||
// The incoming image and the outline maps are only textures: the shader
|
||||
// draws the change over `shown`.
|
||||
Image {
|
||||
id:incoming
|
||||
visible:false
|
||||
sourceSize:Qt.size(root.width,root.height)
|
||||
asynchronous:true
|
||||
fillMode:Image.PreserveAspectCrop
|
||||
onStatusChanged:{
|
||||
if(status===Image.Error)incoming.source="";
|
||||
else root.reportIfReady();
|
||||
}
|
||||
// The picker's live preview already shows the wallpaper it applies on its
|
||||
// own output, so that output switches directly underneath it.
|
||||
onTargetPathChanged:{
|
||||
stage.instantNext=WallpaperService.instant[root.modelData.name]===targetPath;
|
||||
stage.path=targetPath;
|
||||
}
|
||||
// The outline plan for the incoming wallpaper (WallpaperService), once known.
|
||||
property string incomingPath:""
|
||||
readonly property var plan:root.transitioning ? WallpaperService.transitions[root.incomingPath] : undefined
|
||||
readonly property bool wantsOutline:!!root.plan && root.plan.kind==="outline"
|
||||
readonly property bool outlineReady:root.wantsOutline && fieldMap.status===Image.Ready && lineMap.status===Image.Ready
|
||||
// Settled: colonies, outline maps loaded, or maps that failed (colonies then).
|
||||
readonly property bool planSettled:root.plan!==undefined && (!root.wantsOutline || root.outlineReady
|
||||
|| fieldMap.status===Image.Error || lineMap.status===Image.Error)
|
||||
onPlanSettledChanged:reportIfReady()
|
||||
property bool reported:false
|
||||
// Ready once the image is decoded and the plan settled. The service's
|
||||
// fallback starts the change anyway if this takes too long; it then uses
|
||||
// colonies unless the maps happen to be in.
|
||||
function reportIfReady() {
|
||||
if(reported || incoming.status!==Image.Ready || !incoming.source.toString() || !planSettled)return;
|
||||
reported=true;
|
||||
WallpaperService.revealReady(root.modelData.name);
|
||||
}
|
||||
// Maps hold numbers, not colours, at their own size; the shader interpolates.
|
||||
Image {
|
||||
id:fieldMap
|
||||
visible:false
|
||||
asynchronous:true
|
||||
cache:false
|
||||
source:root.wantsOutline ? "file://"+root.plan.field : ""
|
||||
}
|
||||
Image {
|
||||
id:lineMap
|
||||
visible:false
|
||||
asynchronous:true
|
||||
cache:false
|
||||
source:root.wantsOutline ? "file://"+root.plan.line : ""
|
||||
}
|
||||
// PreserveAspectCrop decodes to cover the output, so the texture can be
|
||||
// larger than the item on one axis: sample its centred window.
|
||||
function crop(img) {
|
||||
const iw=Math.max(img.implicitWidth,1),ih=Math.max(img.implicitHeight,1);
|
||||
const s=Math.max(root.width/iw,root.height/ih);
|
||||
const w=root.width/(iw*s),h=root.height/(ih*s);
|
||||
return Qt.vector4d((1-w)/2,(1-h)/2,w,h);
|
||||
}
|
||||
ShaderEffect {
|
||||
anchors.fill:parent
|
||||
visible:root.transitioning && incoming.status===Image.Ready && root.progress>0
|
||||
property var oldTex:shown
|
||||
property var newTex:incoming
|
||||
property real t:root.progress
|
||||
property real sw:width
|
||||
property real sh:height
|
||||
property real cell:4
|
||||
property real glow:0.9
|
||||
property real seed:root.seed
|
||||
property vector4d cropOld:root.crop(shown)
|
||||
property vector4d cropNew:root.crop(incoming)
|
||||
property color ember:root.ember
|
||||
property color ink:Theme.text
|
||||
property real mode:root.mode
|
||||
// Unused in colonies mode, but every sampler needs a texture.
|
||||
property var fieldTex:root.outlineReady ? fieldMap : incoming
|
||||
property var lineTex:root.outlineReady ? lineMap : incoming
|
||||
property real fw:Math.max(fieldMap.implicitWidth,1)
|
||||
property real fh:Math.max(fieldMap.implicitHeight,1)
|
||||
property real lineW:1.5
|
||||
property real sdRange:16
|
||||
fragmentShader:Qt.resolvedUrl("shaders/transition.frag.qsb")
|
||||
}
|
||||
// Captured when a change starts, so the burn keeps its colour even if the
|
||||
// palette regenerates from the new wallpaper halfway through.
|
||||
property real seed:0
|
||||
property color ember:Theme.accentVivid
|
||||
property real mode:0
|
||||
Component.onCompleted:stage.path=targetPath
|
||||
Connections {
|
||||
target:WallpaperService
|
||||
function onRevealSerialChanged() {
|
||||
if(incoming.status===Image.Ready && incoming.source.toString() && !reveal.running && root.progress===0) {
|
||||
root.seed=Math.random()*100;root.ember=Theme.accentVivid;
|
||||
root.mode=root.outlineReady ? 1 : 0;
|
||||
reveal.duration=root.mode ? 2000 : 1800;
|
||||
reveal.restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
NumberAnimation {
|
||||
id:reveal
|
||||
target:root;property:"progress"
|
||||
from:0;to:1
|
||||
// Linear time: the shader eases its own phases. Set per change.
|
||||
easing.type:Easing.Linear
|
||||
onFinished:{shown.source=incoming.source;Qt.callLater(root.settle);}
|
||||
function onRevealSerialChanged() {stage.go();}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Effects
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
@@ -9,115 +10,272 @@ import "../services"
|
||||
import "../core"
|
||||
import "../theme"
|
||||
// qmllint disable uncreatable-type
|
||||
// Full-screen wallpaper picker. The whole screen is a live preview: moving the
|
||||
// selection plays the real change (TransitionStage) to that wallpaper, and the
|
||||
// grid sits on a frosted sheet over it. Enter applies (the desktop under the
|
||||
// preview switches directly, see WallpaperBackground), Esc leaves everything as
|
||||
// it was, Space hides the sheet to look at the preview alone.
|
||||
PanelWindow {
|
||||
id:root
|
||||
screen:ScreenService.current(ShellState.wallpaperScreen)
|
||||
// Hangs from the middle of the bar as a drawer; the layer starts at the
|
||||
// screen top so the bar join is inside its box.
|
||||
anchors {top:true}
|
||||
readonly property real screenWidth:screen ? screen.width : 1920
|
||||
readonly property real screenHeight:screen ? screen.height : 1080
|
||||
implicitWidth:Math.round(surface.width)
|
||||
implicitHeight:Math.round(BarDrawers.bottom+surface.contentHeight)
|
||||
visible:ShellState.wallpaperPickerOpen || surface.shown
|
||||
anchors {top:true;bottom:true;left:true;right:true}
|
||||
readonly property string screenName:screen ? screen.name : ""
|
||||
readonly property bool open:ShellState.wallpaperPickerOpen
|
||||
visible:open || content.opacity>0
|
||||
color:Theme.transparent
|
||||
exclusionMode:ExclusionMode.Ignore
|
||||
WlrLayershell.namespace:"glassMxrph-wallpaper-picker"
|
||||
WlrLayershell.layer:WlrLayer.Overlay
|
||||
WlrLayershell.keyboardFocus:ShellState.wallpaperPickerOpen ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
|
||||
WlrLayershell.keyboardFocus:open ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
|
||||
Component.onCompleted:ShellState.wallpaperWindow=root
|
||||
Component.onDestruction:ShellState.wallpaperWindow=null
|
||||
|
||||
property string filter:"all"
|
||||
readonly property var results:WallpaperService.images.filter(i=>(filter!=="history" || ConfigService.data.wallpaper.history.includes(i.path)) && (!search.text || i.name.toLowerCase().includes(search.text.toLowerCase())))
|
||||
// A vertical mouse wheel steps through the horizontal strip, one tile per notch.
|
||||
// Handled on the tiles: their MouseAreas take wheel events before the ListView.
|
||||
property real wheelPending:0
|
||||
function wheelStep(event) {
|
||||
wheelPending+=event.angleDelta.y || event.angleDelta.x;
|
||||
const steps=Math.trunc(wheelPending/120);
|
||||
if(!steps)return;
|
||||
wheelPending-=steps*120;
|
||||
view.currentIndex=Math.max(0,Math.min(view.count-1,view.currentIndex-steps));
|
||||
// The selection lives here, not in the view: a rescan or a new search
|
||||
// replaces the model, and the view would fall back to the first tile.
|
||||
property string selectedPath:""
|
||||
readonly property var selected:results.find(i=>i.path===selectedPath) || null
|
||||
property bool peek:false
|
||||
property string applying:""
|
||||
readonly property string desktopPath:ConfigService.ready ? (ConfigService.data.wallpaper.byMonitor[root.screenName] || WallpaperService.currentPath) : ""
|
||||
|
||||
function select(index) {
|
||||
if(index<0 || index>=results.length)return;
|
||||
view.currentIndex=index;
|
||||
selectedPath=results[index].path;
|
||||
}
|
||||
function applyCurrent() {if(root.results[view.currentIndex])WallpaperService.apply(root.results[view.currentIndex].path);}
|
||||
Connections {
|
||||
target:ShellState
|
||||
function onWallpaperPickerOpenChanged() {
|
||||
if(ShellState.wallpaperPickerOpen) {
|
||||
WallpaperService.refresh();WallpaperService.scan();
|
||||
Qt.callLater(()=>view.forceActiveFocus());
|
||||
}
|
||||
function syncSelection() {
|
||||
const index=results.findIndex(i=>i.path===selectedPath);
|
||||
if(index>=0)view.currentIndex=index;
|
||||
else if(results.length)select(0);
|
||||
}
|
||||
onResultsChanged:Qt.callLater(syncSelection)
|
||||
// Previews follow the selection once it rests, so sweeping across the grid
|
||||
// does not start a change per tile.
|
||||
onSelectedPathChanged:previewDelay.restart()
|
||||
Timer {id:previewDelay;interval:200;onTriggered:if(root.open && root.selectedPath)preview.path=root.selectedPath}
|
||||
|
||||
function applySelected() {
|
||||
if(!selectedPath || applying)return;
|
||||
// Enter before the preview caught up: show it directly, the desktop is about to.
|
||||
if(preview.path!==selectedPath) {previewDelay.stop();preview.instantNext=true;preview.path=selectedPath;}
|
||||
if(WallpaperService.apply(selectedPath,root.screenName)) {applying=selectedPath;applyGuard.restart();}
|
||||
}
|
||||
// Close once this output's desktop shows the applied wallpaper (a moment to
|
||||
// decode it), or after a while regardless.
|
||||
readonly property bool applied:applying!=="" && desktopPath===applying
|
||||
onAppliedChanged:if(applied)closeDelay.restart()
|
||||
Timer {id:closeDelay;interval:150;onTriggered:root.close()}
|
||||
Timer {id:applyGuard;interval:1500;onTriggered:if(root.applying)root.close()}
|
||||
function close() {applying="";ShellState.wallpaperPickerOpen=false;}
|
||||
|
||||
onOpenChanged:{
|
||||
if(open) {
|
||||
applying="";peek=false;
|
||||
WallpaperService.refresh();WallpaperService.scan();
|
||||
preview.instantNext=true;
|
||||
preview.path=desktopPath;
|
||||
selectedPath=desktopPath;
|
||||
syncSelection();
|
||||
view.positionViewAtIndex(Math.max(0,view.currentIndex),GridView.Center);
|
||||
Qt.callLater(()=>view.forceActiveFocus());
|
||||
}
|
||||
}
|
||||
// Exclusive focus routes outside clicks here (see ControlCenter).
|
||||
MouseArea {x:-20000;y:-20000;width:40000;height:40000;onPressed:ShellState.wallpaperPickerOpen=false}
|
||||
BarDrawer {
|
||||
id:surface
|
||||
|
||||
Item {
|
||||
id:content
|
||||
objectName:"wallpaperPickerSurface"
|
||||
y:BarDrawers.bottom
|
||||
open:ShellState.wallpaperPickerOpen
|
||||
contentWidth:Math.min(1240,root.screenWidth-2*(BarDrawers.margin+BarDrawers.radius+ear))
|
||||
contentHeight:Math.min(590,root.screenHeight-BarDrawers.bottom-40)
|
||||
drawerId:"wallpaper"
|
||||
screenName:root.screen ? root.screen.name : ""
|
||||
screenX:(root.screenWidth-width)/2
|
||||
MouseArea {anchors.fill:parent}
|
||||
anchors.fill:parent
|
||||
opacity:root.open ? 1 : 0
|
||||
Behavior on opacity {NumberAnimation {duration:Theme.duration*1.2;easing.type:Easing.OutCubic}}
|
||||
// Release the preview's textures once fully closed.
|
||||
onOpacityChanged:if(opacity===0 && !root.open)preview.path=""
|
||||
|
||||
TransitionStage {
|
||||
id:preview
|
||||
anchors.fill:parent
|
||||
}
|
||||
MouseArea {anchors.fill:parent;onClicked:root.peek=!root.peek}
|
||||
|
||||
// Name and transition of the selection, over the preview.
|
||||
ColumnLayout {
|
||||
anchors.fill:parent;anchors.margins:22;spacing:18
|
||||
RowLayout {
|
||||
Layout.fillWidth:true
|
||||
Text {text:"Wallpapers";color:Theme.text;font.pixelSize:24;Layout.fillWidth:true}
|
||||
GlassComboBox {
|
||||
Layout.preferredWidth:160
|
||||
model:["all","primary"].concat(Quickshell.screens.map(s=>s.name))
|
||||
currentIndex:Math.max(0,model.indexOf(WallpaperService.selectedMonitor))
|
||||
onActivated:WallpaperService.selectedMonitor=currentText
|
||||
}
|
||||
GlassIconButton {text:"⚙";onClicked:ShellState.openSettings("wallpaper");Accessible.name:"Wallpaper settings"}
|
||||
GlassIconButton {text:"×";onClicked:ShellState.wallpaperPickerOpen=false;Accessible.name:"Close picker"}
|
||||
id:info
|
||||
x:56;y:48
|
||||
spacing:6
|
||||
opacity:root.selected ? 1 : 0
|
||||
Behavior on opacity {NumberAnimation {duration:Theme.duration}}
|
||||
layer.enabled:true
|
||||
layer.effect:MultiEffect {shadowEnabled:true;shadowBlur:0.8;shadowOpacity:0.7;shadowColor:"black";autoPaddingEnabled:true}
|
||||
Text {
|
||||
text:root.selected ? root.selected.name.replace(/\.[^.]+$/,"") : ""
|
||||
color:"white";font.pixelSize:34;font.weight:Font.DemiBold
|
||||
}
|
||||
RowLayout {
|
||||
GlassButton {text:"All";accented:root.filter==="all";onClicked:root.filter="all"}
|
||||
GlassButton {text:"History";accented:root.filter==="history";onClicked:root.filter="history"}
|
||||
GlassTextField {id:search;objectName:"wallpaperSearch";Layout.fillWidth:true;placeholderText:"Search wallpapers…";onTextChanged:view.currentIndex=0;Keys.onEscapePressed:ShellState.wallpaperPickerOpen=false;Keys.onDownPressed:view.forceActiveFocus()}
|
||||
GlassIconButton {text:"↻";onClicked:WallpaperService.scan();Accessible.name:"Refresh wallpapers"}
|
||||
Text {
|
||||
readonly property string status:root.selected ? (WallpaperService.outlineStatus[root.selected.path] || "") : ""
|
||||
text:(status==="outline" ? "✦ Outline transition" : status==="pending" ? "Preparing outline…" : "Colonies transition")
|
||||
+" · "+(view.currentIndex+1)+" / "+root.results.length
|
||||
+(root.selected && root.selected.path===root.desktopPath ? " · current" : "")
|
||||
color:Qt.alpha("white",0.85);font.pixelSize:15
|
||||
}
|
||||
ListView {
|
||||
id:view
|
||||
objectName:"wallpaperCarousel"
|
||||
Layout.fillWidth:true;Layout.fillHeight:true
|
||||
orientation:ListView.Horizontal
|
||||
spacing:14
|
||||
clip:true
|
||||
model:root.results
|
||||
snapMode:ListView.SnapToItem
|
||||
boundsBehavior:Flickable.StopAtBounds
|
||||
highlightMoveDuration:Theme.duration
|
||||
preferredHighlightBegin:width/2-125
|
||||
preferredHighlightEnd:width/2+125
|
||||
highlightRangeMode:ListView.ApplyRange
|
||||
keyNavigationEnabled:true
|
||||
ScrollBar.horizontal:ScrollBar {}
|
||||
Keys.onReturnPressed:root.applyCurrent()
|
||||
Keys.onEnterPressed:root.applyCurrent()
|
||||
Keys.onEscapePressed:ShellState.wallpaperPickerOpen=false
|
||||
delegate:GlassPanel {
|
||||
id:tile
|
||||
required property var modelData
|
||||
required property int index
|
||||
width:250;height:view.height-10
|
||||
radius:18
|
||||
border.width:2
|
||||
border.color:view.currentIndex===index ? Theme.accent : Theme.border
|
||||
Image {anchors.fill:parent;anchors.margins:6;source:tile.modelData.url;sourceSize:Qt.size(500,700);asynchronous:true;fillMode:Image.PreserveAspectCrop;clip:true}
|
||||
Rectangle {anchors.bottom:parent.bottom;anchors.left:parent.left;anchors.right:parent.right;anchors.margins:6;height:42;color:Qt.alpha(Theme.surface,0.85)
|
||||
Text {anchors.fill:parent;anchors.margins:10;text:(WallpaperService.currentPath===tile.modelData.path?"✓ ":"")+tile.modelData.name;color:Theme.text;elide:Text.ElideMiddle}
|
||||
}
|
||||
|
||||
// Frosted sheet: a blurred copy of the preview behind it, so the glass
|
||||
// shows the wallpaper being previewed (the compositor's blur would show
|
||||
// what is under this window instead).
|
||||
Item {
|
||||
id:sheet
|
||||
width:parent.width-96
|
||||
height:Math.min(540,Math.round(parent.height*0.46))
|
||||
x:48
|
||||
y:root.peek || !root.open ? parent.height+16 : parent.height-height-36
|
||||
Behavior on y {NumberAnimation {duration:Theme.duration*1.4;easing.type:Easing.OutCubic}}
|
||||
ShaderEffectSource {
|
||||
id:sheetBackdrop
|
||||
sourceItem:preview
|
||||
sourceRect:Qt.rect(sheet.x,sheet.y,sheet.width,sheet.height)
|
||||
visible:false
|
||||
}
|
||||
Item {
|
||||
id:sheetMask
|
||||
anchors.fill:parent
|
||||
visible:false
|
||||
layer.enabled:true
|
||||
Rectangle {anchors.fill:parent;radius:28}
|
||||
}
|
||||
MultiEffect {
|
||||
anchors.fill:parent
|
||||
source:sheetBackdrop
|
||||
autoPaddingEnabled:false
|
||||
blurEnabled:true;blur:1;blurMax:64
|
||||
saturation:-0.1;brightness:-0.08
|
||||
maskEnabled:true;maskSource:sheetMask
|
||||
maskThresholdMin:0.5;maskSpreadAtMin:1
|
||||
}
|
||||
Rectangle {anchors.fill:parent;radius:28;color:Qt.alpha(Theme.tint,0.38);border.width:1;border.color:Theme.border}
|
||||
MouseArea {anchors.fill:parent}
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill:parent;anchors.margins:22;spacing:14
|
||||
RowLayout {
|
||||
Layout.fillWidth:true;spacing:10
|
||||
Text {text:"Wallpapers";color:Theme.text;font.pixelSize:22}
|
||||
GlassButton {text:"All";accented:root.filter==="all";onClicked:root.filter="all"}
|
||||
GlassButton {text:"History";accented:root.filter==="history";onClicked:root.filter="history"}
|
||||
GlassTextField {
|
||||
id:search;objectName:"wallpaperSearch"
|
||||
Layout.fillWidth:true;placeholderText:"Search wallpapers…"
|
||||
Keys.onEscapePressed:root.close()
|
||||
Keys.onDownPressed:view.forceActiveFocus()
|
||||
Keys.onReturnPressed:view.forceActiveFocus()
|
||||
}
|
||||
MouseArea {anchors.fill:parent;onClicked:{view.currentIndex=tile.index;view.forceActiveFocus();WallpaperService.apply(tile.modelData.path);}onWheel:event=>root.wheelStep(event)}
|
||||
GlassComboBox {
|
||||
Layout.preferredWidth:150
|
||||
model:["all","primary"].concat(Quickshell.screens.map(s=>s.name))
|
||||
currentIndex:Math.max(0,model.indexOf(WallpaperService.selectedMonitor))
|
||||
onActivated:WallpaperService.selectedMonitor=currentText
|
||||
}
|
||||
GlassIconButton {text:"↻";onClicked:WallpaperService.scan();Accessible.name:"Refresh wallpapers"}
|
||||
GlassIconButton {text:"⚙";onClicked:ShellState.openSettings("wallpaper");Accessible.name:"Wallpaper settings"}
|
||||
GlassIconButton {text:"×";onClicked:root.close();Accessible.name:"Close picker"}
|
||||
}
|
||||
GridView {
|
||||
id:view
|
||||
objectName:"wallpaperGrid"
|
||||
Layout.fillWidth:true;Layout.fillHeight:true
|
||||
readonly property int columns:Math.max(3,Math.floor(width/300))
|
||||
cellWidth:Math.floor(width/columns)
|
||||
cellHeight:Math.round((cellWidth-16)*9/16)+16
|
||||
clip:true
|
||||
model:root.results
|
||||
boundsBehavior:Flickable.StopAtBounds
|
||||
keyNavigationEnabled:true
|
||||
ScrollBar.vertical:ScrollBar {}
|
||||
onCurrentIndexChanged:if(root.results[currentIndex])root.selectedPath=root.results[currentIndex].path
|
||||
Keys.onReturnPressed:root.applySelected()
|
||||
Keys.onEnterPressed:root.applySelected()
|
||||
Keys.onEscapePressed:root.close()
|
||||
Keys.onSpacePressed:root.peek=!root.peek
|
||||
// Typing goes to the search field.
|
||||
Keys.onPressed:event=>{
|
||||
if(event.text && event.text.trim() && !(event.modifiers&(Qt.ControlModifier|Qt.AltModifier|Qt.MetaModifier))) {
|
||||
search.forceActiveFocus();search.text+=event.text;event.accepted=true;
|
||||
}
|
||||
}
|
||||
// One rounded mask shared by every thumbnail (they are all the same size).
|
||||
Item {
|
||||
id:tileMask
|
||||
width:view.cellWidth-16;height:view.cellHeight-16
|
||||
visible:false
|
||||
layer.enabled:true
|
||||
Rectangle {anchors.fill:parent;radius:14}
|
||||
}
|
||||
delegate:Item {
|
||||
id:cell
|
||||
required property var modelData
|
||||
required property int index
|
||||
readonly property bool current:view.currentIndex===index
|
||||
width:view.cellWidth;height:view.cellHeight
|
||||
Item {
|
||||
anchors.fill:parent;anchors.margins:8
|
||||
scale:cell.current ? 1 : (tileArea.containsMouse ? 0.98 : 0.95)
|
||||
Behavior on scale {NumberAnimation {duration:Theme.duration;easing.type:Easing.OutCubic}}
|
||||
Image {
|
||||
anchors.fill:parent
|
||||
source:cell.modelData.url
|
||||
sourceSize:Qt.size(480,270)
|
||||
asynchronous:true
|
||||
fillMode:Image.PreserveAspectCrop
|
||||
opacity:status===Image.Ready ? (cell.current ? 1 : 0.82) : 0
|
||||
Behavior on opacity {NumberAnimation {duration:Theme.duration}}
|
||||
layer.enabled:true
|
||||
layer.effect:MultiEffect {maskEnabled:true;maskSource:tileMask;maskThresholdMin:0.5;maskSpreadAtMin:1}
|
||||
}
|
||||
Rectangle {
|
||||
anchors.fill:parent;radius:14;color:"transparent"
|
||||
border.width:cell.current ? 3 : 1
|
||||
border.color:cell.current ? Theme.accent : Qt.alpha("white",0.16)
|
||||
}
|
||||
Row {
|
||||
anchors.top:parent.top;anchors.right:parent.right;anchors.margins:8;spacing:6
|
||||
Repeater {
|
||||
model:[WallpaperService.outlineStatus[cell.modelData.path]==="outline" ? "✦" : "",
|
||||
cell.modelData.path===root.desktopPath ? "✓" : ""].filter(s=>s)
|
||||
delegate:Rectangle {
|
||||
required property string modelData
|
||||
width:24;height:24;radius:12
|
||||
color:Qt.alpha("black",0.55)
|
||||
Text {anchors.centerIn:parent;text:parent.modelData;color:"white";font.pixelSize:13}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Click previews, double-click applies.
|
||||
MouseArea {
|
||||
id:tileArea
|
||||
anchors.fill:parent
|
||||
hoverEnabled:true
|
||||
onClicked:{root.select(cell.index);view.forceActiveFocus();}
|
||||
onDoubleClicked:{root.select(cell.index);root.applySelected();}
|
||||
}
|
||||
}
|
||||
}
|
||||
Text {visible:!root.results.length;text:WallpaperService.scanning ? "Loading wallpapers…" : "No wallpapers here. Choose a folder in Wallpaper settings.";color:Theme.textSecondary;Layout.fillWidth:true;wrapMode:Text.Wrap}
|
||||
Text {
|
||||
text:WallpaperService.error || (root.applying ? "Applying wallpaper…" : "Click or arrows preview · Double-click or Enter apply · Space peek · type to search · Esc close")
|
||||
color:WallpaperService.error ? Theme.urgent : Theme.textSecondary
|
||||
Layout.fillWidth:true;elide:Text.ElideRight
|
||||
}
|
||||
}
|
||||
Text {visible:!root.results.length;text:WallpaperService.scanning ? "Loading wallpapers…" : "No wallpapers here. Choose a folder in Wallpaper settings.";color:Theme.textSecondary;Layout.fillWidth:true;wrapMode:Text.Wrap}
|
||||
Text {text:WallpaperService.error || (WallpaperService.busy?"Applying wallpaper…":"Click or ← → and Enter to apply · Esc Close");color:WallpaperService.error?Theme.urgent:Theme.textSecondary;Layout.fillWidth:true;wrapMode:Text.Wrap}
|
||||
}
|
||||
// While peeking, a click or any key brings the sheet back.
|
||||
Text {
|
||||
anchors.bottom:parent.bottom;anchors.horizontalCenter:parent.horizontalCenter;anchors.bottomMargin:28
|
||||
visible:root.peek && root.open
|
||||
text:"Space to show wallpapers · Enter apply · Esc close"
|
||||
color:"white";font.pixelSize:14
|
||||
layer.enabled:true
|
||||
layer.effect:MultiEffect {shadowEnabled:true;shadowBlur:0.6;shadowOpacity:0.8;shadowColor:"black"}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user