1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-29 07:52:50 -05:00

Add random transition effect

This commit is contained in:
bbedward
2025-09-25 09:06:38 -04:00
parent 974dd70a06
commit 7ccd2d9418
5 changed files with 110 additions and 34 deletions

View File

@@ -47,6 +47,8 @@ Singleton {
property string lastBrightnessDevice: "" property string lastBrightnessDevice: ""
property string launchPrefix: "" property string launchPrefix: ""
property string wallpaperTransition: "fade" property string wallpaperTransition: "fade"
readonly property var availableWallpaperTransitions: ["none", "fade", "wipe", "disc", "stripes", "iris bloom", "pixelate", "portal"]
property var includedTransitions: availableWallpaperTransitions.filter(t => t !== "none")
// Power management settings - AC Power // Power management settings - AC Power
property int acMonitorTimeout: 0 // Never property int acMonitorTimeout: 0 // Never
@@ -119,6 +121,7 @@ Singleton {
lastBrightnessDevice = settings.lastBrightnessDevice !== undefined ? settings.lastBrightnessDevice : "" lastBrightnessDevice = settings.lastBrightnessDevice !== undefined ? settings.lastBrightnessDevice : ""
launchPrefix = settings.launchPrefix !== undefined ? settings.launchPrefix : "" launchPrefix = settings.launchPrefix !== undefined ? settings.launchPrefix : ""
wallpaperTransition = settings.wallpaperTransition !== undefined ? settings.wallpaperTransition : "fade" wallpaperTransition = settings.wallpaperTransition !== undefined ? settings.wallpaperTransition : "fade"
includedTransitions = settings.includedTransitions !== undefined ? settings.includedTransitions : availableWallpaperTransitions.filter(t => t !== "none")
acMonitorTimeout = settings.acMonitorTimeout !== undefined ? settings.acMonitorTimeout : 0 acMonitorTimeout = settings.acMonitorTimeout !== undefined ? settings.acMonitorTimeout : 0
acLockTimeout = settings.acLockTimeout !== undefined ? settings.acLockTimeout : 0 acLockTimeout = settings.acLockTimeout !== undefined ? settings.acLockTimeout : 0
@@ -173,6 +176,7 @@ Singleton {
"lastBrightnessDevice": lastBrightnessDevice, "lastBrightnessDevice": lastBrightnessDevice,
"launchPrefix": launchPrefix, "launchPrefix": launchPrefix,
"wallpaperTransition": wallpaperTransition, "wallpaperTransition": wallpaperTransition,
"includedTransitions": includedTransitions,
"acMonitorTimeout": acMonitorTimeout, "acMonitorTimeout": acMonitorTimeout,
"acLockTimeout": acLockTimeout, "acLockTimeout": acLockTimeout,
"acSuspendTimeout": acSuspendTimeout, "acSuspendTimeout": acSuspendTimeout,

View File

@@ -805,24 +805,60 @@ Item {
text: "Transition Effect" text: "Transition Effect"
description: "Visual effect used when wallpaper changes" description: "Visual effect used when wallpaper changes"
currentValue: { currentValue: {
switch (SessionData.wallpaperTransition) { if (SessionData.wallpaperTransition === "random") return "Random"
case "none": return "None" return SessionData.wallpaperTransition.charAt(0).toUpperCase() + SessionData.wallpaperTransition.slice(1)
case "fade": return "Fade"
case "wipe": return "Wipe"
case "disc": return "Disc"
case "stripes": return "Stripes"
case "iris bloom": return "Iris Bloom"
case "pixelate": return "Pixelate"
case "portal": return "Portal"
default: return "Fade"
}
} }
options: ["None", "Fade", "Wipe", "Disc", "Stripes", "Iris Bloom", "Pixelate", "Portal"] options: ["Random"].concat(SessionData.availableWallpaperTransitions.map(t => t.charAt(0).toUpperCase() + t.slice(1)))
onValueChanged: value => { onValueChanged: value => {
var transition = value.toLowerCase() var transition = value.toLowerCase()
SessionData.setWallpaperTransition(transition) SessionData.setWallpaperTransition(transition)
} }
} }
Column {
width: parent.width
spacing: Theme.spacingS
visible: SessionData.wallpaperTransition === "random"
leftPadding: Theme.spacingM
rightPadding: Theme.spacingM
StyledText {
text: "Include Transitions"
font.pixelSize: Theme.fontSizeMedium
color: Theme.surfaceText
font.weight: Font.Medium
}
StyledText {
text: "Select which transitions to include in randomization"
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText
wrapMode: Text.WordWrap
width: parent.width - parent.leftPadding - parent.rightPadding
}
DankButtonGroup {
id: transitionGroup
width: parent.width - parent.leftPadding - parent.rightPadding
selectionMode: "multi"
model: SessionData.availableWallpaperTransitions.filter(t => t !== "none")
initialSelection: SessionData.includedTransitions
currentSelection: SessionData.includedTransitions
onSelectionChanged: (index, selected) => {
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)
}
SessionData.includedTransitions = newIncluded
}
}
}
} }
} }

