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
@@ -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