summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2013-08-31 00:06:29 (GMT)
committerSwift Review <review@swift.im>2013-08-31 07:09:01 (GMT)
commit2f8ef07f7ac166ee073510fa7fca3c2b353cb9c2 (patch)
tree90a457f3867b3eaead5d5aa63e7c3ae26a27fb0f /Swift
parent36de32c1a64fb814db18cafc7646feff144b5dbe (diff)
downloadswift-2f8ef07f7ac166ee073510fa7fca3c2b353cb9c2.zip
swift-2f8ef07f7ac166ee073510fa7fca3c2b353cb9c2.tar.bz2
Fix Qt warnings in avatar loading and add multi-line support to Base64 decoder.
Change-Id: I451cd5e8a0258e2b6c87fffd1996cdd7319847a4 License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/QtScaledAvatarCache.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/Swift/QtUI/QtScaledAvatarCache.cpp b/Swift/QtUI/QtScaledAvatarCache.cpp
index 6abff87..46ec2fc 100644
--- a/Swift/QtUI/QtScaledAvatarCache.cpp
+++ b/Swift/QtUI/QtScaledAvatarCache.cpp
@@ -14,6 +14,9 @@
#include <QPainter>
#include <QByteArray>
+#include <Swiften/Base/Log.h>
+#include <Swift/QtUI/QtSwiftUtil.h>
+
namespace Swift {
QtScaledAvatarCache::QtScaledAvatarCache(int size) : size(size) {
@@ -31,18 +34,21 @@ QString QtScaledAvatarCache::getScaledAvatarPath(const QString& path) {
QString targetFile = targetDir.absoluteFilePath(avatarFile.baseName());
if (!QFileInfo(targetFile).exists()) {
QPixmap avatarPixmap;
- avatarPixmap.load(path);
- QPixmap maskedAvatar(avatarPixmap.size());
- maskedAvatar.fill(QColor(0, 0, 0, 0));
- QPainter maskPainter(&maskedAvatar);
- maskPainter.setBrush(Qt::black);
- maskPainter.drawRoundedRect(maskedAvatar.rect(), 25.0, 25.0, Qt::RelativeSize);
- maskPainter.setCompositionMode(QPainter::CompositionMode_SourceIn);
- maskPainter.drawPixmap(0, 0, avatarPixmap);
- maskPainter.end();
-
- if (!maskedAvatar.scaled(size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation).save(targetFile, "PNG")) {
- return path;
+ if (avatarPixmap.load(path)) {
+ QPixmap maskedAvatar(avatarPixmap.size());
+ maskedAvatar.fill(QColor(0, 0, 0, 0));
+ QPainter maskPainter(&maskedAvatar);
+ maskPainter.setBrush(Qt::black);
+ maskPainter.drawRoundedRect(maskedAvatar.rect(), 25.0, 25.0, Qt::RelativeSize);
+ maskPainter.setCompositionMode(QPainter::CompositionMode_SourceIn);
+ maskPainter.drawPixmap(0, 0, avatarPixmap);
+ maskPainter.end();
+
+ if (!maskedAvatar.scaled(size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation).save(targetFile, "PNG")) {
+ return path;
+ }
+ } else {
+ SWIFT_LOG(debug) << "Failed to load " << Q2PSTRING(path) << std::endl;
}
}
return targetFile;