Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Plasma Add-ons
Commits
7fd63273
Verified
Commit
7fd63273
authored
May 05, 2022
by
Fushan Wen
Browse files
wallpapers/potd: Give random chooser a seed in simonstalenhagprovider
Make the seed depend on the current date.
CCBUG: 453391
parent
47948c86
Changes
1
Hide whitespace changes
Inline
Side-by-side
wallpapers/potd/plugins/simonstalenhagprovider.cpp
View file @
7fd63273
...
...
@@ -6,10 +6,11 @@
#include
"simonstalenhagprovider.h"
#include
<random>
#include
<QDebug>
#include
<QJsonArray>
#include
<QJsonDocument>
#include
<QRandomGenerator>
#include
<KIO/Job>
#include
<KPluginFactory>
...
...
@@ -28,8 +29,11 @@ static QJsonValue randomArrayValueByKey(const QJsonObject &object, QLatin1String
return
result
;
}
auto
arraySize
=
array
.
size
();
return
array
.
at
(
QRandomGenerator
::
global
()
->
bounded
(
arraySize
));
// Plasma 5.24.0 release date
std
::
mt19937
randomEngine
(
QDate
(
2022
,
2
,
3
).
daysTo
(
QDate
::
currentDate
()));
std
::
uniform_int_distribution
<
int
>
distrib
(
0
,
array
.
size
()
-
1
);
return
array
.
at
(
distrib
(
randomEngine
));
}
SimonStalenhagProvider
::
SimonStalenhagProvider
(
QObject
*
parent
,
const
KPluginMetaData
&
data
,
const
QVariantList
&
args
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment