mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-07 22:15:38 -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 showOverwriteConfirmation: false
|
||||
property string pendingFilePath: ""
|
||||
property bool weAvailable: false
|
||||
property string wePath: ""
|
||||
property bool weMode: false
|
||||
|
||||
signal fileSelected(string path)
|
||||
|
||||
@@ -131,6 +134,31 @@ DankModal {
|
||||
Component.onCompleted: {
|
||||
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
|
||||
height: 600
|
||||
enableShadow: true
|
||||
@@ -148,6 +176,9 @@ DankModal {
|
||||
selectedIndex = -1
|
||||
keyboardNavigationActive = false
|
||||
backButtonFocused = false
|
||||
if (browserType === "wallpaper" && !weAvailable) {
|
||||
discoverWallpaperEngine()
|
||||
}
|
||||
}
|
||||
}
|
||||
onCurrentPathChanged: {
|
||||
@@ -334,6 +365,23 @@ DankModal {
|
||||
executeKeyboardSelection(targetIndex)
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: weDiscoveryProcess
|
||||
|
||||
property string wePath: ""
|
||||
running: false
|
||||
|
||||
onExited: exitCode => {
|
||||
if (exitCode === 0) {
|
||||
fileBrowserModal.weAvailable = true
|
||||
fileBrowserModal.wePath = wePath
|
||||
} else {
|
||||
currentPathIndex++
|
||||
checkNextPath()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
content: Component {
|
||||
Item {
|
||||
@@ -373,6 +421,22 @@ DankModal {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
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 {
|
||||
circular: false
|
||||
iconName: "info"
|
||||
@@ -439,8 +503,8 @@ DankModal {
|
||||
width: parent.width
|
||||
height: parent.height - 80
|
||||
clip: true
|
||||
cellWidth: fileBrowserModal.browserType === "we" ? 255 : 150
|
||||
cellHeight: fileBrowserModal.browserType === "we" ? 215 : 130
|
||||
cellWidth: weMode ? 255 : 150
|
||||
cellHeight: weMode ? 215 : 130
|
||||
cacheBuffer: 260
|
||||
model: folderModel
|
||||
currentIndex: selectedIndex
|
||||
@@ -466,8 +530,8 @@ DankModal {
|
||||
required property url fileURL
|
||||
required property int index
|
||||
|
||||
width: fileBrowserModal.browserType === "we" ? 245 : 140
|
||||
height: fileBrowserModal.browserType === "we" ? 205 : 120
|
||||
width: weMode ? 245 : 140
|
||||
height: weMode ? 205 : 120
|
||||
radius: Theme.cornerRadius
|
||||
color: {
|
||||
if (keyboardNavigationActive && delegateRoot.index === selectedIndex)
|
||||
@@ -498,31 +562,33 @@ DankModal {
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
Item {
|
||||
width: fileBrowserModal.browserType === "we" ? 225 : 80
|
||||
height: fileBrowserModal.browserType === "we" ? 165 : 60
|
||||
width: weMode ? 225 : 80
|
||||
height: weMode ? 165 : 60
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
CachingImage {
|
||||
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
|
||||
source: {
|
||||
if (fileBrowserModal.browserType === "we" && delegateRoot.fileIsDir) {
|
||||
if (weMode && delegateRoot.fileIsDir) {
|
||||
return "file://" + delegateRoot.filePath + "/preview" + weExtensions[weExtIndex]
|
||||
}
|
||||
return (!delegateRoot.fileIsDir && isImageFile(delegateRoot.fileName)) ? ("file://" + delegateRoot.filePath) : ""
|
||||
}
|
||||
onStatusChanged: {
|
||||
if (fileBrowserModal.browserType === "we" && delegateRoot.fileIsDir && status === Image.Error) {
|
||||
if (weMode && delegateRoot.fileIsDir && status === Image.Error) {
|
||||
if (weExtIndex < weExtensions.length - 1) {
|
||||
weExtIndex++
|
||||
source = "file://" + delegateRoot.filePath + "/preview" + weExtensions[weExtIndex]
|
||||
} else {
|
||||
source = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
visible: (!delegateRoot.fileIsDir && isImageFile(delegateRoot.fileName)) || (fileBrowserModal.browserType === "we" && delegateRoot.fileIsDir)
|
||||
maxCacheSize: fileBrowserModal.browserType === "we" ? 225 : 80
|
||||
visible: (!delegateRoot.fileIsDir && isImageFile(delegateRoot.fileName)) || (weMode && delegateRoot.fileIsDir)
|
||||
maxCacheSize: weMode ? 225 : 80
|
||||
}
|
||||
|
||||
DankIcon {
|
||||
@@ -538,7 +604,7 @@ DankModal {
|
||||
name: "folder"
|
||||
size: Theme.iconSizeLarge
|
||||
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
|
||||
selectedIndex = delegateRoot.index
|
||||
setSelectedFileData(delegateRoot.filePath, delegateRoot.fileName, delegateRoot.fileIsDir)
|
||||
if (fileBrowserModal.browserType === "we" && delegateRoot.fileIsDir) {
|
||||
// Select this folder instead of navigating inside
|
||||
fileSelected(delegateRoot.filePath)
|
||||
if (weMode && delegateRoot.fileIsDir) {
|
||||
var sceneId = delegateRoot.filePath.split("/").pop()
|
||||
fileSelected("we:" + sceneId)
|
||||
fileBrowserModal.close()
|
||||
} if (delegateRoot.fileIsDir) {
|
||||
} else if (delegateRoot.fileIsDir) {
|
||||
navigateTo(delegateRoot.filePath)
|
||||
} else {
|
||||
fileSelected(delegateRoot.filePath)
|
||||
fileBrowserModal.close() // Close modal after file selection
|
||||
fileBrowserModal.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -585,7 +651,11 @@ DankModal {
|
||||
fileBrowserModal.keyboardSelectionRequested = false
|
||||
selectedIndex = delegateRoot.index
|
||||
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)
|
||||
} else {
|
||||
fileSelected(delegateRoot.filePath)
|
||||
|
||||
Reference in New Issue
Block a user