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 <QAction>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QSignalSpy>
|
#include <QSignalSpy>
|
||||||
|
#include <QRandomGenerator>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
Plasma::Applet *SimpleLoader::internalLoadApplet(const QString &name, uint appletId,
|
Plasma::Applet *SimpleLoader::internalLoadApplet(const QString &name, uint appletId,
|
||||||
const QVariantList &args)
|
const QVariantList &args)
|
||||||
@ -67,12 +68,9 @@ int SimpleCorona::screenForContainment(const Plasma::Containment *c) const
|
|||||||
SimpleApplet::SimpleApplet(QObject *parent , const QString &serviceId, uint appletId)
|
SimpleApplet::SimpleApplet(QObject *parent , const QString &serviceId, uint appletId)
|
||||||
: Plasma::Applet(parent, serviceId, appletId)
|
: Plasma::Applet(parent, serviceId, appletId)
|
||||||
{
|
{
|
||||||
QTime time = QTime::currentTime();
|
|
||||||
qsrand((uint)time.msec());
|
|
||||||
|
|
||||||
//updateConstraints(Plasma::Types::UiReadyConstraint);
|
//updateConstraints(Plasma::Types::UiReadyConstraint);
|
||||||
m_timer.setSingleShot(true);
|
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();
|
m_timer.start();
|
||||||
connect(&m_timer, &QTimer::timeout, [=]() {
|
connect(&m_timer, &QTimer::timeout, [=]() {
|
||||||
updateConstraints(Plasma::Types::UiReadyConstraint);
|
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)
|
SimpleContainment::SimpleContainment(QObject *parent , const QString &serviceId, uint appletId)
|
||||||
: Plasma::Containment(parent, serviceId, appletId)
|
: Plasma::Containment(parent, serviceId, appletId)
|
||||||
{
|
{
|
||||||
QTime time = QTime::currentTime();
|
|
||||||
qsrand((uint)time.msec());
|
|
||||||
|
|
||||||
//updateConstraints(Plasma::Types::UiReadyConstraint);
|
//updateConstraints(Plasma::Types::UiReadyConstraint);
|
||||||
m_timer.setSingleShot(true);
|
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();
|
m_timer.start();
|
||||||
connect(&m_timer, &QTimer::timeout, [=]() {
|
connect(&m_timer, &QTimer::timeout, [=]() {
|
||||||
updateConstraints(Plasma::Types::UiReadyConstraint);
|
updateConstraints(Plasma::Types::UiReadyConstraint);
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
#include "plasma.h"
|
#include "plasma.h"
|
||||||
#include "debug_p.h"
|
#include "debug_p.h"
|
||||||
@ -195,11 +196,9 @@ void DataContainer::connectVisualization(QObject *visualization, uint pollingInt
|
|||||||
|
|
||||||
void DataContainer::setStorageEnabled(bool store)
|
void DataContainer::setStorageEnabled(bool store)
|
||||||
{
|
{
|
||||||
QTime time = QTime::currentTime();
|
|
||||||
qsrand((uint)time.msec());
|
|
||||||
d->enableStorage = store;
|
d->enableStorage = store;
|
||||||
if (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 <QQmlProperty>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
@ -701,7 +702,7 @@ void AppletQuickItem::init()
|
|||||||
//to be the delay, smaller minimum walue, smaller spread
|
//to be the delay, smaller minimum walue, smaller spread
|
||||||
const int min = (100 - preloadWeight) * 20;
|
const int min = (100 - preloadWeight) * 20;
|
||||||
const int max = (100 - preloadWeight) * 100;
|
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]() {
|
QTimer::singleShot(delay, this, [this, delay]() {
|
||||||
qCDebug(LOG_PLASMAQUICK) << "Delayed preload of " << d->applet->title() << "after" << (qreal)delay/1000 << "seconds";
|
qCDebug(LOG_PLASMAQUICK) << "Delayed preload of " << d->applet->title() << "after" << (qreal)delay/1000 << "seconds";
|
||||||
d->preloadForExpansion();
|
d->preloadForExpansion();
|
||||||
|
Loading…
Reference in New Issue
Block a user