[weather] Port away from Q_PRIVATE_SLOT

parent 148180d3
......@@ -48,8 +48,8 @@ WeatherLocation::WeatherLocation(QObject *parent)
: QObject(parent)
, d(new WeatherLocationPrivate(this))
{
QObject::connect(&d->validator, SIGNAL(finished(QMap<QString,QString>)),
this, SLOT(validatorFinished(QMap<QString,QString>)));
connect(&d->validator, &WeatherValidator::finished,
this, [&](const QMap<QString, QString>& sources) { d->validatorFinished(sources); } );
}
WeatherLocation::~WeatherLocation() = default;
......@@ -90,7 +90,3 @@ void WeatherLocation::dataUpdated(const QString &source, const Plasma::DataEngin
emit finished(QString());
}
// needed due to private slots
#include "moc_weatherlocation.cpp"
......@@ -58,8 +58,6 @@ public Q_SLOTS:
private:
const QScopedPointer<class WeatherLocationPrivate> d;
Q_PRIVATE_SLOT(d, void validatorFinished(const QMap<QString, QString> &results))
};
#endif
......@@ -45,7 +45,8 @@ public:
busyTimer = new QTimer(q);
busyTimer->setInterval(2*60*1000);
busyTimer->setSingleShot(true);
QObject::connect(busyTimer, SIGNAL(timeout()), q, SLOT(giveUpBeingBusy()));
QObject::connect(busyTimer, &QTimer::timeout,
q, [&]() { giveUpBeingBusy(); });
}
WeatherPopupApplet *q;
......@@ -66,6 +67,7 @@ public:
double longitude;
QTimer *busyTimer;
KNotification *timeoutNotification;
QMetaObject::Connection timeoutNotificationConnection;
bool isValidLatitude() {
return -90 <= latitude && latitude <= 90;
......@@ -108,7 +110,10 @@ public:
KNotification::event( KNotification::Error, QString(), // TODO: some title?
i18n("Weather information retrieval for %1 timed out.", list.value(2)),
QStringLiteral("dialog-error"));
QObject::connect(timeoutNotification, SIGNAL(closed()), q, SLOT(onTimeoutNotificationClosed()));
// seems global disconnect with wildcard does not cover lambdas, so remembering manually for disconnect
timeoutNotificationConnection =
QObject::connect(timeoutNotification, &KNotification::closed,
q, [&]() { onTimeoutNotificationClosed(); });
}
}
......@@ -220,7 +225,7 @@ void WeatherPopupApplet::init()
void WeatherPopupApplet::connectToEngine()
{
if (d->timeoutNotification) {
QObject::disconnect(d->timeoutNotification, SIGNAL(closed()), this, SLOT(onTimeoutNotificationClosed()));
QObject::disconnect(d->timeoutNotificationConnection);
d->timeoutNotification = nullptr;
}
......@@ -231,7 +236,8 @@ void WeatherPopupApplet::connectToEngine()
#if 0
if (!d->location) {
d->location = new WeatherLocation(this);
connect(d->location, SIGNAL(finished(QString)), this, SLOT(locationReady(QString)));
connect(d->location, &WeatherLocation::finished,
this, [&](const QString& source) { d->locationReady(source); });
}
Plasma::DataEngine *dataEngine = dataEngine(QStringLiteral("geolocation"));
......@@ -412,7 +418,3 @@ QString WeatherPopupApplet::conditionIcon()
}
return d->conditionIcon;
}
// needed due to private slots
#include "moc_weatherpopupapplet.cpp"
......@@ -113,9 +113,6 @@ class PLASMAWEATHER_EXPORT WeatherPopupApplet : public Plasma::Applet, public Pl
const QScopedPointer<class WeatherPopupAppletPrivate> d;
friend class WeatherPopupAppletPrivate;
Q_PRIVATE_SLOT(d, void locationReady(const QString &source))
Q_PRIVATE_SLOT(d, void giveUpBeingBusy())
Q_PRIVATE_SLOT(d, void onTimeoutNotificationClosed())
};
#endif
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