From c109dc8b365e2ce7cc1f0c543e56f8f7653d8770 Mon Sep 17 00:00:00 2001 From: Fushan Wen Date: Thu, 16 Jun 2022 08:27:50 +0800 Subject: [PATCH] wallpapers/image: use `m_formattedSource` in `determineProviderType` No need to call formatUrl again. --- wallpapers/image/plugin/utils/mediaproxy.cpp | 16 ++++++++-------- wallpapers/image/plugin/utils/mediaproxy.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/wallpapers/image/plugin/utils/mediaproxy.cpp b/wallpapers/image/plugin/utils/mediaproxy.cpp index fbedc3e40..8020059e7 100644 --- a/wallpapers/image/plugin/utils/mediaproxy.cpp +++ b/wallpapers/image/plugin/utils/mediaproxy.cpp @@ -62,7 +62,7 @@ void MediaProxy::setSource(const QString &url) m_formattedSource = formatUrl(m_source); Q_EMIT sourceChanged(); - m_providerType = determineType(m_source); + determineProviderType(); updateModelImage(); } @@ -171,7 +171,7 @@ void MediaProxy::useSingleImageDefaults() m_formattedSource = formatUrl(m_source); Q_EMIT sourceChanged(); - m_providerType = determineType(m_source); + determineProviderType(); updateModelImage(); } @@ -211,17 +211,17 @@ bool MediaProxy::isDarkColorScheme(const QPalette &palette) const noexcept return qGray(palette.window().color().rgb()) < 192; } -Provider::Type MediaProxy::determineType(const QUrl &url) +void MediaProxy::determineProviderType() { - QFileInfo info(formatUrl(url).toLocalFile()); + QFileInfo info(m_formattedSource.toLocalFile()); if (info.isFile()) { - return Provider::Type::Image; + m_providerType = Provider::Type::Image; } else if (info.isDir()) { - return Provider::Type::Package; + m_providerType = Provider::Type::Package; + } else { + m_providerType = Provider::Type::Unknown; } - - return Provider::Type::Unknown; } QUrl MediaProxy::findPreferredImageInPackage() diff --git a/wallpapers/image/plugin/utils/mediaproxy.h b/wallpapers/image/plugin/utils/mediaproxy.h index 626c04d06..5da152579 100644 --- a/wallpapers/image/plugin/utils/mediaproxy.h +++ b/wallpapers/image/plugin/utils/mediaproxy.h @@ -83,7 +83,7 @@ private Q_SLOTS: private: inline bool isDarkColorScheme(const QPalette &palette = {}) const noexcept; - Provider::Type determineType(const QUrl &url); + void determineProviderType(); QUrl findPreferredImageInPackage(); void updateModelImage();