forked from Shinonome/dots-hyprland
wallpaper selector: add random button (#1997)
This commit is contained in:
@@ -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
|
acceptedButtons: Qt.BackButton | Qt.ForwardButton
|
||||||
onPressed: event => {
|
onPressed: event => {
|
||||||
if (event.button === Qt.BackButton) {
|
if (event.button === Qt.BackButton) {
|
||||||
@@ -267,8 +274,7 @@ MouseArea {
|
|||||||
|
|
||||||
function activateCurrent() {
|
function activateCurrent() {
|
||||||
const filePath = grid.model.get(currentIndex, "filePath")
|
const filePath = grid.model.get(currentIndex, "filePath")
|
||||||
Wallpapers.select(filePath, root.useDarkMode);
|
root.selectWallpaperPath(filePath);
|
||||||
filterField.text = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
model: Wallpapers.folderModel
|
model: Wallpapers.folderModel
|
||||||
@@ -287,8 +293,7 @@ MouseArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onActivated: {
|
onActivated: {
|
||||||
Wallpapers.select(fileModelData.filePath, root.useDarkMode);
|
root.selectWallpaperPath(fileModelData.filePath);
|
||||||
filterField.text = "";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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 {
|
ToolbarButton {
|
||||||
implicitWidth: height
|
implicitWidth: height
|
||||||
onClicked: root.useDarkMode = !root.useDarkMode
|
onClicked: root.useDarkMode = !root.useDarkMode
|
||||||
|
|||||||
Reference in New Issue
Block a user