Commit 4699c749 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port some deprecated methods

parent f372ca18
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <NetworkManagerQt/Utils> #include <NetworkManagerQt/Utils>
#include <KLocalizedString> #include <KLocalizedString>
#include <QRandomGenerator>
#include "uiutils.h" #include "uiutils.h"
...@@ -31,8 +32,6 @@ WifiConnectionWidget::WifiConnectionWidget(const NetworkManager::Setting::Ptr &s ...@@ -31,8 +32,6 @@ WifiConnectionWidget::WifiConnectionWidget(const NetworkManager::Setting::Ptr &s
SettingWidget(setting, parent, f), SettingWidget(setting, parent, f),
m_ui(new Ui::WifiConnectionWidget) m_ui(new Ui::WifiConnectionWidget)
{ {
qsrand(QTime::currentTime().msec());
m_ui->setupUi(this); m_ui->setupUi(this);
connect(m_ui->btnRandomMacAddr, &QPushButton::clicked, this, &WifiConnectionWidget::generateRandomClonedMac); connect(m_ui->btnRandomMacAddr, &QPushButton::clicked, this, &WifiConnectionWidget::generateRandomClonedMac);
...@@ -125,9 +124,10 @@ QVariantMap WifiConnectionWidget::setting() const ...@@ -125,9 +124,10 @@ QVariantMap WifiConnectionWidget::setting() const
void WifiConnectionWidget::generateRandomClonedMac() void WifiConnectionWidget::generateRandomClonedMac()
{ {
QByteArray mac; QByteArray mac;
auto *generator = QRandomGenerator::global();
mac.resize(6); mac.resize(6);
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
int random = qrand() % 255; const int random = generator->bounded(255);
mac[i] = random; mac[i] = random;
} }
......
...@@ -25,12 +25,12 @@ ...@@ -25,12 +25,12 @@
#include <NetworkManagerQt/Utils> #include <NetworkManagerQt/Utils>
#include <NetworkManagerQt/WiredSetting> #include <NetworkManagerQt/WiredSetting>
#include <QRandomGenerator>
WiredConnectionWidget::WiredConnectionWidget(const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f): WiredConnectionWidget::WiredConnectionWidget(const NetworkManager::Setting::Ptr &setting, QWidget* parent, Qt::WindowFlags f):
SettingWidget(setting, parent, f), SettingWidget(setting, parent, f),
m_widget(new Ui::WiredConnectionWidget) m_widget(new Ui::WiredConnectionWidget)
{ {
qsrand(QTime::currentTime().msec());
m_widget->setupUi(this); m_widget->setupUi(this);
connect(m_widget->btnRandomMacAddr, &QPushButton::clicked, this, &WiredConnectionWidget::generateRandomClonedMac); connect(m_widget->btnRandomMacAddr, &QPushButton::clicked, this, &WiredConnectionWidget::generateRandomClonedMac);
...@@ -150,10 +150,11 @@ QVariantMap WiredConnectionWidget::setting() const ...@@ -150,10 +150,11 @@ QVariantMap WiredConnectionWidget::setting() const
void WiredConnectionWidget::generateRandomClonedMac() void WiredConnectionWidget::generateRandomClonedMac()
{ {
auto *generator = QRandomGenerator::global();
QByteArray mac; QByteArray mac;
mac.resize(6); mac.resize(6);
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
int random = qrand() % 255; const int random = generator->bounded(255);
mac[i] = random; mac[i] = random;
} }
......
...@@ -229,7 +229,6 @@ void OpenconnectAuthWorkerThread::writeProgress(int level, const char *fmt, va_l ...@@ -229,7 +229,6 @@ void OpenconnectAuthWorkerThread::writeProgress(int level, const char *fmt, va_l
if (*m_userDecidedToQuit) { if (*m_userDecidedToQuit) {
return; return;
} }
QString msg; const QString msg = QString::vasprintf(fmt, argPtr);
msg.vsprintf(fmt, argPtr);
Q_EMIT updateLog(msg, level); Q_EMIT updateLog(msg, level);
} }
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