From 319c7823e2a578cfc2df12ac52f5470f21b0c716 Mon Sep 17 00:00:00 2001 From: Attacktive Date: Thu, 30 Nov 2023 23:10:15 +0900 Subject: [PATCH 1/2] feat: add option to generate random seed --- contents/config/main.xml | 4 ++++ contents/ui/config.qml | 13 +++++++++++++ contents/ui/main.qml | 16 ++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/contents/config/main.xml b/contents/config/main.xml index a45d5a0..5fa6d4d 100644 --- a/contents/config/main.xml +++ b/contents/config/main.xml @@ -69,6 +69,10 @@ false + + + false + diff --git a/contents/ui/config.qml b/contents/ui/config.qml index a565a51..04ecc20 100644 --- a/contents/ui/config.qml +++ b/contents/ui/config.qml @@ -50,6 +50,8 @@ ColumnLayout { property string cfg_SearchColor + property bool cfg_RandomSeed + Image { id: currentWallpaper source: wallpaper.configuration.currentWallpaperThumbnail @@ -288,6 +290,17 @@ ColumnLayout { } } } + + RowLayout { + Kirigami.FormData.label: i18n("Random seed") + CheckBox { + text: i18n("Enable") + checked: cfg_RandomSeed + onToggled: { + cfg_RandomSeed = checked; + } + } + } } Label { diff --git a/contents/ui/main.qml b/contents/ui/main.qml index f1e9de2..6fa386d 100644 --- a/contents/ui/main.qml +++ b/contents/ui/main.qml @@ -144,6 +144,10 @@ QQC2.StackView { url += `ratios=${encodeURIComponent(root.aspectRatio)}&` + if (wallpaper.configuration.RandomSeed) { + url += `seed=${generateSeed()}` + } + url += `q=${encodeURIComponent(wallpaper.configuration.Query)}` console.error('using url: ' + url); @@ -239,6 +243,18 @@ QQC2.StackView { pendingImage = null; } + function generateSeed() { + const characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + const generatedCharacters = []; + + for (let i = 0; i < 6; i++) { + const randomIndex = Math.floor(Math.random() * characters.length); + generatedCharacters.push(characters.charAt(randomIndex)); + } + + return generatedCharacters.join(''); + } + replaceEnter: Transition { OpacityAnimator { id: replaceEnterOpacityAnimator From d5539d3427e0a49f108378f58ba84f8315c58ac9 Mon Sep 17 00:00:00 2001 From: Attacktive Date: Fri, 1 Dec 2023 12:15:11 +0900 Subject: [PATCH 2/2] fix: add missing ampersand (&) after query parameter `seed` --- contents/ui/main.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/ui/main.qml b/contents/ui/main.qml index 6fa386d..b9c8f07 100644 --- a/contents/ui/main.qml +++ b/contents/ui/main.qml @@ -145,7 +145,7 @@ QQC2.StackView { url += `ratios=${encodeURIComponent(root.aspectRatio)}&` if (wallpaper.configuration.RandomSeed) { - url += `seed=${generateSeed()}` + url += `seed=${generateSeed()}&` } url += `q=${encodeURIComponent(wallpaper.configuration.Query)}`