1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-26 06:22:50 -05:00

wallpaper: encode image URIs

fixes #1306
This commit is contained in:
bbedward
2026-01-08 14:31:48 -05:00
parent f5f21e738a
commit a21a846bf5
11 changed files with 131 additions and 117 deletions

View File

@@ -40,6 +40,12 @@ Variants {
id: root
anchors.fill: parent
function encodeFileUrl(path) {
if (!path)
return "";
return "file://" + path.split('/').map(s => encodeURIComponent(s)).join('/');
}
property string source: SessionData.getMonitorWallpaper(modelData.name) || ""
property bool isColorSource: source.startsWith("#")
@@ -83,7 +89,7 @@ Variants {
isInitialized = true;
return;
}
const formattedSource = source.startsWith("file://") ? source : "file://" + source;
const formattedSource = source.startsWith("file://") ? source : encodeFileUrl(source);
setWallpaperImmediate(formattedSource);
isInitialized = true;
}
@@ -100,7 +106,7 @@ Variants {
return;
}
const formattedSource = source.startsWith("file://") ? source : "file://" + source;
const formattedSource = source.startsWith("file://") ? source : encodeFileUrl(source);
if (!isInitialized || !currentWallpaper.source) {
setWallpaperImmediate(formattedSource);

View File

@@ -1,7 +1,6 @@
import Qt.labs.folderlistmodel
import QtCore
import QtQuick
import QtQuick.Controls
import QtQuick.Effects
import qs.Common
import qs.Modals.FileBrowser
@@ -311,7 +310,7 @@ Item {
showFiles: true
showDirs: false
sortField: FolderListModel.Name
folder: wallpaperDir ? "file://" + wallpaperDir : ""
folder: wallpaperDir ? "file://" + wallpaperDir.split('/').map(s => encodeURIComponent(s)).join('/') : ""
}
FileBrowserSurfaceModal {
@@ -401,7 +400,9 @@ Item {
currentIndex = clampedIndex;
positionViewAtIndex(clampedIndex, GridView.Contain);
}
Qt.callLater(() => { enableAnimation = true; });
Qt.callLater(() => {
enableAnimation = true;
});
}
Connections {

View File

@@ -15,6 +15,12 @@ import qs.Modules.Lock
Item {
id: root
function encodeFileUrl(path) {
if (!path)
return "";
return "file://" + path.split('/').map(s => encodeURIComponent(s)).join('/');
}
readonly property string xdgDataDirs: Quickshell.env("XDG_DATA_DIRS")
property string screenName: ""
property string randomFact: ""
@@ -162,7 +168,7 @@ Item {
var _ = SessionData.perMonitorWallpaper;
var __ = SessionData.monitorWallpapers;
var currentWallpaper = SessionData.getMonitorWallpaper(screenName);
return (currentWallpaper && !currentWallpaper.startsWith("#")) ? currentWallpaper : "";
return (currentWallpaper && !currentWallpaper.startsWith("#")) ? encodeFileUrl(currentWallpaper) : "";
}
fillMode: Theme.getFillMode(GreetdSettings.wallpaperFillMode)
smooth: true
@@ -356,14 +362,10 @@ Item {
Layout.preferredWidth: 60
Layout.preferredHeight: 60
imageSource: {
if (PortalService.profileImage === "") {
if (PortalService.profileImage === "")
return "";
}
if (PortalService.profileImage.startsWith("/")) {
return "file://" + PortalService.profileImage;
}
if (PortalService.profileImage.startsWith("/"))
return encodeFileUrl(PortalService.profileImage);
return PortalService.profileImage;
}
fallbackIcon: "person"
@@ -1154,7 +1156,7 @@ Item {
required property string modelData
FolderListModel {
folder: "file://" + modelData
folder: encodeFileUrl(modelData)
nameFilters: ["*.desktop"]
showDirs: false
showDotAndDotDot: false

View File

@@ -14,6 +14,12 @@ import qs.Widgets
Item {
id: root
function encodeFileUrl(path) {
if (!path)
return "";
return "file://" + path.split('/').map(s => encodeURIComponent(s)).join('/');
}
property string passwordBuffer: ""
property bool demoMode: false
property string screenName: ""
@@ -170,7 +176,7 @@ Item {
anchors.fill: parent
source: {
var currentWallpaper = SessionData.getMonitorWallpaper(screenName);
return (currentWallpaper && !currentWallpaper.startsWith("#")) ? currentWallpaper : "";
return (currentWallpaper && !currentWallpaper.startsWith("#")) ? encodeFileUrl(currentWallpaper) : "";
}
fillMode: Theme.getFillMode(SettingsData.wallpaperFillMode)
smooth: true
@@ -659,14 +665,10 @@ Item {
Layout.preferredWidth: 60
Layout.preferredHeight: 60
imageSource: {
if (PortalService.profileImage === "") {
if (PortalService.profileImage === "")
return "";
}
if (PortalService.profileImage.startsWith("/")) {
return "file://" + PortalService.profileImage;
}
if (PortalService.profileImage.startsWith("/"))
return encodeFileUrl(PortalService.profileImage);
return PortalService.profileImage;
}
fallbackIcon: "person"

View File

@@ -389,7 +389,7 @@ Item {
CachingImage {
anchors.fill: parent
anchors.margins: 1
source: Theme.wallpaperPath ? "file://" + Theme.wallpaperPath : ""
imagePath: (Theme.wallpaperPath && !Theme.wallpaperPath.startsWith("#")) ? Theme.wallpaperPath : ""
fillMode: Image.PreserveAspectCrop
visible: Theme.wallpaperPath && !Theme.wallpaperPath.startsWith("#")
layer.enabled: true

View File

@@ -55,9 +55,9 @@ Item {
CachingImage {
anchors.fill: parent
anchors.margins: 1
source: {
imagePath: {
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath;
return (currentWallpaper !== "" && !currentWallpaper.startsWith("#")) ? "file://" + currentWallpaper : "";
return (currentWallpaper !== "" && !currentWallpaper.startsWith("#")) ? currentWallpaper : "";
}
fillMode: Image.PreserveAspectCrop
visible: {
@@ -391,9 +391,9 @@ Item {
CachingImage {
anchors.fill: parent
anchors.margins: 1
source: {
imagePath: {
var lightWallpaper = SessionData.wallpaperPathLight;
return (lightWallpaper !== "" && !lightWallpaper.startsWith("#")) ? "file://" + lightWallpaper : "";
return (lightWallpaper !== "" && !lightWallpaper.startsWith("#")) ? lightWallpaper : "";
}
fillMode: Image.PreserveAspectCrop
visible: {
@@ -575,9 +575,9 @@ Item {
CachingImage {
anchors.fill: parent
anchors.margins: 1
source: {
imagePath: {
var darkWallpaper = SessionData.wallpaperPathDark;
return (darkWallpaper !== "" && !darkWallpaper.startsWith("#")) ? "file://" + darkWallpaper : "";
return (darkWallpaper !== "" && !darkWallpaper.startsWith("#")) ? darkWallpaper : "";
}
fillMode: Image.PreserveAspectCrop
visible: {
@@ -968,17 +968,9 @@ Item {
SettingsDropdownRow {
id: intervalDropdown
property var intervalOptions: [
"5 seconds", "10 seconds", "15 seconds", "20 seconds", "25 seconds", "30 seconds",
"35 seconds", "40 seconds", "45 seconds", "50 seconds", "55 seconds",
"1 minute", "5 minutes", "15 minutes", "30 minutes", "1 hour", "1.5 hours", "2 hours",
"3 hours", "4 hours", "6 hours", "8 hours", "12 hours"
]
property var intervalOptions: ["5 seconds", "10 seconds", "15 seconds", "20 seconds", "25 seconds", "30 seconds", "35 seconds", "40 seconds", "45 seconds", "50 seconds", "55 seconds", "1 minute", "5 minutes", "15 minutes", "30 minutes", "1 hour", "1.5 hours", "2 hours", "3 hours", "4 hours", "6 hours", "8 hours", "12 hours"]
property var intervalValues: [
5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60,
300, 900, 1800, 3600, 5400, 7200, 10800, 14400, 21600, 28800, 43200
]
property var intervalValues: [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 300, 900, 1800, 3600, 5400, 7200, 10800, 14400, 21600, 28800, 43200]
tab: "wallpaper"
tags: ["interval", "cycling", "time", "frequency"]
settingKey: "wallpaperCyclingInterval"

View File

@@ -39,6 +39,12 @@ Variants {
id: root
anchors.fill: parent
function encodeFileUrl(path) {
if (!path)
return "";
return "file://" + path.split('/').map(s => encodeURIComponent(s)).join('/');
}
property string source: SessionData.getMonitorWallpaper(modelData.name) || ""
property bool isColorSource: source.startsWith("#")
property string transitionType: SessionData.wallpaperTransition
@@ -108,7 +114,7 @@ Variants {
isInitialized = true;
return;
}
const formattedSource = source.startsWith("file://") ? source : "file://" + source;
const formattedSource = source.startsWith("file://") ? source : encodeFileUrl(source);
setWallpaperImmediate(formattedSource);
isInitialized = true;
}
@@ -119,7 +125,7 @@ Variants {
return;
}
const formattedSource = source.startsWith("file://") ? source : "file://" + source;
const formattedSource = source.startsWith("file://") ? source : encodeFileUrl(source);
if (!isInitialized || !currentWallpaper.source) {
setWallpaperImmediate(formattedSource);