Port qrand to QRandomGenerator (qrand is deprecated in qt5.15)
Summary: Port to QRandomGenerator Reviewers: apol Reviewed By: apol Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D26464
This commit is contained in:
parent
3f30f91fb0
commit
b387faa935
@ -24,6 +24,7 @@
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QSignalSpy>
|
||||
#include <QRandomGenerator>
|
||||
#include <QProcess>
|
||||
Plasma::Applet *SimpleLoader::internalLoadApplet(const QString &name, uint appletId,
|
||||
const QVariantList &args)
|
||||
@ -67,12 +68,9 @@ int SimpleCorona::screenForContainment(const Plasma::Containment *c) const
|
||||
SimpleApplet::SimpleApplet(QObject *parent , const QString &serviceId, uint appletId)
|
||||
: Plasma::Applet(parent, serviceId, appletId)
|
||||
{
|
||||
QTime time = QTime::currentTime();
|
||||
qsrand((uint)time.msec());
|
||||
|
||||
//updateConstraints(Plasma::Types::UiReadyConstraint);
|
||||
m_timer.setSingleShot(true);
|
||||
m_timer.setInterval(qrand() % ((500 + 1) - 100) + 100);
|
||||
m_timer.setInterval(QRandomGenerator::global()->bounded((500 + 1) - 100) + 100);
|
||||
m_timer.start();
|
||||
connect(&m_timer, &QTimer::timeout, [=]() {
|
||||
updateConstraints(Plasma::Types::UiReadyConstraint);
|
||||
@ -83,12 +81,9 @@ SimpleApplet::SimpleApplet(QObject *parent , const QString &serviceId, uint appl
|
||||
SimpleContainment::SimpleContainment(QObject *parent , const QString &serviceId, uint appletId)
|
||||
: Plasma::Containment(parent, serviceId, appletId)
|
||||
{
|
||||
QTime time = QTime::currentTime();
|
||||
qsrand((uint)time.msec());
|
||||
|
||||
//updateConstraints(Plasma::Types::UiReadyConstraint);
|
||||
m_timer.setSingleShot(true);
|
||||
m_timer.setInterval(qrand() % ((500 + 1) - 100) + 100);
|
||||
m_timer.setInterval(QRandomGenerator::global()->bounded((500 + 1) - 100) + 100);
|
||||
m_timer.start();
|
||||
connect(&m_timer, &QTimer::timeout, [=]() {
|
||||
updateConstraints(Plasma::Types::UiReadyConstraint);
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QRandomGenerator>
|
||||
|
||||
#include "plasma.h"
|
||||
#include "debug_p.h"
|
||||
@ -195,11 +196,9 @@ void DataContainer::connectVisualization(QObject *visualization, uint pollingInt
|
||||
|
||||
void DataContainer::setStorageEnabled(bool store)
|
||||
{
|
||||
QTime time = QTime::currentTime();
|
||||
qsrand((uint)time.msec());
|
||||
d->enableStorage = store;
|
||||
if (store) {
|
||||
QTimer::singleShot(qrand() % (2000 + 1), this, SLOT(retrieve()));
|
||||
QTimer::singleShot(QRandomGenerator::global()->bounded(2000 + 1), this, SLOT(retrieve()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <QQmlProperty>
|
||||
#include <QQmlContext>
|
||||
#include <QQuickWindow>
|
||||
#include <QRandomGenerator>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
@ -701,7 +702,7 @@ void AppletQuickItem::init()
|
||||
//to be the delay, smaller minimum walue, smaller spread
|
||||
const int min = (100 - preloadWeight) * 20;
|
||||
const int max = (100 - preloadWeight) * 100;
|
||||
const int delay = qrand() % ((max + 1) - min) + min;
|
||||
const int delay = QRandomGenerator::global()->bounded((max + 1) - min) + min;
|
||||
QTimer::singleShot(delay, this, [this, delay]() {
|
||||
qCDebug(LOG_PLASMAQUICK) << "Delayed preload of " << d->applet->title() << "after" << (qreal)delay/1000 << "seconds";
|
||||
d->preloadForExpansion();
|
||||
|
Loading…
Reference in New Issue
Block a user