mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-08 06:25:37 -05:00
hide wallpaper engine unless they are available
This commit is contained in:
@@ -32,6 +32,9 @@ DankModal {
|
|||||||
property bool selectedFileIsDir: false
|
property bool selectedFileIsDir: false
|
||||||
property bool showOverwriteConfirmation: false
|
property bool showOverwriteConfirmation: false
|
||||||
property string pendingFilePath: ""
|
property string pendingFilePath: ""
|
||||||
|
property bool weAvailable: false
|
||||||
|
property string wePath: ""
|
||||||
|
property bool weMode: false
|
||||||
|
|
||||||
signal fileSelected(string path)
|
signal fileSelected(string path)
|
||||||
|
|
||||||
@@ -131,6 +134,31 @@ DankModal {
|
|||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
currentPath = getLastPath()
|
currentPath = getLastPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
property var steamPaths: [
|
||||||
|
StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/.steam/steam/steamapps/workshop/content/431960",
|
||||||
|
StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/.local/share/Steam/steamapps/workshop/content/431960",
|
||||||
|
StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/workshop/content/431960",
|
||||||
|
StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/snap/steam/common/.local/share/Steam/steamapps/workshop/content/431960"
|
||||||
|
]
|
||||||
|
property int currentPathIndex: 0
|
||||||
|
|
||||||
|
function discoverWallpaperEngine() {
|
||||||
|
currentPathIndex = 0
|
||||||
|
checkNextPath()
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkNextPath() {
|
||||||
|
if (currentPathIndex >= steamPaths.length) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const wePath = steamPaths[currentPathIndex]
|
||||||
|
const cleanPath = wePath.replace(/^file:\/\//, '')
|
||||||
|
weDiscoveryProcess.command = ["test", "-d", cleanPath]
|
||||||
|
weDiscoveryProcess.wePath = wePath
|
||||||
|
weDiscoveryProcess.running = true
|
||||||
|
}
|
||||||
width: 800
|
width: 800
|
||||||
height: 600
|
height: 600
|
||||||
enableShadow: true
|
enableShadow: true
|
||||||
@@ -148,6 +176,9 @@ DankModal {
|
|||||||
selectedIndex = -1
|
selectedIndex = -1
|
||||||
keyboardNavigationActive = false
|
keyboardNavigationActive = false
|
||||||
backButtonFocused = false
|
backButtonFocused = false
|
||||||
|
if (browserType === "wallpaper" && !weAvailable) {
|
||||||
|
discoverWallpaperEngine()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onCurrentPathChanged: {
|
onCurrentPathChanged: {
|
||||||
@@ -335,6 +366,23 @@ DankModal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: weDiscoveryProcess
|
||||||
|
|
||||||
|
property string wePath: ""
|
||||||
|
running: false
|
||||||
|
|
||||||
|
onExited: exitCode => {
|
||||||
|
if (exitCode === 0) {
|
||||||
|
fileBrowserModal.weAvailable = true
|
||||||
|
fileBrowserModal.wePath = wePath
|
||||||
|
} else {
|
||||||
|
currentPathIndex++
|
||||||
|
checkNextPath()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
content: Component {
|
content: Component {
|
||||||
Item {
|
Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -373,6 +421,22 @@ DankModal {
|
|||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
spacing: Theme.spacingS
|
spacing: Theme.spacingS
|
||||||
|
|
||||||
|
DankActionButton {
|
||||||
|
circular: false
|
||||||
|
iconName: "movie"
|
||||||
|
iconSize: Theme.iconSize - 4
|
||||||
|
iconColor: weMode ? Theme.primary : Theme.surfaceText
|
||||||
|
visible: weAvailable && browserType === "wallpaper"
|
||||||
|
onClicked: {
|
||||||
|
weMode = !weMode
|
||||||
|
if (weMode) {
|
||||||
|
navigateTo(wePath)
|
||||||
|
} else {
|
||||||
|
navigateTo(getLastPath())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DankActionButton {
|
DankActionButton {
|
||||||
circular: false
|
circular: false
|
||||||
iconName: "info"
|
iconName: "info"
|
||||||
@@ -439,8 +503,8 @@ DankModal {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height - 80
|
height: parent.height - 80
|
||||||
clip: true
|
clip: true
|
||||||
cellWidth: fileBrowserModal.browserType === "we" ? 255 : 150
|
cellWidth: weMode ? 255 : 150
|
||||||
cellHeight: fileBrowserModal.browserType === "we" ? 215 : 130
|
cellHeight: weMode ? 215 : 130
|
||||||
cacheBuffer: 260
|
cacheBuffer: 260
|
||||||
model: folderModel
|
model: folderModel
|
||||||
currentIndex: selectedIndex
|
currentIndex: selectedIndex
|
||||||
@@ -466,8 +530,8 @@ DankModal {
|
|||||||
required property url fileURL
|
required property url fileURL
|
||||||
required property int index
|
required property int index
|
||||||
|
|
||||||
width: fileBrowserModal.browserType === "we" ? 245 : 140
|
width: weMode ? 245 : 140
|
||||||
height: fileBrowserModal.browserType === "we" ? 205 : 120
|
height: weMode ? 205 : 120
|
||||||
radius: Theme.cornerRadius
|
radius: Theme.cornerRadius
|
||||||
color: {
|
color: {
|
||||||
if (keyboardNavigationActive && delegateRoot.index === selectedIndex)
|
if (keyboardNavigationActive && delegateRoot.index === selectedIndex)
|
||||||
@@ -498,31 +562,33 @@ DankModal {
|
|||||||
spacing: Theme.spacingXS
|
spacing: Theme.spacingXS
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
width: fileBrowserModal.browserType === "we" ? 225 : 80
|
width: weMode ? 225 : 80
|
||||||
height: fileBrowserModal.browserType === "we" ? 165 : 60
|
height: weMode ? 165 : 60
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
||||||
CachingImage {
|
CachingImage {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
property var weExtensions: [".jpg", ".png", ".webp", ".gif", ".jpeg"]
|
property var weExtensions: [".jpg", ".jpeg", ".png", ".webp", ".gif", ".bmp", ".tga"]
|
||||||
property int weExtIndex: 0
|
property int weExtIndex: 0
|
||||||
source: {
|
source: {
|
||||||
if (fileBrowserModal.browserType === "we" && delegateRoot.fileIsDir) {
|
if (weMode && delegateRoot.fileIsDir) {
|
||||||
return "file://" + delegateRoot.filePath + "/preview" + weExtensions[weExtIndex]
|
return "file://" + delegateRoot.filePath + "/preview" + weExtensions[weExtIndex]
|
||||||
}
|
}
|
||||||
return (!delegateRoot.fileIsDir && isImageFile(delegateRoot.fileName)) ? ("file://" + delegateRoot.filePath) : ""
|
return (!delegateRoot.fileIsDir && isImageFile(delegateRoot.fileName)) ? ("file://" + delegateRoot.filePath) : ""
|
||||||
}
|
}
|
||||||
onStatusChanged: {
|
onStatusChanged: {
|
||||||
if (fileBrowserModal.browserType === "we" && delegateRoot.fileIsDir && status === Image.Error) {
|
if (weMode && delegateRoot.fileIsDir && status === Image.Error) {
|
||||||
if (weExtIndex < weExtensions.length - 1) {
|
if (weExtIndex < weExtensions.length - 1) {
|
||||||
weExtIndex++
|
weExtIndex++
|
||||||
source = "file://" + delegateRoot.filePath + "/preview" + weExtensions[weExtIndex]
|
source = "file://" + delegateRoot.filePath + "/preview" + weExtensions[weExtIndex]
|
||||||
|
} else {
|
||||||
|
source = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fillMode: Image.PreserveAspectCrop
|
fillMode: Image.PreserveAspectCrop
|
||||||
visible: (!delegateRoot.fileIsDir && isImageFile(delegateRoot.fileName)) || (fileBrowserModal.browserType === "we" && delegateRoot.fileIsDir)
|
visible: (!delegateRoot.fileIsDir && isImageFile(delegateRoot.fileName)) || (weMode && delegateRoot.fileIsDir)
|
||||||
maxCacheSize: fileBrowserModal.browserType === "we" ? 225 : 80
|
maxCacheSize: weMode ? 225 : 80
|
||||||
}
|
}
|
||||||
|
|
||||||
DankIcon {
|
DankIcon {
|
||||||
@@ -538,7 +604,7 @@ DankModal {
|
|||||||
name: "folder"
|
name: "folder"
|
||||||
size: Theme.iconSizeLarge
|
size: Theme.iconSizeLarge
|
||||||
color: Theme.primary
|
color: Theme.primary
|
||||||
visible: delegateRoot.fileIsDir && fileBrowserModal.browserType !== "we"
|
visible: delegateRoot.fileIsDir && !weMode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -565,15 +631,15 @@ DankModal {
|
|||||||
// Update selected file info and index first
|
// Update selected file info and index first
|
||||||
selectedIndex = delegateRoot.index
|
selectedIndex = delegateRoot.index
|
||||||
setSelectedFileData(delegateRoot.filePath, delegateRoot.fileName, delegateRoot.fileIsDir)
|
setSelectedFileData(delegateRoot.filePath, delegateRoot.fileName, delegateRoot.fileIsDir)
|
||||||
if (fileBrowserModal.browserType === "we" && delegateRoot.fileIsDir) {
|
if (weMode && delegateRoot.fileIsDir) {
|
||||||
// Select this folder instead of navigating inside
|
var sceneId = delegateRoot.filePath.split("/").pop()
|
||||||
fileSelected(delegateRoot.filePath)
|
fileSelected("we:" + sceneId)
|
||||||
fileBrowserModal.close()
|
fileBrowserModal.close()
|
||||||
} if (delegateRoot.fileIsDir) {
|
} else if (delegateRoot.fileIsDir) {
|
||||||
navigateTo(delegateRoot.filePath)
|
navigateTo(delegateRoot.filePath)
|
||||||
} else {
|
} else {
|
||||||
fileSelected(delegateRoot.filePath)
|
fileSelected(delegateRoot.filePath)
|
||||||
fileBrowserModal.close() // Close modal after file selection
|
fileBrowserModal.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -585,7 +651,11 @@ DankModal {
|
|||||||
fileBrowserModal.keyboardSelectionRequested = false
|
fileBrowserModal.keyboardSelectionRequested = false
|
||||||
selectedIndex = delegateRoot.index
|
selectedIndex = delegateRoot.index
|
||||||
setSelectedFileData(delegateRoot.filePath, delegateRoot.fileName, delegateRoot.fileIsDir)
|
setSelectedFileData(delegateRoot.filePath, delegateRoot.fileName, delegateRoot.fileIsDir)
|
||||||
if (delegateRoot.fileIsDir) {
|
if (weMode && delegateRoot.fileIsDir) {
|
||||||
|
var sceneId = delegateRoot.filePath.split("/").pop()
|
||||||
|
fileSelected("we:" + sceneId)
|
||||||
|
fileBrowserModal.close()
|
||||||
|
} else if (delegateRoot.fileIsDir) {
|
||||||
navigateTo(delegateRoot.filePath)
|
navigateTo(delegateRoot.filePath)
|
||||||
} else {
|
} else {
|
||||||
fileSelected(delegateRoot.filePath)
|
fileSelected(delegateRoot.filePath)
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ Item {
|
|||||||
CachingImage {
|
CachingImage {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: 1
|
anchors.margins: 1
|
||||||
property var weExtensions: [".jpg", ".png", ".webp", ".gif", ".jpeg"]
|
property var weExtensions: [".jpg", ".jpeg", ".png", ".webp", ".gif", ".bmp", ".tga"]
|
||||||
property int weExtIndex: 0
|
property int weExtIndex: 0
|
||||||
source: {
|
source: {
|
||||||
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath
|
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath
|
||||||
@@ -156,12 +156,16 @@ Item {
|
|||||||
}
|
}
|
||||||
onStatusChanged: {
|
onStatusChanged: {
|
||||||
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath
|
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath
|
||||||
if (currentWallpaper.startsWith("we:") && status === Image.Error && weExtIndex < weExtensions.length - 1) {
|
if (currentWallpaper && currentWallpaper.startsWith("we:") && status === Image.Error) {
|
||||||
|
if (weExtIndex < weExtensions.length - 1) {
|
||||||
weExtIndex++
|
weExtIndex++
|
||||||
source = StandardPaths.writableLocation(StandardPaths.HomeLocation)
|
source = StandardPaths.writableLocation(StandardPaths.HomeLocation)
|
||||||
+ "/.local/share/Steam/steamapps/workshop/content/431960/"
|
+ "/.local/share/Steam/steamapps/workshop/content/431960/"
|
||||||
+ currentWallpaper.substring(3)
|
+ currentWallpaper.substring(3)
|
||||||
+ "/preview" + weExtensions[weExtIndex]
|
+ "/preview" + weExtensions[weExtIndex]
|
||||||
|
} else {
|
||||||
|
visible = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fillMode: Image.PreserveAspectCrop
|
fillMode: Image.PreserveAspectCrop
|
||||||
@@ -253,29 +257,6 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
width: 32; height: 32; radius: 16
|
|
||||||
color: Qt.rgba(255, 255, 255, 0.9)
|
|
||||||
|
|
||||||
DankIcon {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
name: "movie" // 🎬 icon for WE
|
|
||||||
size: 18
|
|
||||||
color: "black"
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
onClicked: {
|
|
||||||
if (parentModal) {
|
|
||||||
parentModal.allowFocusOverride = true
|
|
||||||
parentModal.shouldHaveFocus = false
|
|
||||||
}
|
|
||||||
weBrowser.open()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: 32
|
width: 32
|
||||||
@@ -1467,37 +1448,6 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileBrowserModal {
|
|
||||||
id: weBrowser
|
|
||||||
browserTitle: "Select Wallpaper Engine Scene"
|
|
||||||
browserIcon: "movie"
|
|
||||||
browserType: "we"
|
|
||||||
fileExtensions: [] // only show dirs
|
|
||||||
|
|
||||||
// override homeDir to point to Steam workshop path
|
|
||||||
homeDir: StandardPaths.writableLocation(StandardPaths.HomeLocation)
|
|
||||||
+ "/.local/share/Steam/steamapps/workshop/content/431960"
|
|
||||||
|
|
||||||
// ensure we start there
|
|
||||||
Component.onCompleted: currentPath = homeDir
|
|
||||||
|
|
||||||
function getLastPath() {
|
|
||||||
return homeDir
|
|
||||||
}
|
|
||||||
|
|
||||||
onFileSelected: folderPath => {
|
|
||||||
var sceneId = folderPath.split("/").pop()
|
|
||||||
var weSource = "we:" + sceneId
|
|
||||||
if (SessionData.perMonitorWallpaper) {
|
|
||||||
SessionData.setMonitorWallpaper(selectedMonitorName, weSource)
|
|
||||||
} else {
|
|
||||||
SessionData.setWallpaper(weSource)
|
|
||||||
}
|
|
||||||
close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DankColorPicker {
|
DankColorPicker {
|
||||||
id: colorPicker
|
id: colorPicker
|
||||||
|
|||||||
@@ -21,30 +21,23 @@ Item {
|
|||||||
command: []
|
command: []
|
||||||
onExited: (code) => {
|
onExited: (code) => {
|
||||||
if (pendingSceneId !== "") {
|
if (pendingSceneId !== "") {
|
||||||
const cacheHome = StandardPaths.writableLocation(StandardPaths.CacheLocation).toString()
|
|
||||||
const baseDir = cacheHome.startsWith("file://") ? cacheHome.substring(7) : cacheHome
|
|
||||||
const outDir = baseDir + "/dankshell/we_screenshots"
|
|
||||||
const outPath = outDir + "/" + pendingSceneId + ".jpg"
|
|
||||||
|
|
||||||
Quickshell.execDetached(["mkdir", "-p", outDir])
|
|
||||||
|
|
||||||
// only spawn after killer has done its job
|
|
||||||
weProcess.command = [
|
weProcess.command = [
|
||||||
"linux-wallpaperengine",
|
"linux-wallpaperengine",
|
||||||
"--screen-root", monitor,
|
"--screen-root", monitor,
|
||||||
"--screenshot",
|
"--bg", pendingSceneId,
|
||||||
outPath,
|
|
||||||
pendingSceneId,
|
|
||||||
"--silent"
|
"--silent"
|
||||||
]
|
]
|
||||||
weProcess.running = true
|
weProcess.running = true
|
||||||
|
sceneId = pendingSceneId
|
||||||
pendingSceneId = ""
|
pendingSceneId = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function start(newSceneId) {
|
function start(newSceneId) {
|
||||||
sceneId = newSceneId
|
if (sceneId === newSceneId && weProcess.running) {
|
||||||
|
return
|
||||||
|
}
|
||||||
pendingSceneId = newSceneId
|
pendingSceneId = newSceneId
|
||||||
stop()
|
stop()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user