Show wallpapers as a justified gallery in the picker drawer

Back to the drawer picker, now with justified rows: each thumbnail keeps
its aspect ratio (read from the file header by the scan) and every row
fills the width. Arrows move in two dimensions, click or Enter applies,
✦ marks outline wallpapers. Drops the full-screen preview picker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mxandClaude Opus 5.5 committed 2026-11-08 22:57:08 +01:00
1 parent 2a41cde6f5
commit ebace10767
7 files changed
+240 -278

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@ Open Settings → Wallpaper → Open wallpaper picker, or run:
./scripts/glassmxrph wallpaper ./scripts/glassmxrph wallpaper
``` ```
The picker covers the screen with a live preview of the selected wallpaper and a grid of thumbnails on a frosted sheet. Selecting a wallpaper (click or arrow keys) plays the real transition to it in the preview; Enter or double-click applies it, and the desktop under the preview switches directly while other outputs play the transition. Space hides the sheet to look at the preview alone, typing searches, and Escape closes without changing anything. ✦ marks wallpapers whose subject outline is drawn first. History records the last 50 selections. The picker drawer shows the wallpapers as a justified gallery: every thumbnail keeps its own aspect ratio and each row fills the width. Search local images, select an output, browse with the arrow keys and apply with Enter or a click. ✦ marks wallpapers whose subject outline is drawn first when changing to them. History records the last 50 selections. Escape or an outside click closes it.
Configure image directories in Wallpaper settings; the default search directory is ~/Pictures/Wallpapers. Select the Native backend when replacing Serpantinum. New configurations default to Native; existing explicit backend preferences are preserved. Configure image directories in Wallpaper settings; the default search directory is ~/Pictures/Wallpapers. Select the Native backend when replacing Serpantinum. New configurations default to Native; existing explicit backend preferences are preserved.
+37 -1
View File
@@ -92,6 +92,41 @@ def apply(req):
else:raise ValueError('No active wallpaper provider') else:raise ValueError('No active wallpaper provider')
return {'backend':backend,'path':str(path),'providerPath':str(path)} return {'backend':backend,'path':str(path),'providerPath':str(path)}
def image_size(path):
"""(width, height) from the file header, or None. Standard library only:
the picker lays thumbnails out by aspect ratio before any is decoded."""
import struct
try:
with open(path,'rb') as f:
head=f.read(32)
if head[:8]==b'\x89PNG\r\n\x1a\n':
return struct.unpack('>II',head[16:24])
if head[:2]==b'BM':
w,h=struct.unpack('<ii',head[18:26]);return (abs(w),abs(h))
if head[:4]==b'RIFF' and head[8:12]==b'WEBP':
kind=head[12:16]
if kind==b'VP8 ':
w,h=struct.unpack('<HH',head[26:30]);return (w&0x3fff,h&0x3fff)
if kind==b'VP8L':
b=head[21:25];return (1+(((b[1]&0x3f)<<8)|b[0]),1+(((b[3]&0xf)<<10)|(b[2]<<2)|((b[1]&0xc0)>>6)))
if kind==b'VP8X':
return (1+int.from_bytes(head[24:27],'little'),1+int.from_bytes(head[27:30],'little'))
return None
if head[:2]==b'\xff\xd8':
f.seek(2)
while True:
marker=f.read(2)
if len(marker)<2 or marker[0]!=0xff:return None
while marker[1]==0xff:marker=marker[:1]+f.read(1)
if marker[1] in (0xd8,0x01) or 0xd0<=marker[1]<=0xd7:continue
length=struct.unpack('>H',f.read(2))[0]
if marker[1] in (0xc0,0xc1,0xc2,0xc3,0xc5,0xc6,0xc7,0xc9,0xca,0xcb,0xcd,0xce,0xcf):
h,w=struct.unpack('>xHH',f.read(5));return (w,h)
f.seek(length-2,1)
except (OSError,struct.error):
return None
return None
def scan(req): def scan(req):
found={};errors=[] found={};errors=[]
for directory in (req.get('directories') or [str(Path.home()/'Pictures/Wallpapers')]): for directory in (req.get('directories') or [str(Path.home()/'Pictures/Wallpapers')]):
@@ -99,7 +134,8 @@ def scan(req):
try: try:
for entry in base.iterdir(): for entry in base.iterdir():
if entry.is_file() and entry.suffix.lower() in IMAGES: if entry.is_file() and entry.suffix.lower() in IMAGES:
resolved=entry.resolve();found[str(resolved)]={'path':str(resolved),'url':resolved.as_uri(),'name':entry.name} resolved=entry.resolve();size=image_size(resolved)
found[str(resolved)]={'path':str(resolved),'url':resolved.as_uri(),'name':entry.name,'width':size[0] if size else 0,'height':size[1] if size else 0}
if len(found)>=1000:break if len(found)>=1000:break
except OSError as error:errors.append(str(error)) except OSError as error:errors.append(str(error))
if len(found)>=1000:break if len(found)>=1000:break
+1 -8
View File
@@ -48,18 +48,11 @@ Singleton {
next[output] = path; next[output] = path;
observed = next; observed = next;
} }
// Output -> path that switches without a change, because the picker's live function apply(path) {
// 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]; const outputs = selectedMonitor === "all" ? Quickshell.screens.map(s => s.name) : [monitor];
if (!ConfigService.ready || !ConfigService.writable || !outputs.length || !outputs[0] || busy) if (!ConfigService.ready || !ConfigService.writable || !outputs.length || !outputs[0] || busy)
return false; return false;
error = ""; error = "";
const nextInstant = {};
if (instantOutput)
nextInstant[instantOutput] = path;
instant = nextInstant;
prepareTransition(path); prepareTransition(path);
// Native rendering needs no provider round trip: decode once, then switch // Native rendering needs no provider round trip: decode once, then switch
// every output in one write so their transitions start together. // every output in one write so their transitions start together.
+3 -5
View File
@@ -116,11 +116,9 @@ Item {
} }
function pickerQuery(text: string): void {input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperSearch").text=text;} function pickerQuery(text: string): void {input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperSearch").text=text;}
function pickerSelect(index: int): bool { function pickerSelect(index: int): bool {
const view=input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperGrid"); ShellState.wallpaperWindow.tileAt(index);input.wait(50);
view.positionViewAtIndex(index,GridView.Contain);input.wait(50); const item=ShellState.wallpaperWindow.tileAt(index);if(!item)return false;
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 pickerScreenshot(path: string): bool {return input.findChild(ShellState.wallpaperWindow.contentItem,"wallpaperPickerSurface").grabToImage(result=>result.saveToFile(path));}
function geometry(name: string): string { function geometry(name: string): string {
+2 -5
View File
@@ -4,7 +4,7 @@ import "../services"
import "../theme" import "../theme"
// A full-size wallpaper that changes with shaders/transition.frag: colonies, or // 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 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. // One per output (WallpaperBackground).
Item { Item {
id: root id: root
// The wallpaper to show. Changing it starts a change once the new image // The wallpaper to show. Changing it starts a change once the new image
@@ -13,8 +13,6 @@ Item {
// false: a change starts as soon as it is ready. true: it emits ready() // false: a change starts as soon as it is ready. true: it emits ready()
// and waits for go(), so several outputs can start together. // and waits for go(), so several outputs can start together.
property bool waitForGo: false property bool waitForGo: false
// Show the next path directly, without a change (consumed by that change).
property bool instantNext: false
signal loading() signal loading()
signal ready() signal ready()
// 0..1 while the new wallpaper takes over. // 0..1 while the new wallpaper takes over.
@@ -25,8 +23,7 @@ Item {
// The first wallpaper (and reduced motion) appears directly; later changes // The first wallpaper (and reduced motion) appears directly; later changes
// load into `incoming` and are revealed once decoded. // load into `incoming` and are revealed once decoded.
onTargetChanged: { onTargetChanged: {
if (!shown.source.toString() || Theme.duration === 0 || instantNext) { if (!shown.source.toString() || Theme.duration === 0) {
instantNext = false;
reveal.stop(); progress = 0; incoming.source = ""; shown.source = target; reveal.stop(); progress = 0; incoming.source = ""; shown.source = target;
return; return;
} }
+1 -6
View File
@@ -24,12 +24,7 @@ PanelWindow {
onLoading:WallpaperService.revealLoading(root.modelData.name) onLoading:WallpaperService.revealLoading(root.modelData.name)
onReady:WallpaperService.revealReady(root.modelData.name) onReady:WallpaperService.revealReady(root.modelData.name)
} }
// The picker's live preview already shows the wallpaper it applies on its onTargetPathChanged:stage.path=targetPath
// own output, so that output switches directly underneath it.
onTargetPathChanged:{
stage.instantNext=WallpaperService.instant[root.modelData.name]===targetPath;
stage.path=targetPath;
}
Component.onCompleted:stage.path=targetPath Component.onCompleted:stage.path=targetPath
Connections { Connections {
target:WallpaperService target:WallpaperService
+195 -252
View File
@@ -10,290 +10,233 @@ import "../services"
import "../core" import "../core"
import "../theme" import "../theme"
// qmllint disable uncreatable-type // 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 { PanelWindow {
id:root id:root
screen:ScreenService.current(ShellState.wallpaperScreen) screen:ScreenService.current(ShellState.wallpaperScreen)
anchors {top:true;bottom:true;left:true;right:true} // Hangs from the middle of the bar as a drawer; the layer starts at the
readonly property string screenName:screen ? screen.name : "" // screen top so the bar join is inside its box.
readonly property bool open:ShellState.wallpaperPickerOpen anchors {top:true}
visible:open || content.opacity>0 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
color:Theme.transparent color:Theme.transparent
exclusionMode:ExclusionMode.Ignore exclusionMode:ExclusionMode.Ignore
WlrLayershell.namespace:"glassMxrph-wallpaper-picker" WlrLayershell.namespace:"glassMxrph-wallpaper-picker"
WlrLayershell.layer:WlrLayer.Overlay WlrLayershell.layer:WlrLayer.Overlay
WlrLayershell.keyboardFocus:open ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None WlrLayershell.keyboardFocus:ShellState.wallpaperPickerOpen ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
Component.onCompleted:ShellState.wallpaperWindow=root Component.onCompleted:ShellState.wallpaperWindow=root
Component.onDestruction:ShellState.wallpaperWindow=null Component.onDestruction:ShellState.wallpaperWindow=null
property string filter:"all" 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()))) 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())))
// 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) : ""
// Justified rows, as in a photo gallery: every thumbnail keeps its own
// aspect ratio (from the scan's header sizes) and each row is scaled so it
// fills the width exactly. The last row keeps the target height.
readonly property real rowTarget:170
readonly property real gap:10
readonly property var rows:layoutRows(results,view.width)
function aspectOf(image) {
const a=image.width>0 && image.height>0 ? image.width/image.height : 16/9;
return Math.max(0.5,Math.min(3,a)); // keep panoramas and slivers usable
}
function layoutRows(images,width) {
const out=[];
if(width<=0)return out;
let row=[],sum=0;
const close=height=>{
let x=0;
out.push({height:height,tiles:row.map(t=>{const w=t.aspect*height;const tile={index:t.index,x:x,width:w};x+=w+root.gap;return tile;})});
row=[];sum=0;
};
images.forEach((image,index)=>{
const aspect=aspectOf(image);
row.push({index:index,aspect:aspect});sum+=aspect;
if(sum*rowTarget+gap*(row.length-1)>=width)close((width-gap*(row.length-1))/sum);
});
if(row.length)close(rowTarget);
return out;
}
// Where each result sits: its row, and its horizontal centre for up/down.
readonly property var places:{
const p=[];
rows.forEach((row,r)=>row.tiles.forEach(t=>p[t.index]={row:r,center:t.x+t.width/2}));
return p;
}
property int current:0
onResultsChanged:if(current>=results.length)current=Math.max(0,results.length-1)
function select(index) { function select(index) {
if(index<0 || index>=results.length)return; if(index<0 || index>=results.length)return;
view.currentIndex=index; current=index;
selectedPath=results[index].path; if(places[index])view.positionViewAtIndex(places[index].row,ListView.Contain);
} }
// Puts the view back on the selection after its model was replaced. The // Up/down: the tile in the next row whose centre is closest.
// selection only changes on input (select/step), never from the view. function vertical(direction) {
property bool centerOnSync:false const here=places[current];
function syncSelection() { if(!here)return select(0);
const index=results.findIndex(i=>i.path===selectedPath); const row=rows[here.row+direction];
view.currentIndex=index; if(!row)return;
if(index>=0 && centerOnSync) {view.positionViewAtIndex(index,GridView.Center);centerOnSync=false;} let best=row.tiles[0];
for(const t of row.tiles)if(Math.abs(t.x+t.width/2-here.center)<Math.abs(best.x+best.width/2-here.center))best=t;
select(best.index);
} }
// Arrow keys: move in the grid; from no selection, start at the first tile. function applyCurrent() {if(root.results[current])WallpaperService.apply(root.results[current].path);}
function step(move) { // For the test driver: the thumbnail item of a result, scrolled into view.
if(!results.length)return; function tileAt(index) {
if(view.currentIndex<0)view.currentIndex=0; const place=places[index];
else move(); if(!place)return null;
selectedPath=results[view.currentIndex].path; view.positionViewAtIndex(place.row,ListView.Contain);
const row=view.itemAtIndex(place.row);
return row ? row.tileAt(index) : null;
} }
// A search that hides the selection selects its first match.
Connections { Connections {
target:search target:ShellState
function onTextChanged() {if(search.text && !root.selected && root.results.length)root.select(0);} function onWallpaperPickerOpenChanged() {
} if(ShellState.wallpaperPickerOpen) {
onResultsChanged:Qt.callLater(syncSelection) WallpaperService.refresh();WallpaperService.scan();
// Previews follow the selection once it rests, so sweeping across the grid const at=root.results.findIndex(i=>i.path===WallpaperService.currentPath);
// does not start a change per tile. if(at>=0)root.select(at);
onSelectedPathChanged:previewDelay.restart() Qt.callLater(()=>view.forceActiveFocus());
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;
centerOnSync=true;
syncSelection();
Qt.callLater(()=>view.forceActiveFocus());
} }
} }
// Exclusive focus routes outside clicks here (see ControlCenter).
Item { MouseArea {x:-20000;y:-20000;width:40000;height:40000;onPressed:ShellState.wallpaperPickerOpen=false}
id:content BarDrawer {
id:surface
objectName:"wallpaperPickerSurface" objectName:"wallpaperPickerSurface"
anchors.fill:parent y:BarDrawers.bottom
opacity:root.open ? 1 : 0 open:ShellState.wallpaperPickerOpen
Behavior on opacity {NumberAnimation {duration:Theme.duration*1.2;easing.type:Easing.OutCubic}} contentWidth:Math.min(1240,root.screenWidth-2*(BarDrawers.margin+BarDrawers.radius+ear))
// Release the preview's textures once fully closed. contentHeight:Math.min(640,root.screenHeight-BarDrawers.bottom-40)
onOpacityChanged:if(opacity===0 && !root.open)preview.path="" drawerId:"wallpaper"
screenName:root.screen ? root.screen.name : ""
TransitionStage { screenX:(root.screenWidth-width)/2
id:preview MouseArea {anchors.fill:parent}
anchors.fill:parent
}
MouseArea {anchors.fill:parent;onClicked:root.peek=!root.peek}
// Name and transition of the selection, over the preview.
ColumnLayout { ColumnLayout {
id:info anchors.fill:parent;anchors.margins:22;spacing:16
x:56;y:48 RowLayout {
spacing:6 Layout.fillWidth:true
opacity:root.selected ? 1 : 0 Text {text:"Wallpapers";color:Theme.text;font.pixelSize:24;Layout.fillWidth:true}
Behavior on opacity {NumberAnimation {duration:Theme.duration}} GlassComboBox {
layer.enabled:true Layout.preferredWidth:160
layer.effect:MultiEffect {shadowEnabled:true;shadowBlur:0.8;shadowOpacity:0.7;shadowColor:"black";autoPaddingEnabled:true} model:["all","primary"].concat(Quickshell.screens.map(s=>s.name))
Text { currentIndex:Math.max(0,model.indexOf(WallpaperService.selectedMonitor))
text:root.selected ? root.selected.name.replace(/\.[^.]+$/,"") : "" onActivated:WallpaperService.selectedMonitor=currentText
color:"white";font.pixelSize:34;font.weight:Font.DemiBold
}
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
}
}
// 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()
}
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 { GlassIconButton {text:"⚙";onClicked:ShellState.openSettings("wallpaper");Accessible.name:"Wallpaper settings"}
id:view GlassIconButton {text:"×";onClicked:ShellState.wallpaperPickerOpen=false;Accessible.name:"Close picker"}
objectName:"wallpaperGrid" }
Layout.fillWidth:true;Layout.fillHeight:true RowLayout {
readonly property int columns:Math.max(3,Math.floor(width/300)) GlassButton {text:"All";accented:root.filter==="all";onClicked:root.filter="all"}
cellWidth:Math.floor(width/columns) GlassButton {text:"History";accented:root.filter==="history";onClicked:root.filter="history"}
cellHeight:Math.round((cellWidth-16)*9/16)+16 GlassTextField {id:search;objectName:"wallpaperSearch";Layout.fillWidth:true;placeholderText:"Search wallpapers…";onTextChanged:root.select(0);Keys.onEscapePressed:ShellState.wallpaperPickerOpen=false;Keys.onDownPressed:view.forceActiveFocus()}
clip:true GlassIconButton {text:"↻";onClicked:WallpaperService.scan();Accessible.name:"Refresh wallpapers"}
model:root.results }
boundsBehavior:Flickable.StopAtBounds ListView {
keyNavigationEnabled:false id:view
ScrollBar.vertical:ScrollBar {} objectName:"wallpaperGallery"
Keys.onLeftPressed:root.step(()=>view.moveCurrentIndexLeft()) Layout.fillWidth:true;Layout.fillHeight:true
Keys.onRightPressed:root.step(()=>view.moveCurrentIndexRight()) spacing:root.gap
Keys.onUpPressed:root.step(()=>view.moveCurrentIndexUp()) clip:true
Keys.onDownPressed:root.step(()=>view.moveCurrentIndexDown()) model:root.rows
Keys.onReturnPressed:root.applySelected() boundsBehavior:Flickable.StopAtBounds
Keys.onEnterPressed:root.applySelected() ScrollBar.vertical:ScrollBar {}
Keys.onEscapePressed:root.close() Keys.onLeftPressed:root.select(root.current-1)
Keys.onSpacePressed:root.peek=!root.peek Keys.onRightPressed:root.select(root.current+1)
// Typing goes to the search field. Keys.onUpPressed:root.vertical(-1)
Keys.onPressed:event=>{ Keys.onDownPressed:root.vertical(1)
if(event.text && event.text.trim() && !(event.modifiers&(Qt.ControlModifier|Qt.AltModifier|Qt.MetaModifier))) { Keys.onReturnPressed:root.applyCurrent()
search.forceActiveFocus();search.text+=event.text;event.accepted=true; Keys.onEnterPressed:root.applyCurrent()
} Keys.onEscapePressed:ShellState.wallpaperPickerOpen=false
delegate:Item {
id:rowItem
required property var modelData
width:view.width
height:modelData.height
function tileAt(index) {
for(let i=0;i<tiles.count;i++)if(tiles.itemAt(i).modelData.index===index)return tiles.itemAt(i);
return null;
} }
// One rounded mask shared by every thumbnail (they are all the same size). Repeater {
Item { id:tiles
id:tileMask model:rowItem.modelData.tiles
width:view.cellWidth-16;height:view.cellHeight-16 delegate:Item {
visible:false id:tile
layer.enabled:true required property var modelData
Rectangle {anchors.fill:parent;radius:14} readonly property var image:root.results[modelData.index]
} readonly property bool selected:root.current===modelData.index
delegate:Item { x:modelData.x;width:modelData.width;height:rowItem.height
id:cell Item {
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 anchors.fill:parent
source:cell.modelData.url scale:hover.containsMouse && !tile.selected ? 1.02 : 1
sourceSize:Qt.size(480,270) Behavior on scale {NumberAnimation {duration:Theme.duration;easing.type:Easing.OutCubic}}
asynchronous:true Image {
fillMode:Image.PreserveAspectCrop anchors.fill:parent
opacity:status===Image.Ready ? (cell.current ? 1 : 0.82) : 0 source:tile.image ? tile.image.url : ""
Behavior on opacity {NumberAnimation {duration:Theme.duration}} sourceSize:Qt.size(Math.round(tile.width*1.5),Math.round(tile.height*1.5))
layer.enabled:true asynchronous:true
layer.effect:MultiEffect {maskEnabled:true;maskSource:tileMask;maskThresholdMin:0.5;maskSpreadAtMin:1} fillMode:Image.PreserveAspectCrop
} opacity:status===Image.Ready ? 1 : 0
Rectangle { Behavior on opacity {NumberAnimation {duration:Theme.duration}}
anchors.fill:parent;radius:14;color:"transparent" layer.enabled:true
border.width:cell.current ? 3 : 1 layer.effect:MultiEffect {maskEnabled:true;maskSource:mask;maskThresholdMin:0.5;maskSpreadAtMin:1}
border.color:cell.current ? Theme.accent : Qt.alpha("white",0.16) }
} Item {
Row { id:mask
anchors.top:parent.top;anchors.right:parent.right;anchors.margins:8;spacing:6 anchors.fill:parent
Repeater { visible:false
model:[WallpaperService.outlineStatus[cell.modelData.path]==="outline" ? "✦" : "", layer.enabled:true
cell.modelData.path===root.desktopPath ? "✓" : ""].filter(s=>s) Rectangle {anchors.fill:parent;radius:12}
delegate:Rectangle { }
required property string modelData Rectangle {
width:24;height:24;radius:12 anchors.fill:parent;radius:12;color:"transparent"
color:Qt.alpha("black",0.55) border.width:tile.selected ? 3 : 1
Text {anchors.centerIn:parent;text:parent.modelData;color:"white";font.pixelSize:13} border.color:tile.selected ? Theme.accent : Theme.border
}
// Name on the selected or hovered thumbnail only.
Rectangle {
anchors.left:parent.left;anchors.right:parent.right;anchors.bottom:parent.bottom;anchors.margins:3
height:30;radius:9
color:Qt.alpha(Theme.surface,0.78)
opacity:tile.selected || hover.containsMouse ? 1 : 0
Behavior on opacity {NumberAnimation {duration:Theme.duration}}
Text {
anchors.fill:parent;anchors.leftMargin:10;anchors.rightMargin:10
verticalAlignment:Text.AlignVCenter
text:tile.image ? tile.image.name : ""
color:Theme.text;font.pixelSize:12;elide:Text.ElideMiddle
}
}
// ✦ the subject's outline is drawn first · ✓ current wallpaper
Row {
anchors.top:parent.top;anchors.right:parent.right;anchors.margins:7;spacing:5
Repeater {
model:tile.image ? [WallpaperService.outlineStatus[tile.image.path]==="outline" ? "✦" : "",
tile.image.path===WallpaperService.currentPath ? "✓" : ""].filter(s=>s) : []
delegate:Rectangle {
required property string modelData
width:22;height:22;radius:11
color:Qt.alpha("black",0.55)
Text {anchors.centerIn:parent;text:parent.modelData;color:"white";font.pixelSize:12}
}
} }
} }
} }
} MouseArea {
// Click previews, double-click applies. id:hover
MouseArea { anchors.fill:parent
id:tileArea hoverEnabled:true
anchors.fill:parent onClicked:{root.current=tile.modelData.index;view.forceActiveFocus();root.applyCurrent();}
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}
// While peeking, a click or any key brings the sheet back. Text {text:WallpaperService.error || (WallpaperService.busy?"Applying wallpaper…":"Click or arrows and Enter to apply · ✦ outline transition · Esc Close");color:WallpaperService.error?Theme.urgent:Theme.textSecondary;Layout.fillWidth:true;wrapMode:Text.Wrap}
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"}
} }
} }
} }