mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-27 15:02:50 -05:00
wallpaper: pause cycling when locked, clean state when changing modes
This commit is contained in:
@@ -6,6 +6,7 @@ import Quickshell
|
|||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
import qs.Common
|
import qs.Common
|
||||||
|
import qs.Services
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
@@ -20,6 +21,7 @@ Singleton {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
readonly property bool shouldPauseCycling: anyFullscreen || SessionService.locked
|
||||||
property string cachedCyclingTime: SessionData.wallpaperCyclingTime
|
property string cachedCyclingTime: SessionData.wallpaperCyclingTime
|
||||||
property int cachedCyclingInterval: SessionData.wallpaperCyclingInterval
|
property int cachedCyclingInterval: SessionData.wallpaperCyclingInterval
|
||||||
property string lastTimeCheck: ""
|
property string lastTimeCheck: ""
|
||||||
@@ -34,7 +36,7 @@ Singleton {
|
|||||||
running: false
|
running: false
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (typeof WallpaperCyclingService !== "undefined" && targetScreen !== "" && !WallpaperCyclingService.anyFullscreen) {
|
if (typeof WallpaperCyclingService !== "undefined" && targetScreen !== "" && !WallpaperCyclingService.shouldPauseCycling) {
|
||||||
WallpaperCyclingService.cycleNextForMonitor(targetScreen);
|
WallpaperCyclingService.cycleNextForMonitor(targetScreen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,6 +115,16 @@ Singleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: SessionService
|
||||||
|
|
||||||
|
function onSessionUnlocked() {
|
||||||
|
if (SessionData.wallpaperCyclingEnabled || SessionData.perMonitorWallpaper) {
|
||||||
|
updateCyclingState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateCyclingState() {
|
function updateCyclingState() {
|
||||||
if (SessionData.perMonitorWallpaper) {
|
if (SessionData.perMonitorWallpaper) {
|
||||||
stopCycling();
|
stopCycling();
|
||||||
@@ -151,13 +163,18 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function startCycling() {
|
function startCycling() {
|
||||||
if (SessionData.wallpaperCyclingMode === "interval") {
|
switch (SessionData.wallpaperCyclingMode) {
|
||||||
|
case "interval":
|
||||||
|
lastTimeCheck = "";
|
||||||
intervalTimer.interval = cachedCyclingInterval * 1000;
|
intervalTimer.interval = cachedCyclingInterval * 1000;
|
||||||
intervalTimer.start();
|
intervalTimer.start();
|
||||||
cyclingActive = true;
|
cyclingActive = true;
|
||||||
} else if (SessionData.wallpaperCyclingMode === "time") {
|
break;
|
||||||
|
case "time":
|
||||||
|
intervalTimer.stop();
|
||||||
cyclingActive = true;
|
cyclingActive = true;
|
||||||
checkTimeBasedCycling();
|
checkTimeBasedCycling();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,23 +184,43 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function startMonitorCycling(screenName, settings) {
|
function startMonitorCycling(screenName, settings) {
|
||||||
if (settings.mode === "interval") {
|
switch (settings.mode) {
|
||||||
var timer = monitorTimers[screenName];
|
case "interval":
|
||||||
if (!timer && monitorTimerComponent && monitorTimerComponent.status === Component.Ready) {
|
{
|
||||||
var newTimers = Object.assign({}, monitorTimers);
|
var newChecks = Object.assign({}, monitorLastTimeChecks);
|
||||||
newTimers[screenName] = monitorTimerComponent.createObject(root);
|
delete newChecks[screenName];
|
||||||
newTimers[screenName].targetScreen = screenName;
|
monitorLastTimeChecks = newChecks;
|
||||||
monitorTimers = newTimers;
|
|
||||||
timer = monitorTimers[screenName];
|
var timer = monitorTimers[screenName];
|
||||||
|
if (!timer && monitorTimerComponent && monitorTimerComponent.status === Component.Ready) {
|
||||||
|
var newTimers = Object.assign({}, monitorTimers);
|
||||||
|
newTimers[screenName] = monitorTimerComponent.createObject(root);
|
||||||
|
newTimers[screenName].targetScreen = screenName;
|
||||||
|
monitorTimers = newTimers;
|
||||||
|
timer = monitorTimers[screenName];
|
||||||
|
}
|
||||||
|
if (timer) {
|
||||||
|
timer.interval = settings.interval * 1000;
|
||||||
|
timer.start();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (timer) {
|
case "time":
|
||||||
timer.interval = settings.interval * 1000;
|
{
|
||||||
timer.start();
|
var existingTimer = monitorTimers[screenName];
|
||||||
|
if (existingTimer) {
|
||||||
|
existingTimer.stop();
|
||||||
|
existingTimer.destroy();
|
||||||
|
var newTimers = Object.assign({}, monitorTimers);
|
||||||
|
delete newTimers[screenName];
|
||||||
|
monitorTimers = newTimers;
|
||||||
|
}
|
||||||
|
|
||||||
|
var newChecks = Object.assign({}, monitorLastTimeChecks);
|
||||||
|
newChecks[screenName] = "";
|
||||||
|
monitorLastTimeChecks = newChecks;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else if (settings.mode === "time") {
|
|
||||||
var newChecks = Object.assign({}, monitorLastTimeChecks);
|
|
||||||
newChecks[screenName] = "";
|
|
||||||
monitorLastTimeChecks = newChecks;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,7 +356,7 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function checkTimeBasedCycling() {
|
function checkTimeBasedCycling() {
|
||||||
if (anyFullscreen)
|
if (shouldPauseCycling)
|
||||||
return;
|
return;
|
||||||
const currentTime = Qt.formatTime(systemClock.date, "hh:mm");
|
const currentTime = Qt.formatTime(systemClock.date, "hh:mm");
|
||||||
|
|
||||||
@@ -367,7 +404,7 @@ Singleton {
|
|||||||
running: false
|
running: false
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (anyFullscreen)
|
if (shouldPauseCycling)
|
||||||
return;
|
return;
|
||||||
cycleToNextWallpaper();
|
cycleToNextWallpaper();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user