Verified Commit 25aaec21 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

wallpapers/image: store formatted source url

No need to call formatUrl every time using it.
parent 62e3aef4
Pipeline #190797 passed with stage
in 6 minutes and 37 seconds
......@@ -59,6 +59,7 @@ void MediaProxy::setSource(const QString &url)
}
m_source = QUrl(url);
m_formattedSource = formatUrl(m_source);
Q_EMIT sourceChanged();
m_providerType = determineType(m_source);
......@@ -167,6 +168,9 @@ void MediaProxy::useSingleImageDefaults()
return;
}
m_formattedSource = formatUrl(m_source);
Q_EMIT sourceChanged();
m_providerType = determineType(m_source);
updateModelImage();
}
......@@ -223,7 +227,7 @@ Provider::Type MediaProxy::determineType(const QUrl &url)
QUrl MediaProxy::findPreferredImageInPackage()
{
KPackage::Package package = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Wallpaper/Images"));
package.setPath(formatUrl(m_source).toLocalFile());
package.setPath(m_formattedSource.toLocalFile());
QUrl url;
......@@ -255,7 +259,7 @@ void MediaProxy::updateModelImage()
switch (m_providerType) {
case Provider::Type::Image: {
newRealSource = formatUrl(m_source);
newRealSource = m_formattedSource;
break;
}
......@@ -264,7 +268,7 @@ void MediaProxy::updateModelImage()
QUrl composedUrl(QStringLiteral("image://package/get"));
QUrlQuery urlQuery(composedUrl);
urlQuery.addQueryItem(QStringLiteral("dir"), formatUrl(m_source).toLocalFile());
urlQuery.addQueryItem(QStringLiteral("dir"), m_formattedSource.toLocalFile());
// To make modelImageChaged work
urlQuery.addQueryItem(QStringLiteral("targetWidth"), QString::number(m_targetSize.width()));
urlQuery.addQueryItem(QStringLiteral("targetHeight"), QString::number(m_targetSize.height()));
......
......@@ -91,6 +91,7 @@ private:
bool m_ready = false;
QUrl m_source;
QUrl m_formattedSource;
QUrl m_modelImage;
Provider::Type m_providerType = Provider::Type::Unknown;
......
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