Wallpaper: real support for differents folders per monitor \o/
This commit is contained in:
parent
812ddf2ebb
commit
9bbdf5f6f6
3 changed files with 88 additions and 69 deletions
|
|
@ -67,32 +67,34 @@ ColumnLayout {
|
|||
icon: "refresh"
|
||||
tooltipText: "Refresh wallpaper list"
|
||||
onClicked: {
|
||||
WallpaperService.listWallpapers()
|
||||
WallpaperService.refreshWallpapersList()
|
||||
}
|
||||
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
|
||||
}
|
||||
}
|
||||
|
||||
property list<string> wallpapersList: WallpaperService.getWallpapersList(screen.name)
|
||||
|
||||
NToggle {
|
||||
label: "Assign selection to all monitors"
|
||||
description: "Set selected wallpaper on all monitors at once."
|
||||
checked: Settings.data.wallpaper.setWallpaperOnAllMonitors
|
||||
onToggled: checked => Settings.data.wallpaper.setWallpaperOnAllMonitors = checked
|
||||
visible: (WallpaperService.wallpaperList.length > 0)
|
||||
visible: (wallpapersList.length > 0)
|
||||
}
|
||||
|
||||
// Wallpaper grid container
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: {
|
||||
return Math.ceil(WallpaperService.wallpaperList.length / wallpaperGridView.columns) * wallpaperGridView.cellHeight
|
||||
return Math.ceil(wallpapersList.length / wallpaperGridView.columns) * wallpaperGridView.cellHeight
|
||||
}
|
||||
|
||||
GridView {
|
||||
id: wallpaperGridView
|
||||
anchors.fill: parent
|
||||
clip: true
|
||||
model: WallpaperService.wallpaperList
|
||||
model: wallpapersList
|
||||
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
flickableDirection: Flickable.AutoFlickDirection
|
||||
|
|
@ -187,54 +189,52 @@ ColumnLayout {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Empty state
|
||||
Rectangle {
|
||||
color: Color.mSurface
|
||||
radius: Style.radiusM * scaling
|
||||
border.color: Color.mOutline
|
||||
border.width: Math.max(1, Style.borderS * scaling)
|
||||
visible: WallpaperService.wallpaperList.length === 0 && !WallpaperService.scanning
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 130 * scaling
|
||||
Rectangle {
|
||||
color: Color.mSurface
|
||||
radius: Style.radiusM * scaling
|
||||
border.color: Color.mOutline
|
||||
border.width: Math.max(1, Style.borderS * scaling)
|
||||
visible: wallpapersList.length === 0 && !WallpaperService.scanning
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 130 * scaling
|
||||
|
||||
ColumnLayout {
|
||||
id: fallbackColumn
|
||||
anchors.fill: parent
|
||||
ColumnLayout {
|
||||
id: fallbackColumn
|
||||
anchors.fill: parent
|
||||
|
||||
Item {
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
Item {
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
NIcon {
|
||||
text: "folder_open"
|
||||
font.pointSize: Style.fontSizeXL * scaling
|
||||
color: Color.mOnSurface
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
}
|
||||
NIcon {
|
||||
text: "folder_open"
|
||||
font.pointSize: Style.fontSizeXL * scaling
|
||||
color: Color.mOnSurface
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
}
|
||||
|
||||
NText {
|
||||
text: "No wallpaper found."
|
||||
color: Color.mOnSurface
|
||||
font.weight: Style.fontWeightBold
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
}
|
||||
NText {
|
||||
text: "No wallpaper found."
|
||||
color: Color.mOnSurface
|
||||
font.weight: Style.fontWeightBold
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
}
|
||||
|
||||
NText {
|
||||
text: "Make sure your wallpaper directory is configured and contains image files."
|
||||
color: Color.mOnSurfaceVariant
|
||||
wrapMode: Text.WordWrap
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
}
|
||||
NText {
|
||||
text: "Make sure your wallpaper directory is configured and contains image files."
|
||||
color: Color.mOnSurfaceVariant
|
||||
wrapMode: Text.WordWrap
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
Item {
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NDivider {
|
||||
Layout.fillWidth: true
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ ColumnLayout {
|
|||
description: `Path to your wallpaper directory for "${(modelData.name || "Unknown")}" monitor`
|
||||
text: WallpaperService.getMonitorDirectory(modelData.name)
|
||||
labelColor: Color.mSecondary
|
||||
onEditingFinished: WallpaperService.setMonitorWallpaperDirectory(modelData.name, text)
|
||||
onEditingFinished: WallpaperService.setMonitorDirectory(modelData.name, text)
|
||||
Layout.maximumWidth: 420 * scaling
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ Singleton {
|
|||
}
|
||||
}
|
||||
|
||||
property var wallpaperList: []
|
||||
property var wallpaperLists: ({})
|
||||
property bool scanning: false
|
||||
|
||||
Connections {
|
||||
target: Settings.data.wallpaper
|
||||
function onDirectoryChanged() {
|
||||
root.listWallpapers()
|
||||
root.refreshWallpapersList()
|
||||
}
|
||||
function onRandomEnabledChanged() {
|
||||
root.toggleRandomWallpaper()
|
||||
|
|
@ -110,15 +110,15 @@ Singleton {
|
|||
}
|
||||
|
||||
if (screenName === undefined) {
|
||||
Logger.warn("Wallpaper", "setCurrentWallpaper", "no screen specified")
|
||||
Logger.warn("Wallpaper", "setWallpaper", "no screen specified")
|
||||
return
|
||||
}
|
||||
|
||||
Logger.log("Wallpaper", "setCurrentWallpaper on", screenName, ": ", path)
|
||||
Logger.log("Wallpaper", "setWallpaper on", screenName, ": ", path)
|
||||
|
||||
var wallpaperChanged = false
|
||||
|
||||
var monitor = geMonitorDefinition(screenName)
|
||||
var monitor = getMonitorConfig(screenName)
|
||||
if (monitor !== undefined) {
|
||||
wallpaperChanged = (monitor["wallpaper"] !== path)
|
||||
monitor["wallpaper"] = path
|
||||
|
|
@ -152,7 +152,7 @@ Singleton {
|
|||
if (wallpaperList.length > 0) {
|
||||
var randomIndex = Math.floor(Math.random() * wallpaperList.length)
|
||||
var randomPath = wallpaperList[randomIndex]
|
||||
setCurrentWallpaper(screenName, randomPath)
|
||||
setWallpaper(screenName, randomPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -177,13 +177,21 @@ Singleton {
|
|||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
function listWallpapers() {
|
||||
function getWallpapersList(screenName) {
|
||||
if (screenName != undefined && wallpaperLists[screenName] != undefined) {
|
||||
return wallpaperLists[screenName]
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
function refreshWallpapersList() {
|
||||
if (!Settings.isLoaded) {
|
||||
return
|
||||
}
|
||||
|
||||
// TODO
|
||||
Logger.log("Wallpaper", "Listing wallpapers for all monitors")
|
||||
Logger.log("Wallpaper", "refreshWallpapersList")
|
||||
scanning = true
|
||||
}
|
||||
|
||||
|
|
@ -199,23 +207,34 @@ Singleton {
|
|||
triggeredOnStart: false
|
||||
}
|
||||
|
||||
// FolderListModel {
|
||||
// id: folderModel
|
||||
// nameFilters: ["*.jpg", "*.jpeg", "*.png", "*.gif", "*.pnm", "*.bmp"]
|
||||
// showDirs: false
|
||||
// sortField: FolderListModel.Name
|
||||
// onStatusChanged: {
|
||||
// if (status === FolderListModel.Ready) {
|
||||
// var files = []
|
||||
// for (var i = 0; i < count; i++) {
|
||||
// var directory = (Settings.data.wallpaper.directory !== undefined ? Settings.data.wallpaper.directory : "")
|
||||
// var filepath = directory + "/" + get(i, "fileName")
|
||||
// files.push(filepath)
|
||||
// }
|
||||
// wallpaperList = files
|
||||
// scanning = false
|
||||
// Logger.log("Wallpaper", "List refreshed, count:", wallpaperList.length)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// Instantiator (not Repeater) to create FolderListModel for each monitor
|
||||
Instantiator {
|
||||
model: Quickshell.screens
|
||||
|
||||
delegate: FolderListModel {
|
||||
property string screenName: modelData.name
|
||||
|
||||
folder: "file://" + root.getMonitorDirectory(screenName)
|
||||
nameFilters: ["*.jpg", "*.jpeg", "*.png", "*.gif", "*.pnm", "*.bmp"]
|
||||
showDirs: false
|
||||
sortField: FolderListModel.Name
|
||||
|
||||
onStatusChanged: {
|
||||
if (status === FolderListModel.Ready) {
|
||||
var files = []
|
||||
for (var i = 0; i < count; i++) {
|
||||
var directory = root.getMonitorDirectory(screenName)
|
||||
var filepath = directory + "/" + get(i, "fileName")
|
||||
files.push(filepath)
|
||||
}
|
||||
|
||||
var lists = root.wallpaperLists
|
||||
lists[screenName] = files
|
||||
root.wallpaperLists = lists
|
||||
|
||||
Logger.log("Wallpaper", "List refreshed for", screenName, "count:", files.length)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue