Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
JuK
Commits
a5c155d7
Commit
a5c155d7
authored
Jul 27, 2020
by
Michael Pyne
Browse files
Port away from deprecated random generator and QString function.
parent
5064e40a
Pipeline
#28609
passed with stage
in 12 minutes and 51 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
a5c155d7
...
...
@@ -9,7 +9,7 @@ set (RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE
project
(
juk VERSION
${
RELEASE_SERVICE_VERSION
}
)
set
(
QT_MIN_VERSION
"5.
6
.0"
)
set
(
QT_MIN_VERSION
"5.
10
.0"
)
set
(
KF5_MIN_VERSION
"5.35.0"
)
find_package
(
ECM
${
KF5_MIN_VERSION
}
REQUIRED NO_MODULE
)
...
...
filerenamer.cpp
View file @
a5c155d7
...
...
@@ -937,7 +937,13 @@ void FileRenamer::setFolderIcon(const QUrl &dstURL, const PlaylistItem *item)
// Split path, and go through each path element. If a path element has
// the album information, set its folder icon.
QStringList
elements
=
dstURL
.
path
().
split
(
'/'
,
QString
::
SkipEmptyParts
);
QStringList
elements
=
dstURL
.
path
().
split
(
'/'
,
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
Qt
::
SkipEmptyParts
#else
QString
::
SkipEmptyParts
#endif
);
QString
path
;
for
(
QStringList
::
ConstIterator
it
=
elements
.
constBegin
();
it
!=
elements
.
constEnd
();
++
it
)
{
...
...
tracksequenceiterator.cpp
View file @
a5c155d7
...
...
@@ -17,8 +17,9 @@
#include "tracksequenceiterator.h"
#include <QAction>
#include <krandom.h>
#include <ktoggleaction.h>
#include <QRandomGenerator>
#include <KToggleAction>
#include "playlist.h"
#include "actioncollection.h"
...
...
@@ -69,22 +70,9 @@ DefaultSequenceIterator::~DefaultSequenceIterator()
{
}
// Helper function to return a random number up to (but not including) a given max with
// a truly equal probability of each integer in [0, max) being selected.
// When Qt 5.10 can be required we can use QRandomGenerator for this, but for now need to
// fixup KRandom.
// See https://twitter.com/colmmacc/status/1012723779708088320
static
int
boundedRandom
(
const
int
upperBound
)
{
while
(
1
)
{
const
int
candidate
=
KRandom
::
random
();
// this check excludes integers above the highest multiple of
// upperBound that is still below RAND_MAX to remove bias
if
(
candidate
<
(
RAND_MAX
-
(
RAND_MAX
%
upperBound
)))
{
return
candidate
%
upperBound
;
}
}
return
QRandomGenerator
::
global
()
->
bounded
(
upperBound
);
}
void
DefaultSequenceIterator
::
advance
()
...
...
@@ -97,9 +85,6 @@ void DefaultSequenceIterator::advance()
bool
albumRandom
=
action
(
"albumRandomPlay"
)
&&
action
<
KToggleAction
>
(
"albumRandomPlay"
)
->
isChecked
();
if
(
isRandom
||
albumRandom
)
{
// TODO: This should probably use KRandomSequence's ability to shuffle
// items instead of making a new random choice each time through.
if
(
m_randomItems
.
isEmpty
()
&&
loop
)
{
// Since refillRandomList will remove the currently playing item,
...
...
@@ -199,7 +184,7 @@ void DefaultSequenceIterator::prepareToPlay(Playlist *playlist)
PlaylistItem
*
newItem
=
0
;
if
(
!
items
.
isEmpty
())
newItem
=
items
[
KRandom
::
r
andom
(
)
%
items
.
count
()];
newItem
=
items
[
boundedR
andom
(
items
.
count
()
)
];
setCurrent
(
newItem
);
refillRandomList
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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