mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-08-17 22:29:55 +00:00
refactor: use new-style qt connections
This commit is contained in:
@ -198,7 +198,7 @@ void AbstractExtItem::setCron(const QString &_cron)
|
||||
qCDebug(LOG_LIB) << "Cron string" << _cron;
|
||||
// deinit module first
|
||||
if (m_scheduler) {
|
||||
disconnect(m_scheduler, SIGNAL(activated()), this, SIGNAL(requestDataUpdate()));
|
||||
disconnect(m_scheduler, &QCronScheduler::activated, this, &AbstractExtItem::requestDataUpdate);
|
||||
delete m_scheduler;
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ void AbstractExtItem::setCron(const QString &_cron)
|
||||
// init scheduler
|
||||
m_scheduler = new QCronScheduler(this);
|
||||
m_scheduler->parse(cron());
|
||||
connect(m_scheduler, SIGNAL(activated()), this, SIGNAL(requestDataUpdate()));
|
||||
connect(m_scheduler, &QCronScheduler::activated, this, &AbstractExtItem::requestDataUpdate);
|
||||
}
|
||||
|
||||
|
||||
@ -234,7 +234,7 @@ void AbstractExtItem::setName(const QString &_name)
|
||||
void AbstractExtItem::setNumber(int _number)
|
||||
{
|
||||
qCDebug(LOG_LIB) << "Number" << _number;
|
||||
bool generateNumber = (_number == -1);
|
||||
auto generateNumber = (_number == -1);
|
||||
if (generateNumber) {
|
||||
_number = []() {
|
||||
qCWarning(LOG_LIB) << "Number is empty, generate new one";
|
||||
@ -267,7 +267,7 @@ void AbstractExtItem::deinitSocket()
|
||||
|
||||
m_socket->close();
|
||||
QLocalServer::removeServer(socket());
|
||||
disconnect(m_socket, SIGNAL(newConnection()), this, SLOT(newConnectionReceived()));
|
||||
disconnect(m_socket, &QLocalServer::newConnection, this, &AbstractExtItem::newConnectionReceived);
|
||||
delete m_socket;
|
||||
}
|
||||
|
||||
@ -278,9 +278,9 @@ void AbstractExtItem::initSocket()
|
||||
deinitSocket();
|
||||
|
||||
m_socket = new QLocalServer(this);
|
||||
bool listening = m_socket->listen(socket());
|
||||
auto listening = m_socket->listen(socket());
|
||||
qCInfo(LOG_LIB) << "Server listening on" << socket() << listening;
|
||||
connect(m_socket, SIGNAL(newConnection()), this, SLOT(newConnectionReceived()));
|
||||
connect(m_socket, &QLocalServer::newConnection, this, &AbstractExtItem::newConnectionReceived);
|
||||
}
|
||||
|
||||
|
||||
@ -303,7 +303,7 @@ void AbstractExtItem::readConfiguration()
|
||||
|
||||
bool AbstractExtItem::tryDelete() const
|
||||
{
|
||||
bool status = QFile::remove(m_fileName);
|
||||
auto status = QFile::remove(m_fileName);
|
||||
qCInfo(LOG_LIB) << "Remove file" << m_fileName << status;
|
||||
|
||||
return status;
|
||||
|
@ -40,9 +40,8 @@ ExtNetworkRequest::ExtNetworkRequest(QObject *_parent, const QString &_filePath)
|
||||
// HACK declare as child of nullptr to avoid crash with plasmawindowed
|
||||
// in the destructor
|
||||
m_manager = new QNetworkAccessManager(nullptr);
|
||||
connect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(networkReplyReceived(QNetworkReply *)));
|
||||
|
||||
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
|
||||
connect(m_manager, &QNetworkAccessManager::finished, this, &ExtNetworkRequest::networkReplyReceived);
|
||||
connect(this, &ExtNetworkRequest::requestDataUpdate, this, &ExtNetworkRequest::sendRequest);
|
||||
}
|
||||
|
||||
|
||||
@ -50,8 +49,8 @@ ExtNetworkRequest::~ExtNetworkRequest()
|
||||
{
|
||||
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
|
||||
|
||||
disconnect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(networkReplyReceived(QNetworkReply *)));
|
||||
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
|
||||
disconnect(m_manager, &QNetworkAccessManager::finished, this, &ExtNetworkRequest::networkReplyReceived);
|
||||
disconnect(this, &ExtNetworkRequest::requestDataUpdate, this, &ExtNetworkRequest::sendRequest);
|
||||
|
||||
m_manager->deleteLater();
|
||||
}
|
||||
|
@ -40,10 +40,10 @@ ExtScript::ExtScript(QObject *_parent, const QString &_filePath)
|
||||
m_values[tag("custom")] = "";
|
||||
|
||||
m_process = new QProcess(nullptr);
|
||||
connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(updateValue()));
|
||||
connect(m_process, &QProcess::finished, [this]() { return updateValue(); });
|
||||
m_process->waitForFinished(0);
|
||||
|
||||
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(startProcess()));
|
||||
connect(this, &ExtScript::requestDataUpdate, this, &ExtScript::startProcess);
|
||||
}
|
||||
|
||||
|
||||
@ -51,10 +51,9 @@ ExtScript::~ExtScript()
|
||||
{
|
||||
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
|
||||
|
||||
disconnect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(updateValue()));
|
||||
m_process->kill();
|
||||
m_process->deleteLater();
|
||||
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(startProcess()));
|
||||
disconnect(this, &ExtScript::requestDataUpdate, this, &ExtScript::startProcess);
|
||||
}
|
||||
|
||||
|
||||
@ -227,11 +226,11 @@ void ExtScript::readJsonFilters()
|
||||
qCWarning(LOG_LIB) << "Could not open" << fileName;
|
||||
return;
|
||||
}
|
||||
QString jsonText = jsonFile.readAll();
|
||||
auto jsonText = jsonFile.readAll();
|
||||
jsonFile.close();
|
||||
|
||||
QJsonParseError error{};
|
||||
auto jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error);
|
||||
auto jsonDoc = QJsonDocument::fromJson(jsonText, &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
|
||||
return;
|
||||
|
@ -36,10 +36,10 @@ ExtUpgrade::ExtUpgrade(QObject *_parent, const QString &_filePath)
|
||||
m_values[tag("pkgcount")] = 0;
|
||||
|
||||
m_process = new QProcess(nullptr);
|
||||
connect(m_process, SIGNAL(finished(int)), this, SLOT(updateValue()));
|
||||
connect(m_process, &QProcess::finished, [this]() { return updateValue(); });
|
||||
m_process->waitForFinished(0);
|
||||
|
||||
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(startProcess()));
|
||||
connect(this, &ExtUpgrade::requestDataUpdate, this, &ExtUpgrade::startProcess);
|
||||
}
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ ExtUpgrade::~ExtUpgrade()
|
||||
|
||||
m_process->kill();
|
||||
m_process->deleteLater();
|
||||
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(startProcess()));
|
||||
disconnect(this, &ExtUpgrade::requestDataUpdate, this, &ExtUpgrade::startProcess);
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,9 +49,8 @@ ExtWeather::ExtWeather(QObject *_parent, const QString &_filePath)
|
||||
// HACK declare as child of nullptr to avoid crash with plasmawindowed
|
||||
// in the destructor
|
||||
m_manager = new QNetworkAccessManager(nullptr);
|
||||
connect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(weatherReplyReceived(QNetworkReply *)));
|
||||
|
||||
connect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
|
||||
connect(m_manager, &QNetworkAccessManager::finished, this, &ExtWeather::weatherReplyReceived);
|
||||
connect(this, &ExtWeather::requestDataUpdate, this, &ExtWeather::sendRequest);
|
||||
}
|
||||
|
||||
|
||||
@ -59,8 +58,8 @@ ExtWeather::~ExtWeather()
|
||||
{
|
||||
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
|
||||
|
||||
disconnect(m_manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(weatherReplyReceived(QNetworkReply *)));
|
||||
disconnect(this, SIGNAL(requestDataUpdate()), this, SLOT(sendRequest()));
|
||||
disconnect(m_manager, &QNetworkAccessManager::finished, this, &ExtWeather::weatherReplyReceived);
|
||||
disconnect(this, &ExtWeather::requestDataUpdate, this, &ExtWeather::sendRequest);
|
||||
|
||||
m_manager->deleteLater();
|
||||
}
|
||||
@ -150,7 +149,7 @@ int ExtWeather::ts() const
|
||||
|
||||
QString ExtWeather::uniq() const
|
||||
{
|
||||
return QString("%1 (%2) at %3").arg(city()).arg(country()).arg(ts());
|
||||
return QString("%1 (%2) at %3").arg(city(), country()).arg(ts());
|
||||
}
|
||||
|
||||
|
||||
@ -237,11 +236,11 @@ void ExtWeather::readJsonMap()
|
||||
qCWarning(LOG_LIB) << "Could not open" << fileName;
|
||||
return;
|
||||
}
|
||||
QString jsonText = jsonFile.readAll();
|
||||
auto jsonText = jsonFile.readAll();
|
||||
jsonFile.close();
|
||||
|
||||
QJsonParseError error{};
|
||||
auto jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error);
|
||||
auto jsonDoc = QJsonDocument::fromJson(jsonText, &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
|
||||
return;
|
||||
|
@ -33,7 +33,7 @@ QCronScheduler::QCronScheduler(QObject *_parent)
|
||||
m_timer->setSingleShot(false);
|
||||
m_timer->setInterval(60 * 1000);
|
||||
|
||||
connect(m_timer, SIGNAL(timeout()), this, SLOT(expired()));
|
||||
connect(m_timer, &QTimer::timeout, this, &QCronScheduler::expired);
|
||||
|
||||
m_timer->start();
|
||||
}
|
||||
|
Reference in New Issue
Block a user