Files
glassMxrph/quickshell/wallpaper/WallpaperPicker.qml
T
mxandClaude Opus 5.5 99e64a7713 Add glassMxrph shell sources
Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:36:17 +02:00

117 lines
6.7 KiB
QML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Quickshell
import Quickshell.Wayland
import "../components"
import "../services"
import "../core"
import "../theme"
// qmllint disable uncreatable-type
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
color:Theme.transparent
exclusionMode:ExclusionMode.Ignore
WlrLayershell.namespace:"glassMxrph-wallpaper-picker"
WlrLayershell.layer:WlrLayer.Overlay
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())))
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());
}
}
}
// 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"
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}
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"}
}
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"}
}
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}
}
MouseArea {anchors.fill:parent;onClicked:{view.currentIndex=tile.index;view.forceActiveFocus();}onDoubleClicked:WallpaperService.apply(tile.modelData.path)}
}
}
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}
RowLayout {
Text {text:WallpaperService.error || (WallpaperService.busy?"Applying wallpaper…":"← → Browse · Enter or double-click to apply · Esc Close");color:WallpaperService.error?Theme.urgent:Theme.textSecondary;Layout.fillWidth:true;wrapMode:Text.Wrap}
GlassButton {objectName:"pickerApply";text:"Apply wallpaper";accented:true;enabled:root.results.length>0 && !WallpaperService.busy;onClicked:root.applyCurrent()}
}
}
}
}