gui: Add checkboxes for alpha/opaque in surfaces view.
- pass alpha/opaque settings through to image viewer
- removed caching of thumbnails in ApiSurface instances
- updating thumbnails (due to changed alpha/opaque settings) did not
mesh with constness
- ApiSurfaces should be unaware of thumbnails -> caching should happen
e.g. in SurfacesView
Fixes #374.
diff --git a/gui/apisurface.cpp b/gui/apisurface.cpp
index 4f0a917..e1ce2a1 100644
--- a/gui/apisurface.cpp
+++ b/gui/apisurface.cpp
@@ -2,6 +2,7 @@
#include "thumbnail.h"
#include <sstream>
+#include <memory>
#include <QDebug>
#include <QSysInfo>
@@ -31,18 +32,26 @@
}
};
-void ApiSurface::setData(const QByteArray &data)
+QImage ApiSurface::calculateThumbnail(bool opaque, bool alpha) const
{
- m_data = data;
+ return m_data.isEmpty() ? QImage{} : calculateThumbnail(m_data, opaque, alpha);
+}
+QImage ApiSurface::calculateThumbnail(const QByteArray &data, bool opaque,
+ bool alpha) const
+{
/*
* We need to do the conversion to create the thumbnail
*/
- image::Image *image = imageFromData(data);
+ std::unique_ptr<image::Image> image{imageFromData(data)};
Q_ASSERT(image);
- QImage img = qimageFromRawImage(image);
- m_thumb = thumbnail(img);
- delete image;
+ QImage img = qimageFromRawImage(image.get(), 0.0f, 1.0f, opaque, alpha);
+ return thumbnail(img);
+}
+
+void ApiSurface::setData(const QByteArray &data)
+{
+ m_data = data;
}
QByteArray ApiSurface::data() const
@@ -50,11 +59,6 @@
return m_data;
}
-QImage ApiSurface::thumb() const
-{
- return m_thumb;
-}
-
int ApiSurface::depth() const
{
return m_depth;