1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-27 06:52:50 -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)
}
}
}

View File

@@ -136,9 +136,7 @@ Item {
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath
if (currentWallpaper && currentWallpaper.startsWith("we:")) {
var sceneId = currentWallpaper.substring(3)
return StandardPaths.writableLocation(StandardPaths.HomeLocation)
+ "/.local/share/Steam/steamapps/workshop/content/431960/"
+ sceneId + "/preview" + weExtensions[weExtIndex]
return StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/.local/share/Steam/steamapps/workshop/content/431960/" + sceneId + "/preview" + weExtensions[weExtIndex]
}
return (currentWallpaper !== "" && !currentWallpaper.startsWith("#")) ? "file://" + currentWallpaper : ""
}
@@ -147,10 +145,7 @@ Item {
if (currentWallpaper && currentWallpaper.startsWith("we:") && status === Image.Error) {
if (weExtIndex < weExtensions.length - 1) {
weExtIndex++
source = StandardPaths.writableLocation(StandardPaths.HomeLocation)
+ "/.local/share/Steam/steamapps/workshop/content/431960/"
+ currentWallpaper.substring(3)
+ "/preview" + weExtensions[weExtIndex]
source = StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/.local/share/Steam/steamapps/workshop/content/431960/" + currentWallpaper.substring(3) + "/preview" + weExtensions[weExtIndex]
} else {
visible = false
}
@@ -241,7 +236,6 @@ Item {
}
}
Rectangle {
width: 32
height: 32
@@ -263,7 +257,7 @@ Item {
var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath
PopoutService.colorPickerModal.selectedColor = currentWallpaper.startsWith("#") ? currentWallpaper : Theme.primary
PopoutService.colorPickerModal.pickerTitle = "Choose Wallpaper Color"
PopoutService.colorPickerModal.onColorSelectedCallback = function(selectedColor) {
PopoutService.colorPickerModal.onColorSelectedCallback = function (selectedColor) {
if (SessionData.perMonitorWallpaper) {
SessionData.setMonitorWallpaper(selectedMonitorName, selectedColor)
} else {
@@ -434,11 +428,11 @@ Item {
return modes.indexOf(SettingsData.wallpaperFillMode)
}
onSelectionChanged: (index, selected) => {
if (selected) {
const modes = ["Stretch", "Fit", "Fill", "Tile", "TileVertically", "TileHorizontally", "Pad"]
SettingsData.setWallpaperFillMode(modes[index])
}
}
if (selected) {
const modes = ["Stretch", "Fit", "Fill", "Tile", "TileVertically", "TileHorizontally", "Pad"]
SettingsData.setWallpaperFillMode(modes[index])
}
}
Connections {
target: SettingsData
@@ -452,9 +446,9 @@ Item {
target: personalizationTab
function onSelectedMonitorNameChanged() {
Qt.callLater(() => {
const modes = ["Stretch", "Fit", "Fill", "Tile", "TileVertically", "TileHorizontally", "Pad"]
fillModeGroup.currentIndex = modes.indexOf(SettingsData.wallpaperFillMode)
})
const modes = ["Stretch", "Fit", "Fill", "Tile", "TileVertically", "TileHorizontally", "Pad"]
fillModeGroup.currentIndex = modes.indexOf(SettingsData.wallpaperFillMode)
})
}
}
}
@@ -507,8 +501,8 @@ Item {
anchors.verticalCenter: parent.verticalCenter
checked: SettingsData.blurWallpaperOnOverview
onToggled: checked => {
SettingsData.setBlurWallpaperOnOverview(checked)
}
SettingsData.setBlurWallpaperOnOverview(checked)
}
}
}
@@ -641,7 +635,7 @@ Item {
DankDropdown {
id: monitorDropdown
text: I18n.tr("Monitor")
text: I18n.tr("Wallpaper Monitor")
description: I18n.tr("Select monitor to configure wallpaper")
currentValue: selectedMonitorName || "No monitors"
options: {
@@ -656,6 +650,36 @@ Item {
selectedMonitorName = value
}
}
DankDropdown {
id: matugenTargetDropdown
text: I18n.tr("Matugen Target Monitor")
description: I18n.tr("Monitor whose wallpaper drives dynamic theming colors")
currentValue: {
if (!SettingsData.matugenTargetMonitor || SettingsData.matugenTargetMonitor === "") {
var screens = Quickshell.screens
return screens.length > 0 ? screens[0].name + " (Default)" : "No monitors"
}
return SettingsData.matugenTargetMonitor
}
options: {
var screenNames = []
var screens = Quickshell.screens
for (var i = 0; i < screens.length; i++) {
var label = screens[i].name
if (i === 0 && (!SettingsData.matugenTargetMonitor || SettingsData.matugenTargetMonitor === "")) {
label += " (Default)"
}
screenNames.push(label)
}
return screenNames
}
onValueChanged: value => {
var cleanValue = value.replace(" (Default)", "")
SettingsData.setMatugenTargetMonitor(cleanValue)
}
}
}
}
@@ -720,8 +744,8 @@ Item {
target: personalizationTab
function onSelectedMonitorNameChanged() {
cyclingToggle.checked = Qt.binding(() => {
return SessionData.perMonitorWallpaper ? SessionData.getMonitorCyclingSettings(selectedMonitorName).enabled : SessionData.wallpaperCyclingEnabled
})
return SessionData.perMonitorWallpaper ? SessionData.getMonitorCyclingSettings(selectedMonitorName).enabled : SessionData.wallpaperCyclingEnabled
})
}
}
}
@@ -779,12 +803,12 @@ Item {
target: personalizationTab
function onSelectedMonitorNameChanged() {
modeTabBar.currentIndex = Qt.binding(() => {
if (SessionData.perMonitorWallpaper) {
return SessionData.getMonitorCyclingSettings(selectedMonitorName).mode === "time" ? 1 : 0
} else {
return SessionData.wallpaperCyclingMode === "time" ? 1 : 0
}
})
if (SessionData.perMonitorWallpaper) {
return SessionData.getMonitorCyclingSettings(selectedMonitorName).mode === "time" ? 1 : 0
} else {
return SessionData.wallpaperCyclingMode === "time" ? 1 : 0
}
})
Qt.callLater(modeTabBar.updateIndicator)
}
}
@@ -835,15 +859,15 @@ Item {
function onSelectedMonitorNameChanged() {
// Force dropdown to refresh its currentValue
Qt.callLater(() => {
var currentSeconds
if (SessionData.perMonitorWallpaper) {
currentSeconds = SessionData.getMonitorCyclingSettings(selectedMonitorName).interval
} else {
currentSeconds = SessionData.wallpaperCyclingInterval
}
const index = intervalDropdown.intervalValues.indexOf(currentSeconds)
intervalDropdown.currentValue = index >= 0 ? intervalDropdown.intervalOptions[index] : "5 minutes"
})
var currentSeconds
if (SessionData.perMonitorWallpaper) {
currentSeconds = SessionData.getMonitorCyclingSettings(selectedMonitorName).interval
} else {
currentSeconds = SessionData.wallpaperCyclingInterval
}
const index = intervalDropdown.intervalValues.indexOf(currentSeconds)
intervalDropdown.currentValue = index >= 0 ? intervalDropdown.intervalOptions[index] : "5 minutes"
})
}
}
}
@@ -925,12 +949,12 @@ Item {
function onSelectedMonitorNameChanged() {
// Force text field to refresh its value
Qt.callLater(() => {
if (SessionData.perMonitorWallpaper) {
timeTextField.text = SessionData.getMonitorCyclingSettings(selectedMonitorName).time
} else {
timeTextField.text = SessionData.wallpaperCyclingTime
}
})
if (SessionData.perMonitorWallpaper) {
timeTextField.text = SessionData.getMonitorCyclingSettings(selectedMonitorName).time
} else {
timeTextField.text = SessionData.wallpaperCyclingTime
}
})
}
}
}
@@ -956,14 +980,15 @@ Item {
text: I18n.tr("Transition Effect")
description: I18n.tr("Visual effect used when wallpaper changes")
currentValue: {
if (SessionData.wallpaperTransition === "random") return "Random"
if (SessionData.wallpaperTransition === "random")
return "Random"
return SessionData.wallpaperTransition.charAt(0).toUpperCase() + SessionData.wallpaperTransition.slice(1)
}
options: ["Random"].concat(SessionData.availableWallpaperTransitions.map(t => t.charAt(0).toUpperCase() + t.slice(1)))
onValueChanged: value => {
var transition = value.toLowerCase()
SessionData.setWallpaperTransition(transition)
}
var transition = value.toLowerCase()
SessionData.setWallpaperTransition(transition)
}
}
Column {
@@ -995,17 +1020,17 @@ Item {
currentSelection: SessionData.includedTransitions
onSelectionChanged: (index, selected) => {
const transition = model[index]
let newIncluded = [...SessionData.includedTransitions]
const transition = model[index]
let newIncluded = [...SessionData.includedTransitions]
if (selected && !newIncluded.includes(transition)) {
newIncluded.push(transition)
} else if (!selected && newIncluded.includes(transition)) {
newIncluded = newIncluded.filter(t => t !== transition)
}
if (selected && !newIncluded.includes(transition)) {
newIncluded.push(transition)
} else if (!selected && newIncluded.includes(transition)) {
newIncluded = newIncluded.filter(t => t !== transition)
}
SessionData.includedTransitions = newIncluded
}
SessionData.includedTransitions = newIncluded
}
}
}
}
@@ -1065,8 +1090,8 @@ Item {
anchors.verticalCenter: parent.verticalCenter
checked: SettingsData.blurredWallpaperLayer
onToggled: checked => {
SettingsData.setBlurredWallpaperLayer(checked)
}
SettingsData.setBlurredWallpaperLayer(checked)
}
}
}
}
@@ -1122,9 +1147,9 @@ Item {
anchors.verticalCenter: parent.verticalCenter
checked: SessionData.isLightMode
onToggleCompleted: checked => {
Theme.screenTransition()
Theme.setLightMode(checked)
}
Theme.screenTransition()
Theme.setLightMode(checked)
}
}
}
}
@@ -1176,10 +1201,10 @@ Item {
selectionMode: "single"
currentIndex: SettingsData.animationSpeed
onSelectionChanged: (index, selected) => {
if (selected) {
SettingsData.setAnimationSpeed(index)
}
}
if (selected) {
SettingsData.setAnimationSpeed(index)
}
}
Connections {
target: SettingsData
@@ -1257,10 +1282,10 @@ Item {
showValue: false
wheelEnabled: false
onSliderValueChanged: (newValue) => {
SettingsData.setAnimationSpeed(SettingsData.AnimationSpeed.Custom)
SettingsData.setCustomAnimationDuration(newValue)
}
onSliderValueChanged: newValue => {
SettingsData.setAnimationSpeed(SettingsData.AnimationSpeed.Custom)
SettingsData.setCustomAnimationDuration(newValue)
}
Connections {
target: SettingsData
@@ -1388,19 +1413,21 @@ Item {
id: personalizationMatugenPaletteDropdown
text: I18n.tr("Matugen Palette")
description: I18n.tr("Select the palette algorithm used for wallpaper-based colors")
options: Theme.availableMatugenSchemes.map(function (option) { return option.label })
options: Theme.availableMatugenSchemes.map(function (option) {
return option.label
})
currentValue: Theme.getMatugenScheme(SettingsData.matugenScheme).label
enabled: Theme.matugenAvailable
opacity: enabled ? 1 : 0.4
onValueChanged: value => {
for (var i = 0; i < Theme.availableMatugenSchemes.length; i++) {
var option = Theme.availableMatugenSchemes[i]
if (option.label === value) {
SettingsData.setMatugenScheme(option.value)
break
}
}
}
for (var i = 0; i < Theme.availableMatugenSchemes.length; i++) {
var option = Theme.availableMatugenSchemes[i]
if (option.label === value) {
SettingsData.setMatugenScheme(option.value)
break
}
}
}
}
StyledText {
@@ -1459,8 +1486,8 @@ Item {
checked: SettingsData.runUserMatugenTemplates
enabled: Theme.matugenAvailable
onToggled: checked => {
SettingsData.setRunUserMatugenTemplates(checked)
}
SettingsData.setRunUserMatugenTemplates(checked)
}
}
}
@@ -1528,8 +1555,8 @@ Item {
anchors.verticalCenter: parent.verticalCenter
checked: SettingsData.soundsEnabled
onToggled: checked => {
SettingsData.setSoundsEnabled(checked)
}
SettingsData.setSoundsEnabled(checked)
}
}
}
@@ -1576,8 +1603,8 @@ Item {
anchors.verticalCenter: parent.verticalCenter
checked: SettingsData.useSystemSoundTheme
onToggled: checked => {
SettingsData.setUseSystemSoundTheme(checked)
}
SettingsData.setUseSystemSoundTheme(checked)
}
}
}
@@ -1598,10 +1625,10 @@ Item {
return AudioService.availableSoundThemes.length > 0 ? AudioService.availableSoundThemes[0] : ""
}
onValueChanged: value => {
if (value && value !== AudioService.currentSoundTheme) {
AudioService.setSoundTheme(value)
}
}
if (value && value !== AudioService.currentSoundTheme) {
AudioService.setSoundTheme(value)
}
}
}
Rectangle {
@@ -1641,8 +1668,8 @@ Item {
anchors.verticalCenter: parent.verticalCenter
checked: SettingsData.soundNewNotification
onToggled: checked => {
SettingsData.setSoundNewNotification(checked)
}
SettingsData.setSoundNewNotification(checked)
}
}
}
@@ -1675,8 +1702,8 @@ Item {
anchors.verticalCenter: parent.verticalCenter
checked: SettingsData.soundVolumeChanged
onToggled: checked => {
SettingsData.setSoundVolumeChanged(checked)
}
SettingsData.setSoundVolumeChanged(checked)
}
}
}
@@ -1710,8 +1737,8 @@ Item {
anchors.verticalCenter: parent.verticalCenter
checked: SettingsData.soundPluggedIn
onToggled: checked => {
SettingsData.setSoundPluggedIn(checked)
}
SettingsData.setSoundPluggedIn(checked)
}
}
}
}