1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-07 22:15:38 -05:00

wallpaper: fix per-monitor dankdash tab + allow matugen override

per-monitor

fixes #561
This commit is contained in:
bbedward
2025-10-27 15:36:07 -04:00
parent 7e5c6581c9
commit 7a3884a633
6 changed files with 676 additions and 442 deletions

View File

@@ -49,12 +49,16 @@ DankPopout {
property bool __contentReady: false
function __tryFocusOnce() {
if (!__focusArmed) return
if (!__focusArmed)
return
const win = root.window
if (!win || !win.visible) return
if (!contentLoader.item) return
if (!win || !win.visible)
return
if (!contentLoader.item)
return
if (win.requestActivate) win.requestActivate()
if (win.requestActivate)
win.requestActivate()
contentLoader.item.forceActiveFocus(Qt.TabFocusReason)
if (contentLoader.item.activeFocus)
@@ -78,14 +82,18 @@ DankPopout {
target: contentLoader
function onLoaded() {
__contentReady = true
if (__focusArmed) __tryFocusOnce()
if (__focusArmed)
__tryFocusOnce()
}
}
Connections {
target: root.window ? root.window : null
enabled: !!root.window
function onVisibleChanged() { if (__focusArmed) __tryFocusOnce() }
function onVisibleChanged() {
if (__focusArmed)
__tryFocusOnce()
}
}
onBackgroundClicked: {
@@ -111,14 +119,14 @@ DankPopout {
target: root
function onShouldBeVisibleChanged() {
if (root.shouldBeVisible) {
Qt.callLater(function() {
Qt.callLater(function () {
mainContainer.forceActiveFocus()
})
}
}
}
Keys.onPressed: function(event) {
Keys.onPressed: function (event) {
if (event.key === Qt.Key_Escape) {
root.dashVisible = false
event.accepted = true
@@ -216,32 +224,43 @@ DankPopout {
}
model: {
let tabs = [
{ icon: "dashboard", text: I18n.tr("Overview") },
{ icon: "music_note", text: I18n.tr("Media") },
{ icon: "wallpaper", text: I18n.tr("Wallpapers") }
]
let tabs = [{
"icon": "dashboard",
"text": I18n.tr("Overview")
}, {
"icon": "music_note",
"text": I18n.tr("Media")
}, {
"icon": "wallpaper",
"text": I18n.tr("Wallpapers")
}]
if (SettingsData.weatherEnabled) {
tabs.push({ icon: "wb_sunny", text: I18n.tr("Weather") })
tabs.push({
"icon": "wb_sunny",
"text": I18n.tr("Weather")
})
}
tabs.push({ icon: "settings", text: I18n.tr("Settings"), isAction: true })
tabs.push({
"icon": "settings",
"text": I18n.tr("Settings"),
"isAction": true
})
return tabs
}
onTabClicked: function(index) {
onTabClicked: function (index) {
root.currentTabIndex = index
}
onActionTriggered: function(index) {
onActionTriggered: function (index) {
let settingsIndex = SettingsData.weatherEnabled ? 4 : 3
if (index === settingsIndex) {
dashVisible = false
settingsModal.show()
}
}
}
Item {
@@ -253,10 +272,14 @@ DankPopout {
id: pages
width: parent.width
implicitHeight: {
if (currentIndex === 0) return overviewTab.implicitHeight
if (currentIndex === 1) return mediaTab.implicitHeight
if (currentIndex === 2) return wallpaperTab.implicitHeight
if (SettingsData.weatherEnabled && currentIndex === 3) return weatherTab.implicitHeight
if (currentIndex === 0)
return overviewTab.implicitHeight
if (currentIndex === 1)
return mediaTab.implicitHeight
if (currentIndex === 2)
return wallpaperTab.implicitHeight
if (SettingsData.weatherEnabled && currentIndex === 3)
return weatherTab.implicitHeight
return overviewTab.implicitHeight
}
currentIndex: root.currentTabIndex
@@ -286,6 +309,7 @@ DankPopout {
active: root.currentTabIndex === 2
tabBarItem: tabBar
keyForwardTarget: mainContainer
targetScreen: root.triggerScreen
}
WeatherTab {
@@ -296,4 +320,4 @@ DankPopout {
}
}
}
}
}

View File

@@ -29,9 +29,26 @@ Item {
property bool enableAnimation: false
property string homeDir: StandardPaths.writableLocation(StandardPaths.HomeLocation)
property string selectedFileName: ""
property var targetScreen: null
property string targetScreenName: targetScreen ? targetScreen.name : ""
signal requestTabChange(int newIndex)
function getCurrentWallpaper() {
if (SessionData.perMonitorWallpaper && targetScreenName) {
return SessionData.getMonitorWallpaper(targetScreenName)
}
return SessionData.wallpaperPath
}
function setCurrentWallpaper(path) {
if (SessionData.perMonitorWallpaper && targetScreenName) {
SessionData.setMonitorWallpaper(targetScreenName, path)
} else {
SessionData.setWallpaper(path)
}
}
onCurrentPageChanged: {
if (currentPage !== lastPage) {
enableAnimation = false
@@ -71,7 +88,7 @@ Item {
if (absoluteIndex < wallpaperFolderModel.count) {
const filePath = wallpaperFolderModel.get(absoluteIndex, "filePath")
if (filePath) {
SessionData.setWallpaper(filePath.toString().replace(/^file:\/\//, ''))
setCurrentWallpaper(filePath.toString().replace(/^file:\/\//, ''))
}
}
}
@@ -151,32 +168,39 @@ Item {
}
function setInitialSelection() {
if (!SessionData.wallpaperPath || wallpaperFolderModel.count === 0) {
const currentWallpaper = getCurrentWallpaper()
if (!currentWallpaper || wallpaperFolderModel.count === 0) {
gridIndex = 0
updateSelectedFileName()
Qt.callLater(() => { enableAnimation = true })
Qt.callLater(() => {
enableAnimation = true
})
return
}
for (let i = 0; i < wallpaperFolderModel.count; i++) {
for (var i = 0; i < wallpaperFolderModel.count; i++) {
const filePath = wallpaperFolderModel.get(i, "filePath")
if (filePath && filePath.toString().replace(/^file:\/\//, '') === SessionData.wallpaperPath) {
if (filePath && filePath.toString().replace(/^file:\/\//, '') === currentWallpaper) {
const targetPage = Math.floor(i / itemsPerPage)
const targetIndex = i % itemsPerPage
currentPage = targetPage
gridIndex = targetIndex
updateSelectedFileName()
Qt.callLater(() => { enableAnimation = true })
Qt.callLater(() => {
enableAnimation = true
})
return
}
}
gridIndex = 0
updateSelectedFileName()
Qt.callLater(() => { enableAnimation = true })
Qt.callLater(() => {
enableAnimation = true
})
}
function loadWallpaperDirectory() {
const currentWallpaper = SessionData.wallpaperPath
const currentWallpaper = getCurrentWallpaper()
if (!currentWallpaper || currentWallpaper.startsWith("#") || currentWallpaper.startsWith("we:")) {
if (CacheData.wallpaperLastPath && CacheData.wallpaperLastPath !== "") {
@@ -216,6 +240,19 @@ Item {
setInitialSelection()
}
}
function onMonitorWallpapersChanged() {
loadWallpaperDirectory()
if (visible && active) {
setInitialSelection()
}
}
}
onTargetScreenNameChanged: {
loadWallpaperDirectory()
if (visible && active) {
setInitialSelection()
}
}
Connections {
@@ -267,18 +304,18 @@ Item {
fileExtensions: ["*.jpg", "*.jpeg", "*.png", "*.bmp", "*.gif", "*.webp"]
allowStacking: true
onFileSelected: (path) => {
const cleanPath = path.replace(/^file:\/\//, '')
SessionData.setWallpaper(cleanPath)
onFileSelected: path => {
const cleanPath = path.replace(/^file:\/\//, '')
setCurrentWallpaper(cleanPath)
const dirPath = cleanPath.substring(0, cleanPath.lastIndexOf('/'))
if (dirPath) {
wallpaperDir = dirPath
CacheData.wallpaperLastPath = dirPath
CacheData.saveCache()
}
close()
}
const dirPath = cleanPath.substring(0, cleanPath.lastIndexOf('/'))
if (dirPath) {
wallpaperDir = dirPath
CacheData.wallpaperLastPath = dirPath
CacheData.saveCache()
}
close()
}
onDialogClosed: {
Qt.callLater(() => wallpaperBrowserLoader.active = false)
@@ -327,7 +364,7 @@ Item {
const startIndex = currentPage * itemsPerPage
const endIndex = Math.min(startIndex + itemsPerPage, wallpaperFolderModel.count)
const items = []
for (let i = startIndex; i < endIndex; i++) {
for (var i = startIndex; i < endIndex; i++) {
const filePath = wallpaperFolderModel.get(i, "filePath")
if (filePath) {
items.push(filePath.toString().replace(/^file:\/\//, ''))
@@ -369,7 +406,7 @@ Item {
height: wallpaperGrid.cellHeight
property string wallpaperPath: modelData || ""
property bool isSelected: SessionData.wallpaperPath === modelData
property bool isSelected: getCurrentWallpaper() === modelData
Rectangle {
id: wallpaperCard
@@ -437,7 +474,7 @@ Item {
onClicked: {
gridIndex = index
if (modelData) {
SessionData.setWallpaper(modelData)
setCurrentWallpaper(modelData)
}
}
}