Add wallpaper mode controls
This commit is contained in:
@@ -24,6 +24,14 @@ Item {
|
||||
// unreachable without a long scroll past pictures. Two rows by default,
|
||||
// all of them on request.
|
||||
property bool expanded: false
|
||||
property string mode: DesktopPreferences.get("wallpaperMode")
|
||||
property string selectedOutput: Wallpaper.outputNames()[0] ?? ""
|
||||
property var activeByOutput: Wallpaper.activeByOutput
|
||||
property var slideshowPaths: DesktopPreferences.get("wallpaperSlideshowPaths") ?? []
|
||||
property var assignments: DesktopPreferences.get("wallpaperPerMonitor") ?? ({})
|
||||
property var setSingleAction: function(path) { Wallpaper.setSingle(path); }
|
||||
property var toggleSlideshowAction: function(path) { Wallpaper.toggleSlideshowPath(path); }
|
||||
property var setAssignmentAction: function(output, path) { Wallpaper.setAssignment(output, path); }
|
||||
readonly property int collapsedRows: 2
|
||||
|
||||
readonly property var shown: root.expanded
|
||||
@@ -35,6 +43,27 @@ Item {
|
||||
readonly property int columns: Math.max(2, Math.floor(width / 190))
|
||||
readonly property real cellWidth: columns > 0 ? (width - (columns - 1) * 10) / columns : 160
|
||||
|
||||
function isCurrent(path: string): bool {
|
||||
return root.activeByOutput[root.selectedOutput] === path;
|
||||
}
|
||||
|
||||
function selected(path: string): bool {
|
||||
if (root.mode === "slideshow")
|
||||
return root.slideshowPaths.includes(path);
|
||||
if (root.mode === "per-monitor")
|
||||
return root.assignments[root.selectedOutput] === path;
|
||||
return root.isCurrent(path);
|
||||
}
|
||||
|
||||
function activate(path: string): void {
|
||||
if (root.mode === "slideshow")
|
||||
root.toggleSlideshowAction(path);
|
||||
else if (root.mode === "per-monitor")
|
||||
root.setAssignmentAction(root.selectedOutput, path);
|
||||
else
|
||||
root.setSingleAction(path);
|
||||
}
|
||||
|
||||
Grid {
|
||||
id: grid
|
||||
|
||||
@@ -50,7 +79,8 @@ Item {
|
||||
|
||||
required property var modelData
|
||||
|
||||
readonly property bool current: Wallpaper.active === tile.modelData
|
||||
readonly property bool current: root.isCurrent(tile.modelData)
|
||||
readonly property bool member: root.mode === "slideshow" && root.selected(tile.modelData)
|
||||
|
||||
width: root.cellWidth
|
||||
height: Math.round(root.cellWidth * 9 / 16)
|
||||
@@ -114,6 +144,28 @@ Item {
|
||||
border.color: Theme.accent
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
anchors.margins: 8
|
||||
width: 24
|
||||
height: 24
|
||||
radius: 12
|
||||
visible: tile.member
|
||||
color: Theme.alpha(Theme.bgDark, 0.82)
|
||||
border.width: 1
|
||||
border.color: Theme.alpha(Theme.fg, 0.16)
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "✓"
|
||||
color: Theme.fg
|
||||
font.family: Theme.fontFamily
|
||||
font.pixelSize: 14
|
||||
font.weight: Font.DemiBold
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
@@ -132,7 +184,9 @@ Item {
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: 7
|
||||
text: tile.current ? "Current wallpaper" : Wallpaper.titleFor(tile.modelData)
|
||||
text: tile.current
|
||||
? "Current wallpaper"
|
||||
: (tile.member ? "In slideshow" : Wallpaper.titleFor(tile.modelData))
|
||||
color: tile.current ? Theme.accent : Theme.fg
|
||||
font.family: Theme.fontFamily
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
@@ -144,7 +198,7 @@ Item {
|
||||
HoverHandler { id: hover }
|
||||
|
||||
TapHandler {
|
||||
onTapped: Wallpaper.set(tile.modelData)
|
||||
onTapped: root.activate(tile.modelData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user