WallpaperService: refactored to a simpler signal based approach.
This commit is contained in:
parent
4193d3c87c
commit
5fef9cfe6b
8 changed files with 217 additions and 76 deletions
|
|
@ -18,7 +18,6 @@ Variants {
|
|||
id: root
|
||||
|
||||
// Internal state management
|
||||
property bool firstWallpaper: true
|
||||
property string transitionType: "fade"
|
||||
property real transitionProgress: 0
|
||||
|
||||
|
|
@ -37,17 +36,26 @@ Variants {
|
|||
property real stripesCount: 16
|
||||
property real stripesAngle: 0
|
||||
|
||||
// External state management
|
||||
property string servicedWallpaper: modelData ? WallpaperService.getWallpaper(modelData.name) : ""
|
||||
// Used to debounce wallpaper changes
|
||||
property string futureWallpaper: ""
|
||||
onServicedWallpaperChanged: {
|
||||
// Set wallpaper immediately on startup
|
||||
if (firstWallpaper) {
|
||||
firstWallpaper = false
|
||||
setWallpaperImmediate(servicedWallpaper)
|
||||
} else {
|
||||
futureWallpaper = servicedWallpaper
|
||||
debounceTimer.restart()
|
||||
|
||||
// On startup assign wallpaper immediately
|
||||
Component.onCompleted: {
|
||||
var path = modelData ? WallpaperService.getWallpaper(modelData.name) : ""
|
||||
setWallpaperImmediate(path)
|
||||
}
|
||||
|
||||
// External state management
|
||||
Connections {
|
||||
target: WallpaperService
|
||||
function onWallpaperChanged(screenName, path) {
|
||||
if (screenName === modelData.name) {
|
||||
|
||||
// Update wallpaper display
|
||||
// Set wallpaper immediately on startup
|
||||
futureWallpaper = path
|
||||
debounceTimer.restart()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,11 +14,24 @@ Variants {
|
|||
|
||||
active: Settings.isLoaded && CompositorService.isNiri && modelData
|
||||
|
||||
property string wallpaper: ""
|
||||
|
||||
sourceComponent: PanelWindow {
|
||||
Component.onCompleted: {
|
||||
if (modelData) {
|
||||
Logger.log("Overview", "Loading Overview component for Niri on", modelData.name)
|
||||
}
|
||||
wallpaper = modelData ? WallpaperService.getWallpaper(modelData.name) : ""
|
||||
}
|
||||
|
||||
// External state management
|
||||
Connections {
|
||||
target: WallpaperService
|
||||
function onWallpaperChanged(screenName, path) {
|
||||
if (screenName === modelData.name) {
|
||||
wallpaper = path
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
color: Color.transparent
|
||||
|
|
@ -38,7 +51,7 @@ Variants {
|
|||
id: bgImage
|
||||
anchors.fill: parent
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
source: modelData ? WallpaperService.getWallpaper(modelData.name) : ""
|
||||
source: wallpaper
|
||||
smooth: true
|
||||
mipmap: false
|
||||
cache: false
|
||||
|
|
|
|||
|
|
@ -63,7 +63,8 @@ ColumnLayout {
|
|||
if (exitCode === 0) {
|
||||
// Matugen exists, enable it
|
||||
Settings.data.colorSchemes.useWallpaperColors = true
|
||||
ColorSchemeService.changedWallpaper()
|
||||
Settings.data.colorSchemes.predefinedScheme = ""
|
||||
MatugenService.generateFromWallpaper()
|
||||
ToastService.showNotice("Matugen", "Enabled")
|
||||
} else {
|
||||
// Matugen not found
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ ColumnLayout {
|
|||
|
||||
// Avatar preview
|
||||
NImageCircled {
|
||||
width: 64 * scaling
|
||||
height: 64 * scaling
|
||||
width: 128 * scaling
|
||||
height: 128 * scaling
|
||||
imagePath: Settings.data.general.avatarImage
|
||||
fallbackIcon: "person"
|
||||
borderColor: Color.mPrimary
|
||||
|
|
|
|||
|
|
@ -12,6 +12,35 @@ ColumnLayout {
|
|||
|
||||
spacing: Style.marginL * scaling
|
||||
|
||||
property list<string> wallpapersList: []
|
||||
property string currentWallpaper: ""
|
||||
|
||||
Component.onCompleted: {
|
||||
wallpapersList = screen ? WallpaperService.getWallpapersList(screen.name) : []
|
||||
currentWallpaper = screen ? WallpaperService.getWallpaper(screen.name) : ""
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: WallpaperService
|
||||
function onWallpaperChanged(screenName, path) {
|
||||
if (screenName === screen.name) {
|
||||
currentWallpaper = WallpaperService.getWallpaper(screen.name)
|
||||
}
|
||||
}
|
||||
function onWallpaperDirectoryChanged(screenName, directory) {
|
||||
if (screenName === screen.name) {
|
||||
wallpapersList = WallpaperService.getWallpapersList(screen.name)
|
||||
currentWallpaper = WallpaperService.getWallpaper(screen.name)
|
||||
}
|
||||
}
|
||||
function onWallpaperListChanged(screenName, count) {
|
||||
if (screenName === screen.name) {
|
||||
wallpapersList = WallpaperService.getWallpapersList(screen.name)
|
||||
currentWallpaper = WallpaperService.getWallpaper(screen.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Current wallpaper display
|
||||
NText {
|
||||
text: "Current Wallpaper"
|
||||
|
|
@ -29,7 +58,7 @@ ColumnLayout {
|
|||
NImageRounded {
|
||||
anchors.fill: parent
|
||||
anchors.margins: Style.marginXS * scaling
|
||||
imagePath: screen ? WallpaperService.getWallpaper(screen.name) : ""
|
||||
imagePath: currentWallpaper
|
||||
fallbackIcon: "image"
|
||||
imageRadius: Style.radiusM * scaling
|
||||
}
|
||||
|
|
@ -74,11 +103,9 @@ ColumnLayout {
|
|||
}
|
||||
}
|
||||
|
||||
property list<string> wallpapersList: screen ? WallpaperService.getWallpapersList(screen.name) : []
|
||||
|
||||
NToggle {
|
||||
label: "Assign selection to all monitors"
|
||||
description: "Set selected wallpaper on all monitors at once."
|
||||
label: "Apply to all monitors"
|
||||
description: "Apply selected wallpaper to all monitors at once."
|
||||
checked: Settings.data.wallpaper.setWallpaperOnAllMonitors
|
||||
onToggled: checked => Settings.data.wallpaper.setWallpaperOnAllMonitors = checked
|
||||
visible: (wallpapersList.length > 0)
|
||||
|
|
@ -115,7 +142,7 @@ ColumnLayout {
|
|||
id: wallpaperItem
|
||||
|
||||
property string wallpaperPath: modelData
|
||||
property bool isSelected: screen ? (wallpaperPath === WallpaperService.getWallpaper(screen.name)) : false
|
||||
property bool isSelected: screen ? (wallpaperPath === currentWallpaper) : false
|
||||
|
||||
width: wallpaperGridView.itemSize
|
||||
height: Math.round(wallpaperGridView.itemSize * 0.67)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue