Commit 4427e0e9 authored by Fushan Wen's avatar Fushan Wen Committed by Nate Graham
Browse files

dataengines/potd: Use PotdProviderData to store information for SaveImageThread::done

As the number of roles increases, it's necessary to change the argument
type to make it possible to convey more information in the argument.
parent 24655730
......@@ -39,7 +39,10 @@ void SaveImageThread::run()
{
const QString path = CachedProvider::identifierToPath(m_identifier);
m_image.save(path, "JPEG");
Q_EMIT done(m_identifier, path, m_image);
PotdProviderData data;
data.wallpaperImage = m_image;
data.wallpaperLocalUrl = path;
Q_EMIT done(m_identifier, data);
}
QString CachedProvider::identifierToPath(const QString &identifier)
......
......@@ -79,7 +79,7 @@ public:
void run() override;
Q_SIGNALS:
void done(const QString &source, const QString &path, const QImage &img);
void done(const QString &source, const PotdProviderData &data);
private:
QImage m_image;
......
......@@ -30,6 +30,8 @@ PotdProviderModel::PotdProviderModel(QObject *parent)
connect(&m_checkDatesTimer, &QTimer::timeout, this, &PotdProviderModel::forceUpdateSource);
m_checkDatesTimer.setInterval(10min); // check every 10 minutes
qRegisterMetaType<PotdProviderData>();
}
int PotdProviderModel::rowCount(const QModelIndex &parent) const
......@@ -337,11 +339,11 @@ void PotdProviderModel::slotFinished(PotdProvider *provider)
provider->deleteLater();
}
void PotdProviderModel::slotCachingFinished(const QString &source, const QString &path, const QImage &img)
void PotdProviderModel::slotCachingFinished(const QString &source, const PotdProviderData &data)
{
Q_UNUSED(source)
setImage(img);
setLocalUrl(path);
setImage(data.wallpaperImage);
setLocalUrl(data.wallpaperLocalUrl);
}
void PotdProviderModel::slotError(PotdProvider *provider)
......
......@@ -92,7 +92,7 @@ Q_SIGNALS:
private Q_SLOTS:
void slotFinished(PotdProvider *);
void slotCachingFinished(const QString &source, const QString &path, const QImage &img);
void slotCachingFinished(const QString &source, const PotdProviderData &data);
void slotError(PotdProvider *);
void slotPrepareForSleep(bool sleep);
......
Supports Markdown
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