summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/FreeDesktopNotifier.cpp2
-rw-r--r--Swift/QtUI/FreeDesktopNotifier.h2
-rw-r--r--Swift/QtUI/QtCachedImageScaler.cpp38
-rw-r--r--Swift/QtUI/QtCachedImageScaler.h19
-rw-r--r--Swift/QtUI/SConscript1
5 files changed, 61 insertions, 1 deletions
diff --git a/Swift/QtUI/FreeDesktopNotifier.cpp b/Swift/QtUI/FreeDesktopNotifier.cpp
index 6f680da..eacaa09 100644
--- a/Swift/QtUI/FreeDesktopNotifier.cpp
+++ b/Swift/QtUI/FreeDesktopNotifier.cpp
@@ -39,7 +39,7 @@ void FreeDesktopNotifier::showMessage(Type type, const String& subject, const St
QMap<QString, QVariant> hints;
msg << P2QSTRING(applicationName);
msg << quint32(0); // ID of previous notification to replace
- msg << picture.string().c_str(); // Icon to display
+ msg << imageScaler.getScaledImage(picture, 48).string().c_str(); // Icon to display
msg << P2QSTRING(subject); // Summary / Header of the message to display
msg << P2QSTRING(description); // Body of the message to display
msg << actions; // Actions from which the user may choose
diff --git a/Swift/QtUI/FreeDesktopNotifier.h b/Swift/QtUI/FreeDesktopNotifier.h
index 6583493..0bbf6bb 100644
--- a/Swift/QtUI/FreeDesktopNotifier.h
+++ b/Swift/QtUI/FreeDesktopNotifier.h
@@ -7,6 +7,7 @@
#pragma once
#include "SwifTools/Notifier/Notifier.h"
+#include "QtCachedImageScaler.h"
namespace Swift {
class FreeDesktopNotifier : public Notifier {
@@ -17,5 +18,6 @@ namespace Swift {
private:
String applicationName;
+ QtCachedImageScaler imageScaler;
};
}
diff --git a/Swift/QtUI/QtCachedImageScaler.cpp b/Swift/QtUI/QtCachedImageScaler.cpp
new file mode 100644
index 0000000..7307577
--- /dev/null
+++ b/Swift/QtUI/QtCachedImageScaler.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "QtCachedImageScaler.h"
+
+#include <QImage>
+#include <boost/lexical_cast.hpp>
+
+namespace Swift {
+
+QtCachedImageScaler::QtCachedImageScaler() {
+}
+
+boost::filesystem::path QtCachedImageScaler::getScaledImage(const boost::filesystem::path& imagePath, int size) {
+ boost::filesystem::path scaledImagePath(imagePath.string() + "." + boost::lexical_cast<std::string>(size));
+ if (!boost::filesystem::exists(scaledImagePath)) {
+ QImage image(imagePath.string().c_str());
+ if (!image.isNull()) {
+ if (image.width() > size || image.height() > size) {
+ QImage scaledImage = image.scaled(size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ scaledImage.save(QString::fromUtf8(scaledImagePath.string().c_str()), "PNG");
+ }
+ else {
+ image.save(QString::fromUtf8(scaledImagePath.string().c_str()), "PNG");
+ }
+ }
+ else {
+ return imagePath;
+ }
+ }
+ return scaledImagePath;
+
+}
+
+}
diff --git a/Swift/QtUI/QtCachedImageScaler.h b/Swift/QtUI/QtCachedImageScaler.h
new file mode 100644
index 0000000..f85357f
--- /dev/null
+++ b/Swift/QtUI/QtCachedImageScaler.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <boost/filesystem.hpp>
+
+namespace Swift {
+ class QtCachedImageScaler {
+ public:
+ QtCachedImageScaler();
+
+ boost::filesystem::path getScaledImage(const boost::filesystem::path& image, int size);
+ };
+}
+
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript
index 0bb0708..53c023a 100644
--- a/Swift/QtUI/SConscript
+++ b/Swift/QtUI/SConscript
@@ -77,6 +77,7 @@ sources = [
"QtChatTabs.cpp",
"QtSoundPlayer.cpp",
"QtSystemTray.cpp",
+ "QtCachedImageScaler.cpp",
"QtTabbable.cpp",
"QtTabWidget.cpp",
"QtTextEdit.cpp",