old render cleanup part 1

This commit is contained in:
Agel committed 2026-10-25 14:22:12 +01:00
1 parent 83968646c6
commit acc7e71e7b
38 files changed
+166 -1366

No files matched your search

+4 -48
View File
@@ -11,7 +11,6 @@
QImage EntryImageProvider::loadImageFromSource(IByteSource &source,
const QString &entryName,
int displayWidth,
const QSize &requestedSize)
{
if (entryName.isEmpty())
@@ -25,7 +24,7 @@ QImage EntryImageProvider::loadImageFromSource(IByteSource &source,
if (!image.loadFromData(data))
return {};
return scaleToFit(image, displayWidth, requestedSize);
return scaleToFit(image, requestedSize);
}
EntryImageProvider::EntryImageProvider(SourceFactory sourceFactory, QString scheme)
@@ -38,11 +37,9 @@ QQuickImageResponse *EntryImageProvider::requestImageResponse(const QString &id,
const QSize &requestedSize)
{
QString sourcePath;
int displayWidth;
{
QMutexLocker lock(&m_mutex);
sourcePath = m_sourcePath;
displayWidth = m_displayWidth;
sourcePath = m_sourcePath;
}
// id may be "entry/name.jpg?src=<encoded-path>"
@@ -52,50 +49,16 @@ QQuickImageResponse *EntryImageProvider::requestImageResponse(const QString &id,
sourcePath = parsed.sourcePath;
auto *response = new AsyncImageResponse(
[factory = m_sourceFactory, sourcePath, entryName, displayWidth, requestedSize]() -> QImage {
[factory = m_sourceFactory, sourcePath, entryName, requestedSize]() -> QImage {
auto source = factory();
if (!source->open(sourcePath))
return {};
return loadImageFromSource(*source, entryName, displayWidth, requestedSize);
return loadImageFromSource(*source, entryName, requestedSize);
});
QThreadPool::globalInstance()->start(response);
return response;
}
QImage EntryImageProvider::load(const QUrl &url, int maxWidth) const
{
if (url.scheme() != QLatin1String("image"))
return {};
const ImageUrl::Parsed parsed = ImageUrl::parseImageUrl(url);
const QString entryName = parsed.entry;
if (entryName.isEmpty())
return {};
QString sourcePath = parsed.sourcePath;
if (sourcePath.isEmpty()) {
QMutexLocker lock(&m_mutex);
sourcePath = m_sourcePath;
}
auto source = m_sourceFactory();
if (!source->open(sourcePath))
return {};
return loadImageFromSource(*source, entryName, maxWidth, {});
}
std::unique_ptr<IImageLoader> EntryImageProvider::clone() const
{
QString sourcePath;
{
QMutexLocker lock(&m_mutex);
sourcePath = m_sourcePath;
}
auto c = std::make_unique<EntryImageProvider>(m_sourceFactory, m_scheme);
c->setFilePath(sourcePath);
return c;
}
void EntryImageProvider::setFilePath(const QString &filePath)
{
QMutexLocker lock(&m_mutex);
@@ -114,15 +77,8 @@ QString EntryImageProvider::scheme() const
return m_scheme;
}
void EntryImageProvider::setDisplayWidth(int width)
{
QMutexLocker lock(&m_mutex);
m_displayWidth = width;
}
void EntryImageProvider::clear()
{
QMutexLocker lock(&m_mutex);
m_sourcePath.clear();
m_displayWidth = 0;
}