aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/imagedownloader.cpp33
-rw-r--r--core/qthelper.cpp25
-rw-r--r--core/qthelper.h3
3 files changed, 33 insertions, 28 deletions
diff --git a/core/imagedownloader.cpp b/core/imagedownloader.cpp
index ea6011480..7ce7bde5f 100644
--- a/core/imagedownloader.cpp
+++ b/core/imagedownloader.cpp
@@ -11,7 +11,6 @@
#include <QString>
#include <QImageReader>
#include <QDataStream>
-#include <QSvgRenderer>
#include <QPainter>
#include <QtConcurrent>
@@ -154,33 +153,11 @@ Thumbnailer::Thumbnail Thumbnailer::getHashedImage(const QString &filename, bool
return thumbnail;
}
-static QImage renderIcon(const char *id, int size)
-{
- QImage res(size, size, QImage::Format_RGB32);
- res.fill(Qt::white);
- QSvgRenderer svg{QString(id)};
- QPainter painter(&res);
- svg.render(&painter);
- return res;
-}
-
-// As renderIcon, but render to a fixed width and scale height accordingly
-// and have a transparent background.
-static QImage renderIconWidth(const char *id, int size)
-{
- QSvgRenderer svg{QString(id)};
- QSize svgSize = svg.defaultSize();
- QImage res(size, size * svgSize.height() / svgSize.width(), QImage::Format_ARGB32);
- QPainter painter(&res);
- svg.render(&painter);
- return res;
-}
-
-Thumbnailer::Thumbnailer() : failImage(renderIcon(":filter-close", maxThumbnailSize())), // TODO: Don't misuse filter close icon
- dummyImage(renderIcon(":camera-icon", maxThumbnailSize())),
- videoImage(renderIcon(":video-icon", maxThumbnailSize())),
- videoOverlayImage(renderIconWidth(":video-overlay", maxThumbnailSize())),
- unknownImage(renderIcon(":unknown-icon", maxThumbnailSize()))
+Thumbnailer::Thumbnailer() : failImage(renderSVGIcon(":filter-close", maxThumbnailSize())), // TODO: Don't misuse filter close icon
+ dummyImage(renderSVGIcon(":camera-icon", maxThumbnailSize())),
+ videoImage(renderSVGIcon(":video-icon", maxThumbnailSize())),
+ videoOverlayImage(renderSVGIconWidth(":video-overlay", maxThumbnailSize())),
+ unknownImage(renderSVGIcon(":unknown-icon", maxThumbnailSize()))
{
// Currently, we only process one image at a time. Stefan Fuchs reported problems when
// calculating multiple thumbnails at once and this hopefully helps.
diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index 4db43458b..bebed3cf6 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -36,7 +36,9 @@
#include <QFont>
#include <QApplication>
#include <QTextDocument>
+#include <QPainter>
#include <QProgressDialog> // TODO: remove with convertThumbnails()
+#include <QSvgRenderer>
#include <cstdarg>
#include <cstdint>
#ifdef Q_OS_UNIX
@@ -1701,3 +1703,26 @@ extern "C" void emit_reset_signal()
{
emit diveListNotifier.dataReset();
}
+
+QImage renderSVGIcon(const char *id, int size)
+{
+ QImage res(size, size, QImage::Format_RGB32);
+ res.fill(Qt::white);
+ QSvgRenderer svg{QString(id)};
+ QPainter painter(&res);
+ svg.render(&painter);
+ return res;
+}
+
+// As renderSVGIcon(), but render to a fixed width and scale height accordingly
+// and have a transparent background.
+QImage renderSVGIconWidth(const char *id, int size)
+{
+ QSvgRenderer svg{QString(id)};
+ QSize svgSize = svg.defaultSize();
+ QImage res(size, size * svgSize.height() / svgSize.width(), QImage::Format_ARGB32);
+ QPainter painter(&res);
+ svg.render(&painter);
+ return res;
+}
+
diff --git a/core/qthelper.h b/core/qthelper.h
index c0457256b..152da7f89 100644
--- a/core/qthelper.h
+++ b/core/qthelper.h
@@ -21,6 +21,7 @@ enum watertypes {FRESHWATER, BRACKISHWATER, EN13319WATER, SALTWATER, DC_WATERTYP
#include <QString>
#include "core/gettextfromc.h"
+class QImage;
QString weight_string(int weight_in_grams);
QString distance_string(int distanceInMeters);
@@ -86,6 +87,8 @@ QString getUserAgent();
QString printGPSCoords(const location_t *loc);
std::vector<int> get_cylinder_map_for_remove(int count, int n);
std::vector<int> get_cylinder_map_for_add(int count, int n);
+QImage renderSVGIcon(const char *id, int size);
+QImage renderSVGIconWidth(const char *id, int size);
extern QString (*changesCallback)();
void uiNotification(const QString &msg);