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:
1 parent
2a41cde6f5
commit
ebace10767
7 files changed
+240
-278
No files matched your search
@@ -4,7 +4,7 @@ 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.
|
||||
// One per output (WallpaperBackground).
|
||||
Item {
|
||||
id: root
|
||||
// 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()
|
||||
// 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.
|
||||
@@ -25,8 +23,7 @@ Item {
|
||||
// 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;
|
||||
if (!shown.source.toString() || Theme.duration === 0) {
|
||||
reveal.stop(); progress = 0; incoming.source = ""; shown.source = target;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,12 +24,7 @@ PanelWindow {
|
||||
onLoading:WallpaperService.revealLoading(root.modelData.name)
|
||||
onReady:WallpaperService.revealReady(root.modelData.name)
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
onTargetPathChanged:stage.path=targetPath
|
||||
Component.onCompleted:stage.path=targetPath
|
||||
Connections {
|
||||
target:WallpaperService
|
||||
|
||||
@@ -10,290 +10,233 @@ 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)
|
||||
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
|
||||
// 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
|
||||
color:Theme.transparent
|
||||
exclusionMode:ExclusionMode.Ignore
|
||||
WlrLayershell.namespace:"glassMxrph-wallpaper-picker"
|
||||
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.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())))
|
||||
// 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) {
|
||||
if(index<0 || index>=results.length)return;
|
||||
view.currentIndex=index;
|
||||
selectedPath=results[index].path;
|
||||
current=index;
|
||||
if(places[index])view.positionViewAtIndex(places[index].row,ListView.Contain);
|
||||
}
|
||||
// Puts the view back on the selection after its model was replaced. The
|
||||
// selection only changes on input (select/step), never from the view.
|
||||
property bool centerOnSync:false
|
||||
function syncSelection() {
|
||||
const index=results.findIndex(i=>i.path===selectedPath);
|
||||
view.currentIndex=index;
|
||||
if(index>=0 && centerOnSync) {view.positionViewAtIndex(index,GridView.Center);centerOnSync=false;}
|
||||
// Up/down: the tile in the next row whose centre is closest.
|
||||
function vertical(direction) {
|
||||
const here=places[current];
|
||||
if(!here)return select(0);
|
||||
const row=rows[here.row+direction];
|
||||
if(!row)return;
|
||||
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 step(move) {
|
||||
if(!results.length)return;
|
||||
if(view.currentIndex<0)view.currentIndex=0;
|
||||
else move();
|
||||
selectedPath=results[view.currentIndex].path;
|
||||
function applyCurrent() {if(root.results[current])WallpaperService.apply(root.results[current].path);}
|
||||
// For the test driver: the thumbnail item of a result, scrolled into view.
|
||||
function tileAt(index) {
|
||||
const place=places[index];
|
||||
if(!place)return null;
|
||||
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 {
|
||||
target:search
|
||||
function onTextChanged() {if(search.text && !root.selected && root.results.length)root.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;
|
||||
centerOnSync=true;
|
||||
syncSelection();
|
||||
Qt.callLater(()=>view.forceActiveFocus());
|
||||
target:ShellState
|
||||
function onWallpaperPickerOpenChanged() {
|
||||
if(ShellState.wallpaperPickerOpen) {
|
||||
WallpaperService.refresh();WallpaperService.scan();
|
||||
const at=root.results.findIndex(i=>i.path===WallpaperService.currentPath);
|
||||
if(at>=0)root.select(at);
|
||||
Qt.callLater(()=>view.forceActiveFocus());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id:content
|
||||
// Exclusive focus routes outside clicks here (see ControlCenter).
|
||||
MouseArea {x:-20000;y:-20000;width:40000;height:40000;onPressed:ShellState.wallpaperPickerOpen=false}
|
||||
BarDrawer {
|
||||
id:surface
|
||||
objectName:"wallpaperPickerSurface"
|
||||
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.
|
||||
y:BarDrawers.bottom
|
||||
open:ShellState.wallpaperPickerOpen
|
||||
contentWidth:Math.min(1240,root.screenWidth-2*(BarDrawers.margin+BarDrawers.radius+ear))
|
||||
contentHeight:Math.min(640,root.screenHeight-BarDrawers.bottom-40)
|
||||
drawerId:"wallpaper"
|
||||
screenName:root.screen ? root.screen.name : ""
|
||||
screenX:(root.screenWidth-width)/2
|
||||
MouseArea {anchors.fill:parent}
|
||||
ColumnLayout {
|
||||
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
|
||||
}
|
||||
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"}
|
||||
anchors.fill:parent;anchors.margins:22;spacing:16
|
||||
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
|
||||
}
|
||||
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:false
|
||||
ScrollBar.vertical:ScrollBar {}
|
||||
Keys.onLeftPressed:root.step(()=>view.moveCurrentIndexLeft())
|
||||
Keys.onRightPressed:root.step(()=>view.moveCurrentIndexRight())
|
||||
Keys.onUpPressed:root.step(()=>view.moveCurrentIndexUp())
|
||||
Keys.onDownPressed:root.step(()=>view.moveCurrentIndexDown())
|
||||
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;
|
||||
}
|
||||
GlassIconButton {text:"⚙";onClicked:ShellState.openSettings("wallpaper");Accessible.name:"Wallpaper settings"}
|
||||
GlassIconButton {text:"×";onClicked:ShellState.wallpaperPickerOpen=false;Accessible.name:"Close picker"}
|
||||
}
|
||||
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:root.select(0);Keys.onEscapePressed:ShellState.wallpaperPickerOpen=false;Keys.onDownPressed:view.forceActiveFocus()}
|
||||
GlassIconButton {text:"↻";onClicked:WallpaperService.scan();Accessible.name:"Refresh wallpapers"}
|
||||
}
|
||||
ListView {
|
||||
id:view
|
||||
objectName:"wallpaperGallery"
|
||||
Layout.fillWidth:true;Layout.fillHeight:true
|
||||
spacing:root.gap
|
||||
clip:true
|
||||
model:root.rows
|
||||
boundsBehavior:Flickable.StopAtBounds
|
||||
ScrollBar.vertical:ScrollBar {}
|
||||
Keys.onLeftPressed:root.select(root.current-1)
|
||||
Keys.onRightPressed:root.select(root.current+1)
|
||||
Keys.onUpPressed:root.vertical(-1)
|
||||
Keys.onDownPressed:root.vertical(1)
|
||||
Keys.onReturnPressed:root.applyCurrent()
|
||||
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).
|
||||
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 {
|
||||
Repeater {
|
||||
id:tiles
|
||||
model:rowItem.modelData.tiles
|
||||
delegate:Item {
|
||||
id:tile
|
||||
required property var modelData
|
||||
readonly property var image:root.results[modelData.index]
|
||||
readonly property bool selected:root.current===modelData.index
|
||||
x:modelData.x;width:modelData.width;height:rowItem.height
|
||||
Item {
|
||||
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}
|
||||
scale:hover.containsMouse && !tile.selected ? 1.02 : 1
|
||||
Behavior on scale {NumberAnimation {duration:Theme.duration;easing.type:Easing.OutCubic}}
|
||||
Image {
|
||||
anchors.fill:parent
|
||||
source:tile.image ? tile.image.url : ""
|
||||
sourceSize:Qt.size(Math.round(tile.width*1.5),Math.round(tile.height*1.5))
|
||||
asynchronous:true
|
||||
fillMode:Image.PreserveAspectCrop
|
||||
opacity:status===Image.Ready ? 1 : 0
|
||||
Behavior on opacity {NumberAnimation {duration:Theme.duration}}
|
||||
layer.enabled:true
|
||||
layer.effect:MultiEffect {maskEnabled:true;maskSource:mask;maskThresholdMin:0.5;maskSpreadAtMin:1}
|
||||
}
|
||||
Item {
|
||||
id:mask
|
||||
anchors.fill:parent
|
||||
visible:false
|
||||
layer.enabled:true
|
||||
Rectangle {anchors.fill:parent;radius:12}
|
||||
}
|
||||
Rectangle {
|
||||
anchors.fill:parent;radius:12;color:"transparent"
|
||||
border.width:tile.selected ? 3 : 1
|
||||
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}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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();}
|
||||
MouseArea {
|
||||
id:hover
|
||||
anchors.fill:parent
|
||||
hoverEnabled:true
|
||||
onClicked:{root.current=tile.modelData.index;view.forceActiveFocus();root.applyCurrent();}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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"}
|
||||
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 arrows and Enter to apply · ✦ outline transition · Esc Close");color:WallpaperService.error?Theme.urgent:Theme.textSecondary;Layout.fillWidth:true;wrapMode:Text.Wrap}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user