Wip!
This commit is contained in:
parent
e79c163dd9
commit
861e207fb6
9 changed files with 59 additions and 82 deletions
|
|
@ -90,14 +90,9 @@ Singleton {
|
||||||
}
|
}
|
||||||
onLoaded: function () {
|
onLoaded: function () {
|
||||||
Qt.callLater(function () {
|
Qt.callLater(function () {
|
||||||
// Some stuff like wallpaper setup and settings validation should just be executed once on startup
|
// Some stuff like settings validation should just be executed once on startup and not on every reload
|
||||||
// And not on every reload
|
|
||||||
if (!isLoaded) {
|
if (!isLoaded) {
|
||||||
Logger.log("Settings", "JSON completed loading")
|
Logger.log("Settings", "JSON completed loading")
|
||||||
// if (adapter.wallpaper.current !== "") {
|
|
||||||
// Logger.log("Settings", "Set current wallpaper", adapter.wallpaper.current)
|
|
||||||
// WallpaperService.setCurrentWallpaper(adapter.wallpaper.current, true)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Validate monitor configurations, only once
|
// Validate monitor configurations, only once
|
||||||
// if none of the configured monitors exist, clear the lists
|
// if none of the configured monitors exist, clear the lists
|
||||||
|
|
|
||||||
|
|
@ -4,17 +4,18 @@ import Quickshell.Wayland
|
||||||
import qs.Commons
|
import qs.Commons
|
||||||
import qs.Services
|
import qs.Services
|
||||||
|
|
||||||
Loader {
|
Variants {
|
||||||
active: true
|
model: Quickshell.screens
|
||||||
|
|
||||||
sourceComponent: Variants {
|
delegate: Loader {
|
||||||
model: Quickshell.screens
|
|
||||||
|
|
||||||
delegate: PanelWindow {
|
required property ShellScreen modelData
|
||||||
required property ShellScreen modelData
|
property string wallpaperSource: WallpaperService.getWallpaper(modelData.name)
|
||||||
property string wallpaperSource: WallpaperService.getWallpaper(modelData.name)
|
|
||||||
|
active: wallpaperSource !== ""
|
||||||
|
|
||||||
|
sourceComponent: PanelWindow {
|
||||||
|
|
||||||
visible: wallpaperSource !== ""
|
|
||||||
color: Color.transparent
|
color: Color.transparent
|
||||||
screen: modelData
|
screen: modelData
|
||||||
WlrLayershell.layer: WlrLayer.Background
|
WlrLayershell.layer: WlrLayer.Background
|
||||||
|
|
@ -28,15 +29,10 @@ Loader {
|
||||||
left: true
|
left: true
|
||||||
}
|
}
|
||||||
|
|
||||||
margins {
|
|
||||||
top: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
fillMode: Image.PreserveAspectCrop
|
fillMode: Image.PreserveAspectCrop
|
||||||
source: wallpaperSource
|
source: wallpaperSource
|
||||||
visible: wallpaperSource !== ""
|
|
||||||
cache: true
|
cache: true
|
||||||
smooth: true
|
smooth: true
|
||||||
mipmap: false
|
mipmap: false
|
||||||
|
|
|
||||||
|
|
@ -6,23 +6,20 @@ import qs.Commons
|
||||||
import qs.Services
|
import qs.Services
|
||||||
import qs.Widgets
|
import qs.Widgets
|
||||||
|
|
||||||
Loader {
|
Variants {
|
||||||
active: CompositorService.isNiri
|
model: Quickshell.screens
|
||||||
|
|
||||||
Component.onCompleted: {
|
delegate: Loader {
|
||||||
if (CompositorService.isNiri) {
|
required property ShellScreen modelData
|
||||||
Logger.log("Overview", "Loading Overview component for Niri")
|
property string wallpaperSource: WallpaperService.getWallpaper(modelData.name)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceComponent: Variants {
|
active: CompositorService.isNiri && wallpaperSource !== ""
|
||||||
model: Quickshell.screens
|
|
||||||
|
|
||||||
delegate: PanelWindow {
|
sourceComponent: PanelWindow {
|
||||||
required property ShellScreen modelData
|
Component.onCompleted: {
|
||||||
property string wallpaperSource: WallpaperService.getWallpaper(modelData.name)
|
Logger.log("Overview", "Loading Overview component for Niri on", modelData.name)
|
||||||
|
}
|
||||||
|
|
||||||
visible: wallpaperSource !== ""
|
|
||||||
color: Color.transparent
|
color: Color.transparent
|
||||||
screen: modelData
|
screen: modelData
|
||||||
WlrLayershell.layer: WlrLayer.Background
|
WlrLayershell.layer: WlrLayer.Background
|
||||||
|
|
@ -38,19 +35,15 @@ Loader {
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: bgImage
|
id: bgImage
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
fillMode: Image.PreserveAspectCrop
|
fillMode: Image.PreserveAspectCrop
|
||||||
source: wallpaperSource
|
source: wallpaperSource
|
||||||
cache: true
|
cache: true
|
||||||
smooth: true
|
smooth: true
|
||||||
mipmap: false
|
mipmap: false
|
||||||
visible: wallpaperSource !== ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiEffect {
|
MultiEffect {
|
||||||
id: overviewBgBlur
|
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
source: bgImage
|
source: bgImage
|
||||||
blurEnabled: true
|
blurEnabled: true
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ Loader {
|
||||||
id: lockBgImage
|
id: lockBgImage
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
fillMode: Image.PreserveAspectCrop
|
fillMode: Image.PreserveAspectCrop
|
||||||
source: WallpaperService.currentWallpaper !== "" ? WallpaperService.currentWallpaper : ""
|
source: WallpaperService.getWallpaper(screen.name)
|
||||||
cache: true
|
cache: true
|
||||||
smooth: true
|
smooth: true
|
||||||
mipmap: false
|
mipmap: false
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,9 @@ ColumnLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: 140 * scaling
|
Layout.preferredHeight: 140 * scaling
|
||||||
radius: Style.radiusM * scaling
|
radius: Style.radiusM * scaling
|
||||||
color: Color.mPrimary
|
color: Color.mSecondary
|
||||||
|
|
||||||
NImageRounded {
|
NImageRounded {
|
||||||
id: currentWallpaperImage
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: Style.marginXS * scaling
|
anchors.margins: Style.marginXS * scaling
|
||||||
imagePath: WallpaperService.getWallpaper(screen.name)
|
imagePath: WallpaperService.getWallpaper(screen.name)
|
||||||
|
|
@ -113,7 +112,7 @@ ColumnLayout {
|
||||||
id: wallpaperItem
|
id: wallpaperItem
|
||||||
|
|
||||||
property string wallpaperPath: modelData
|
property string wallpaperPath: modelData
|
||||||
property bool isSelected: wallpaperPath === WallpaperService.currentWallpaper
|
property bool isSelected: wallpaperPath === WallpaperService.getWallpaper(screen.name)
|
||||||
|
|
||||||
width: wallpaperGridView.itemSize
|
width: wallpaperGridView.itemSize
|
||||||
height: Math.floor(wallpaperGridView.itemSize * 0.67)
|
height: Math.floor(wallpaperGridView.itemSize * 0.67)
|
||||||
|
|
|
||||||
|
|
@ -146,16 +146,7 @@ ColumnLayout {
|
||||||
spacing: Style.marginS * scaling
|
spacing: Style.marginS * scaling
|
||||||
|
|
||||||
// Factorized presets data
|
// Factorized presets data
|
||||||
property var intervalPresets: [
|
property var intervalPresets: [5 * 60, 10 * 60, 15 * 60, 30 * 60, 45 * 60, 60 * 60, 90 * 60, 120 * 60]
|
||||||
5 * 60,
|
|
||||||
10 * 60,
|
|
||||||
15 * 60,
|
|
||||||
30 * 60,
|
|
||||||
45 * 60,
|
|
||||||
60 * 60,
|
|
||||||
90 * 60,
|
|
||||||
120 * 60,
|
|
||||||
]
|
|
||||||
|
|
||||||
// Whether current interval equals one of the presets
|
// Whether current interval equals one of the presets
|
||||||
property bool isCurrentPreset: {
|
property bool isCurrentPreset: {
|
||||||
|
|
@ -237,7 +228,7 @@ ColumnLayout {
|
||||||
property int seconds: 0
|
property int seconds: 0
|
||||||
property string label: ""
|
property string label: ""
|
||||||
property bool selected: false
|
property bool selected: false
|
||||||
signal clicked()
|
signal clicked
|
||||||
|
|
||||||
radius: height * 0.5
|
radius: height * 0.5
|
||||||
color: selected ? Color.mPrimary : Color.mSurfaceVariant
|
color: selected ? Color.mPrimary : Color.mSurfaceVariant
|
||||||
|
|
@ -266,4 +257,4 @@ ColumnLayout {
|
||||||
Layout.topMargin: Style.marginXL * scaling
|
Layout.topMargin: Style.marginXL * scaling
|
||||||
Layout.bottomMargin: Style.marginXL * scaling
|
Layout.bottomMargin: Style.marginXL * scaling
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ Singleton {
|
||||||
// Ensure cache dir exists
|
// Ensure cache dir exists
|
||||||
Quickshell.execDetached(["mkdir", "-p", Settings.cacheDir])
|
Quickshell.execDetached(["mkdir", "-p", Settings.cacheDir])
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: fix matugen
|
||||||
var content = buildConfigToml()
|
var content = buildConfigToml()
|
||||||
var mode = Settings.data.colorSchemes.darkMode ? "dark" : "light"
|
var mode = Settings.data.colorSchemes.darkMode ? "dark" : "light"
|
||||||
var wp = WallpaperService.currentWallpaper.replace(/'/g, "'\\''")
|
var wp = WallpaperService.currentWallpaper.replace(/'/g, "'\\''")
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,6 @@ Singleton {
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
Logger.log("Wallpaper", "Service started")
|
Logger.log("Wallpaper", "Service started")
|
||||||
listWallpapers()
|
|
||||||
|
|
||||||
// Wallpaper is set when the settings are loaded.
|
|
||||||
// Don't start random wallpaper during initialization
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property ListModel transitionsModel: ListModel {
|
readonly property ListModel transitionsModel: ListModel {
|
||||||
|
|
@ -33,9 +29,9 @@ Singleton {
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: Settings.data.wallpaper
|
target: Settings.data.wallpaper
|
||||||
onDirectoryChanged: WallpaperService.listWallpapers()
|
function onDirectoryChanged() { console.log("ondirchanged") ; root.listWallpapers() }
|
||||||
onRandomEnabledChanged: WallpaperService.toggleRandomWallpaper()
|
function onRandomEnabledChanged() { root.toggleRandomWallpaper() }
|
||||||
onRandomIntervalChanged: WallpaperService.restartRandomWallpaperTimer()
|
function onRandomIntervalSecChanged() { root.restartRandomWallpaperTimer() }
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
@ -87,7 +83,7 @@ Singleton {
|
||||||
function getWallpaper(screenName) {
|
function getWallpaper(screenName) {
|
||||||
// Logger.log("Wallpaper", "getWallpaper on", screenName)
|
// Logger.log("Wallpaper", "getWallpaper on", screenName)
|
||||||
var monitor = geMonitorDefinition(screenName)
|
var monitor = geMonitorDefinition(screenName)
|
||||||
if (monitor !== undefined) {
|
if ((monitor !== undefined) && (monitor["wallpaper"] !== undefined)) {
|
||||||
return monitor["wallpaper"]
|
return monitor["wallpaper"]
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
|
|
@ -95,8 +91,9 @@ Singleton {
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
function changeWallpaper(screenName, path) {
|
function changeWallpaper(screenName, path) {
|
||||||
|
Logger.log("Changing wallpaper")
|
||||||
if (screenName !== undefined) {
|
if (screenName !== undefined) {
|
||||||
setCurrentWallpaper(screenName, path, false)
|
setCurrentWallpaper(screenName, path)
|
||||||
} else {
|
} else {
|
||||||
for (var i = 0; i < Quickshell.screens.length; i++) {
|
for (var i = 0; i < Quickshell.screens.length; i++) {
|
||||||
setCurrentWallpaper(Quickshell.screens[i].name, path, false)
|
setCurrentWallpaper(Quickshell.screens[i].name, path, false)
|
||||||
|
|
@ -105,7 +102,11 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
function setCurrentWallpaper(screenName, path, isInitial) {
|
function setCurrentWallpaper(screenName, path) {
|
||||||
|
if (path === "" || path === undefined) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (screenName === undefined) {
|
if (screenName === undefined) {
|
||||||
Logger.warn("Wallpaper", "setCurrentWallpaper", "no screen specified")
|
Logger.warn("Wallpaper", "setCurrentWallpaper", "no screen specified")
|
||||||
return
|
return
|
||||||
|
|
@ -113,50 +114,51 @@ Singleton {
|
||||||
|
|
||||||
Logger.log("Wallpaper", "setCurrentWallpaper on", screenName, ": ", path)
|
Logger.log("Wallpaper", "setCurrentWallpaper on", screenName, ": ", path)
|
||||||
|
|
||||||
|
var wallpaperChanged = false
|
||||||
|
|
||||||
var monitor = geMonitorDefinition(screenName)
|
var monitor = geMonitorDefinition(screenName)
|
||||||
if (monitor !== undefined) {
|
if (monitor !== undefined) {
|
||||||
|
wallpaperChanged = (monitor["wallpaper"] !== path)
|
||||||
monitor["wallpaper"] = path
|
monitor["wallpaper"] = path
|
||||||
} else {
|
} else {
|
||||||
|
wallpaperChanged = true
|
||||||
Settings.data.wallpaper.monitors.push({
|
Settings.data.wallpaper.monitors.push({
|
||||||
"name": screenName,
|
"name": screenName,
|
||||||
"directory": Settings.data.wallpaper.directory,
|
"directory": Settings.data.wallpaper.directory,
|
||||||
"wallpaper": path
|
"wallpaper": path
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Only regenerate colors if the wallpaper actually changed
|
// Restart the random wallpaper timer
|
||||||
// var wallpaperChanged = currentWallpaper !== path
|
|
||||||
|
|
||||||
// currentWallpaper = path
|
|
||||||
// if (!isInitial) {
|
|
||||||
// Settings.data.wallpaper.current = path
|
|
||||||
// }
|
|
||||||
if (randomWallpaperTimer.running) {
|
if (randomWallpaperTimer.running) {
|
||||||
randomWallpaperTimer.restart()
|
randomWallpaperTimer.restart()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only notify ColorScheme service if the wallpaper actually changed
|
// Notify ColorScheme service if the wallpaper actually changed
|
||||||
// if (wallpaperChanged) {
|
if (wallpaperChanged) {
|
||||||
// ColorSchemeService.changedWallpaper()
|
ColorSchemeService.changedWallpaper()
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
function setRandomWallpaper() {
|
function setRandomWallpaper() {
|
||||||
var randomIndex = Math.floor(Math.random() * wallpaperList.length)
|
Logger.log("Wallpaper", "setRandomWallpaper");
|
||||||
var randomPath = wallpaperList[randomIndex]
|
for (var i = 0; i < Quickshell.screens.length; i++) {
|
||||||
if (!randomPath) {
|
var screenName = Quickshell.screens[i].name
|
||||||
return
|
// TODO one list per monitor
|
||||||
|
var randomIndex = Math.floor(Math.random() * wallpaperList.length)
|
||||||
|
var randomPath = wallpaperList[randomIndex]
|
||||||
|
setCurrentWallpaper(screenName, randomPath)
|
||||||
}
|
}
|
||||||
setCurrentWallpaper(randomPath, false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
function toggleRandomWallpaper() {
|
function toggleRandomWallpaper() {
|
||||||
if (Settings.data.wallpaper.isRandom && !randomWallpaperTimer.running) {
|
Logger.log("Wallpaper", "toggleRandomWallpaper")
|
||||||
|
if (Settings.data.wallpaper.randomEnabled && !randomWallpaperTimer.running) {
|
||||||
randomWallpaperTimer.start()
|
randomWallpaperTimer.start()
|
||||||
setRandomWallpaper()
|
setRandomWallpaper()
|
||||||
} else if (!Settings.data.randomWallpaper && randomWallpaperTimer.running) {
|
} else if (!Settings.data.wallpaper.randomEnabled && randomWallpaperTimer.running) {
|
||||||
randomWallpaperTimer.stop()
|
randomWallpaperTimer.stop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,6 @@
|
||||||
libnotify
|
libnotify
|
||||||
matugen
|
matugen
|
||||||
networkmanager
|
networkmanager
|
||||||
swww
|
|
||||||
wl-clipboard
|
wl-clipboard
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue