mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-08 14:38:30 -04:00
wallpaper: use filter chips for rando transitions
This commit is contained in:
@@ -1199,16 +1199,18 @@ Item {
|
|||||||
width: parent.width - Theme.spacingM * 2
|
width: parent.width - Theme.spacingM * 2
|
||||||
}
|
}
|
||||||
|
|
||||||
DankButtonGroup {
|
DankFilterChips {
|
||||||
id: transitionGroup
|
id: transitionGroup
|
||||||
width: parent.width - Theme.spacingM * 2
|
width: parent.width - Theme.spacingM * 2
|
||||||
selectionMode: "multi"
|
multiSelect: true
|
||||||
model: SessionData.availableWallpaperTransitions.filter(t => t !== "none")
|
model: SessionData.availableWallpaperTransitions.filter(t => t !== "none").map(t => ({
|
||||||
initialSelection: SessionData.includedTransitions
|
"value": t,
|
||||||
currentSelection: SessionData.includedTransitions
|
"label": t.replace(/\b\w/g, c => c.toUpperCase())
|
||||||
|
}))
|
||||||
|
selectedValues: SessionData.includedTransitions
|
||||||
|
|
||||||
onSelectionChanged: (index, selected) => {
|
onSelectionToggled: (index, selected) => {
|
||||||
const transition = model[index];
|
const transition = model[index].value;
|
||||||
let newIncluded = SessionData.includedTransitions.slice();
|
let newIncluded = SessionData.includedTransitions.slice();
|
||||||
|
|
||||||
if (selected && !newIncluded.includes(transition)) {
|
if (selected && !newIncluded.includes(transition)) {
|
||||||
|
|||||||
@@ -7,12 +7,15 @@ Flow {
|
|||||||
|
|
||||||
property var model: []
|
property var model: []
|
||||||
property int currentIndex: 0
|
property int currentIndex: 0
|
||||||
|
property bool multiSelect: false
|
||||||
|
property var selectedValues: []
|
||||||
property int chipHeight: 32
|
property int chipHeight: 32
|
||||||
property int chipPadding: Theme.spacingM
|
property int chipPadding: Theme.spacingM
|
||||||
property bool showCheck: true
|
property bool showCheck: true
|
||||||
property bool showCounts: true
|
property bool showCounts: true
|
||||||
|
|
||||||
signal selectionChanged(int index)
|
signal selectionChanged(int index)
|
||||||
|
signal selectionToggled(int index, bool selected)
|
||||||
|
|
||||||
spacing: Theme.spacingS
|
spacing: Theme.spacingS
|
||||||
width: parent ? parent.width : 400
|
width: parent ? parent.width : 400
|
||||||
@@ -25,7 +28,8 @@ Flow {
|
|||||||
required property var modelData
|
required property var modelData
|
||||||
required property int index
|
required property int index
|
||||||
|
|
||||||
property bool selected: index === root.currentIndex
|
property var value: typeof modelData === "string" ? modelData : (modelData.value !== undefined ? modelData.value : (modelData.label || ""))
|
||||||
|
property bool selected: root.multiSelect ? root.selectedValues.includes(value) : (index === root.currentIndex)
|
||||||
property bool hovered: mouseArea.containsMouse
|
property bool hovered: mouseArea.containsMouse
|
||||||
property bool pressed: mouseArea.pressed
|
property bool pressed: mouseArea.pressed
|
||||||
property string label: typeof modelData === "string" ? modelData : (modelData.label || "")
|
property string label: typeof modelData === "string" ? modelData : (modelData.label || "")
|
||||||
@@ -99,6 +103,10 @@ Flow {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onPressed: mouse => chipRipple.trigger(mouse.x, mouse.y)
|
onPressed: mouse => chipRipple.trigger(mouse.x, mouse.y)
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
if (root.multiSelect) {
|
||||||
|
root.selectionToggled(chip.index, !chip.selected);
|
||||||
|
return;
|
||||||
|
}
|
||||||
root.currentIndex = chip.index;
|
root.currentIndex = chip.index;
|
||||||
root.selectionChanged(chip.index);
|
root.selectionChanged(chip.index);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user