View File

@@ -37,8 +37,24 @@ LazyLoader {
property string source: SessionData.getMonitorWallpaper(modelData.name) || "" property string source: SessionData.getMonitorWallpaper(modelData.name) || ""
property bool isColorSource: source.startsWith("#") property bool isColorSource: source.startsWith("#")
property string transitionType: SessionData.wallpaperTransition property string transitionType: SessionData.wallpaperTransition
property string actualTransitionType: transitionType
onTransitionTypeChanged: { onTransitionTypeChanged: {
currentWallpaper.visible = (transitionType === "none") if (transitionType === "random") {
if (SessionData.includedTransitions.length === 0) {
actualTransitionType = "none"
} else {
actualTransitionType = SessionData.includedTransitions[Math.floor(Math.random() * SessionData.includedTransitions.length)]
}
} else {
actualTransitionType = transitionType
}
}
onActualTransitionTypeChanged: {
if (actualTransitionType === "none") {
currentWallpaper.visible = true
nextWallpaper.visible = false
}
} }
property real transitionProgress: 0 property real transitionProgress: 0
property real fillMode: 1.0 property real fillMode: 1.0
@@ -95,6 +111,8 @@ LazyLoader {
root.transitionProgress = 0.0 root.transitionProgress = 0.0
currentWallpaper.source = newSource currentWallpaper.source = newSource
nextWallpaper.source = "" nextWallpaper.source = ""
currentWallpaper.visible = true
nextWallpaper.visible = false
} }
function changeWallpaper(newPath, force) { function changeWallpaper(newPath, force) {
@@ -115,17 +133,25 @@ LazyLoader {
} }
// If transition is "none", set immediately // If transition is "none", set immediately
if (root.transitionType === "none") { if (root.transitionType === "random") {
if (SessionData.includedTransitions.length === 0) {
root.actualTransitionType = "none"
} else {
root.actualTransitionType = SessionData.includedTransitions[Math.floor(Math.random() * SessionData.includedTransitions.length)]
}
}
if (root.actualTransitionType === "none") {
setWallpaperImmediate(newPath) setWallpaperImmediate(newPath)
return return
} }
if (root.transitionType === "wipe") { if (root.actualTransitionType === "wipe") {
root.wipeDirection = Math.random() * 4 root.wipeDirection = Math.random() * 4
} else if (root.transitionType === "disc") { } else if (root.actualTransitionType === "disc") {
root.discCenterX = Math.random() root.discCenterX = Math.random()
root.discCenterY = Math.random() root.discCenterY = Math.random()
} else if (root.transitionType === "stripes") { } else if (root.actualTransitionType === "stripes") {
root.stripesCount = Math.round(Math.random() * 20 + 4) root.stripesCount = Math.round(Math.random() * 20 + 4)
root.stripesAngle = Math.random() * 360 root.stripesAngle = Math.random() * 360
} }
@@ -165,7 +191,7 @@ LazyLoader {
Image { Image {
id: currentWallpaper id: currentWallpaper
anchors.fill: parent anchors.fill: parent
visible: root.transitionType === "none" visible: root.actualTransitionType === "none"
opacity: 1 opacity: 1
layer.enabled: false layer.enabled: false
asynchronous: true asynchronous: true
@@ -188,7 +214,7 @@ LazyLoader {
onStatusChanged: { onStatusChanged: {
if (status !== Image.Ready) return if (status !== Image.Ready) return
if (root.transitionType === "none") { if (root.actualTransitionType === "none") {
currentWallpaper.source = source currentWallpaper.source = source
nextWallpaper.source = "" nextWallpaper.source = ""
root.transitionProgress = 0.0 root.transitionProgress = 0.0
@@ -206,7 +232,7 @@ LazyLoader {
ShaderEffect { ShaderEffect {
id: fadeShader id: fadeShader
anchors.fill: parent anchors.fill: parent
visible: root.transitionType === "fade" && (root.hasCurrent || root.booting) visible: root.actualTransitionType === "fade" && (root.hasCurrent || root.booting)
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource property variant source1: root.hasCurrent ? currentWallpaper : transparentSource
property variant source2: nextWallpaper property variant source2: nextWallpaper
@@ -226,7 +252,7 @@ LazyLoader {
ShaderEffect { ShaderEffect {
id: wipeShader id: wipeShader
anchors.fill: parent anchors.fill: parent
visible: root.transitionType === "wipe" && (root.hasCurrent || root.booting) visible: root.actualTransitionType === "wipe" && (root.hasCurrent || root.booting)
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource property variant source1: root.hasCurrent ? currentWallpaper : transparentSource
property variant source2: nextWallpaper property variant source2: nextWallpaper
@@ -248,7 +274,7 @@ LazyLoader {
ShaderEffect { ShaderEffect {
id: discShader id: discShader
anchors.fill: parent anchors.fill: parent
visible: root.transitionType === "disc" && (root.hasCurrent || root.booting) visible: root.actualTransitionType === "disc" && (root.hasCurrent || root.booting)
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource property variant source1: root.hasCurrent ? currentWallpaper : transparentSource
property variant source2: nextWallpaper property variant source2: nextWallpaper
@@ -272,7 +298,7 @@ LazyLoader {
ShaderEffect { ShaderEffect {
id: stripesShader id: stripesShader
anchors.fill: parent anchors.fill: parent
visible: root.transitionType === "stripes" && (root.hasCurrent || root.booting) visible: root.actualTransitionType === "stripes" && (root.hasCurrent || root.booting)
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource property variant source1: root.hasCurrent ? currentWallpaper : transparentSource
property variant source2: nextWallpaper property variant source2: nextWallpaper
@@ -296,7 +322,7 @@ LazyLoader {
ShaderEffect { ShaderEffect {
id: irisBloomShader id: irisBloomShader
anchors.fill: parent anchors.fill: parent
visible: root.transitionType === "iris bloom" && (root.hasCurrent || root.booting) visible: root.actualTransitionType === "iris bloom" && (root.hasCurrent || root.booting)
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource property variant source1: root.hasCurrent ? currentWallpaper : transparentSource
property variant source2: nextWallpaper property variant source2: nextWallpaper
@@ -320,7 +346,7 @@ LazyLoader {
ShaderEffect { ShaderEffect {
id: pixelateShader id: pixelateShader
anchors.fill: parent anchors.fill: parent
visible: root.transitionType === "pixelate" && (root.hasCurrent || root.booting) visible: root.actualTransitionType === "pixelate" && (root.hasCurrent || root.booting)
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource property variant source1: root.hasCurrent ? currentWallpaper : transparentSource
property variant source2: nextWallpaper property variant source2: nextWallpaper
@@ -344,7 +370,7 @@ LazyLoader {
ShaderEffect { ShaderEffect {
id: portalShader id: portalShader
anchors.fill: parent anchors.fill: parent
visible: root.transitionType === "portal" && (root.hasCurrent || root.booting) visible: root.actualTransitionType === "portal" && (root.hasCurrent || root.booting)
property variant source1: root.hasCurrent ? currentWallpaper : transparentSource property variant source1: root.hasCurrent ? currentWallpaper : transparentSource
property variant source2: nextWallpaper property variant source2: nextWallpaper
@@ -371,7 +397,7 @@ LazyLoader {
property: "transitionProgress" property: "transitionProgress"
from: 0.0 from: 0.0
to: 1.0 to: 1.0
duration: root.transitionType === "none" ? 0 : 1000 duration: root.actualTransitionType === "none" ? 0 : 1000
easing.type: Easing.InOutCubic easing.type: Easing.InOutCubic
onFinished: { onFinished: {
Qt.callLater(() => { Qt.callLater(() => {
@@ -380,7 +406,7 @@ LazyLoader {
} }
nextWallpaper.source = "" nextWallpaper.source = ""
nextWallpaper.visible = false nextWallpaper.visible = false
currentWallpaper.visible = root.transitionType === "none" currentWallpaper.visible = root.actualTransitionType === "none"
currentWallpaper.layer.enabled = false currentWallpaper.layer.enabled = false
nextWallpaper.layer.enabled = false nextWallpaper.layer.enabled = false
root.transitionProgress = 0.0 root.transitionProgress = 0.0

View File

@@ -2,13 +2,15 @@ import QtQuick
import qs.Common import qs.Common
import qs.Widgets import qs.Widgets
Row { Flow {
id: root id: root
property var model: [] property var model: []
property int currentIndex: -1 property int currentIndex: -1
property string selectionMode: "single" property string selectionMode: "single"
property bool multiSelect: selectionMode === "multi" property bool multiSelect: selectionMode === "multi"
property var initialSelection: []
property var currentSelection: initialSelection
property bool checkEnabled: true property bool checkEnabled: true
property int buttonHeight: 40 property int buttonHeight: 40
property int minButtonWidth: 64 property int minButtonWidth: 64
@@ -29,11 +31,18 @@ Row {
function selectItem(index) { function selectItem(index) {
if (multiSelect) { if (multiSelect) {
const item = repeater.itemAt(index) const modelValue = model[index]
if (item) { let newSelection = [...currentSelection]
item.selected = !item.selected const isCurrentlySelected = newSelection.includes(modelValue)
selectionChanged(index, item.selected)
if (isCurrentlySelected) {
newSelection = newSelection.filter(item => item !== modelValue)
} else {
newSelection.push(modelValue)
} }
currentSelection = newSelection
selectionChanged(index, !isCurrentlySelected)
} else { } else {
const oldIndex = currentIndex const oldIndex = currentIndex
currentIndex = index currentIndex = index
@@ -51,7 +60,7 @@ Row {
delegate: Rectangle { delegate: Rectangle {
id: segment id: segment
property bool selected: multiSelect ? false : (index === root.currentIndex) property bool selected: multiSelect ? root.currentSelection.includes(modelData) : (index === root.currentIndex)
property bool hovered: mouseArea.containsMouse property bool hovered: mouseArea.containsMouse
property bool pressed: mouseArea.pressed property bool pressed: mouseArea.pressed
property bool isFirst: index === 0 property bool isFirst: index === 0

View File

@@ -335,6 +335,7 @@ Rectangle {
onClicked: { onClicked: {
root.currentValue = modelData root.currentValue = modelData
root.valueChanged(modelData) root.valueChanged(modelData)
listView.popupRef.close()
} }
} }
} }