Commit e6b2c641 authored by Nicolas Fella's avatar Nicolas Fella Committed by Shlomi Fish
Browse files

Port away from KRandom

Summary: See T12093

Reviewers: #kde_games

Subscribers: shlomif, kde-games-devel

Differential Revision: https://phabricator.kde.org/D26201
parent e0f52add
......@@ -8,7 +8,7 @@ set(RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_
project(kpat VERSION ${RELEASE_SERVICE_VERSION})
set (QT_MIN_VERSION "5.9.0")
set (QT_MIN_VERSION "5.10.0")
set (KF5_MIN_VERSION "5.46.0")
include(FindPkgConfig)
......
......@@ -50,7 +50,7 @@
#include <KConfigGroup>
#include <KLocalizedString>
#include <KMessageBox>
#include <KRandom>
#include <QRandomGenerator>
#include <KSharedConfig>
#include <QThread>
......@@ -789,7 +789,7 @@ MoveHint DealerScene::chooseHint()
else
{
// Generate a random number with an exponentional distribution averaging 1/4.
qreal randomExp = qMin<qreal>( -log( 1 - qreal( KRandom::random() ) / RAND_MAX ) / 4, 1 );
qreal randomExp = qMin<qreal>( -log( 1 - qreal( QRandomGenerator::global()->generate() ) / RAND_MAX ) / 4, 1 );
int randomIndex = randomExp * ( hintList.size() - 1 );
std::sort(hintList.begin(), hintList.end(), prioSort);
......
......@@ -63,7 +63,7 @@
#include <QIcon>
#include <KLocalizedString>
#include <KMessageBox>
#include <KRandom>
#include <QRandomGenerator>
#include <QStatusBar>
#include <QMenuBar>
#include <QTemporaryFile>
......@@ -407,7 +407,7 @@ void MainWindow::restart()
void MainWindow::startRandom()
{
startNew(KRandom::random());
startNew(QRandomGenerator::global()->generate());
}
void MainWindow::startNew(int gameNumber)
......@@ -419,7 +419,7 @@ void MainWindow::startNew(int gameNumber)
void MainWindow::slotPickRandom()
{
QList<KCardTheme> themes = KCardTheme::findAll();
KCardTheme theme = themes.at( KRandom::random() % themes.size() );
KCardTheme theme = themes.at( QRandomGenerator::global()->generate() % themes.size() );
Settings::setCardTheme( theme.dirName() );
appearanceChanged();
......
......@@ -43,8 +43,9 @@
#include "speeds.h"
#include "patsolve/spidersolver.h"
#include <QRandomGenerator>
#include <KLocalizedString>
#include <KRandom>
#include <KSelectAction>
......@@ -401,8 +402,8 @@ void Spider::moveFullRunToLeg( KCardPile * pile )
QPointF Spider::randomPos()
{
QRectF rect = sceneRect();
qreal x = rect.left() + qreal(KRandom::random()) / RAND_MAX * (rect.width() - deck()->cardWidth());
qreal y = rect.top() + qreal(KRandom::random()) / RAND_MAX * (rect.height() - deck()->cardHeight());
qreal x = rect.left() + qreal(QRandomGenerator::global()->generate()) / RAND_MAX * (rect.width() - deck()->cardWidth());
qreal y = rect.top() + qreal(QRandomGenerator::global()->generate()) / RAND_MAX * (rect.height() - deck()->cardHeight());
return QPointF( x, y );
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment