wallpaper selector: add random button (#1997)

This commit is contained in:
end-4 2025-09-16 08:22:47 +02:00
parent 074f8ed902
commit 426804304c

View file

@ -40,6 +40,13 @@ MouseArea {
}
}
function selectWallpaperPath(filePath) {
if (filePath && filePath.length > 0) {
Wallpapers.select(filePath, root.useDarkMode);
filterField.text = "";
}
}
acceptedButtons: Qt.BackButton | Qt.ForwardButton
onPressed: event => {
if (event.button === Qt.BackButton) {
@ -267,8 +274,7 @@ MouseArea {
function activateCurrent() {
const filePath = grid.model.get(currentIndex, "filePath")
Wallpapers.select(filePath, root.useDarkMode);
filterField.text = "";
root.selectWallpaperPath(filePath);
}
model: Wallpapers.folderModel
@ -287,8 +293,7 @@ MouseArea {
}
onActivated: {
Wallpapers.select(fileModelData.filePath, root.useDarkMode);
filterField.text = "";
root.selectWallpaperPath(fileModelData.filePath);
}
}
@ -330,6 +335,22 @@ MouseArea {
}
}
ToolbarButton {
implicitWidth: height
onClicked: {
const randomIndex = Math.floor(Math.random() * Wallpapers.folderModel.count);
const filePath = Wallpapers.folderModel.get(randomIndex, "filePath");
root.selectWallpaperPath(filePath);
}
contentItem: MaterialSymbol {
text: "ifl"
iconSize: Appearance.font.pixelSize.larger
}
StyledToolTip {
content: Translation.tr("Pick random from this folder")
}
}
ToolbarButton {
implicitWidth: height
onClicked: root.useDarkMode = !root.useDarkMode