From 0aac201c776b6a337782a99e25ad588b1e1871ff Mon Sep 17 00:00:00 2001 From: marian Date: Wed, 27 Apr 2011 11:26:49 +0000 Subject: [PATCH] Added method used to retrieve and load image files from/into global application pixmap cache. git-svn-id: http://yate.null.ro/svn/yate/trunk@4339 acf43c95-373e-0410-b603-e72c3f656dc1 --- clients/qt4/qt4client.cpp | 22 ++++++++++++++++++++++ clients/qt4/qt4client.h | 9 +++++++++ 2 files changed, 31 insertions(+) diff --git a/clients/qt4/qt4client.cpp b/clients/qt4/qt4client.cpp index 6b6c98f0..28510c50 100644 --- a/clients/qt4/qt4client.cpp +++ b/clients/qt4/qt4client.cpp @@ -3973,6 +3973,28 @@ bool QtClient::sendEvent(QEvent& e, QObject* parent, const QString& name) return ok; } +// Retrieve a pixmap from global application cache. +// Load and add it to the cache if not found +bool QtClient::getPixmapFromCache(QPixmap& pixmap, const QString& file) +{ + if (file.isEmpty()) + return false; + QPixmap* cached = QPixmapCache::find(file); + if (cached) { + pixmap = *cached; + return true; + } + if (!pixmap.load(file)) + return false; +#ifdef XDEBUG + String f; + getUtf8(f,file); + Debug(ClientDriver::self(),DebugAll,"Loaded '%s' in pixmap cache",f.c_str()); +#endif + QPixmapCache::insert(file,pixmap); + return true; +} + /** * QtDriver diff --git a/clients/qt4/qt4client.h b/clients/qt4/qt4client.h index 119f9885..66db38d8 100644 --- a/clients/qt4/qt4client.h +++ b/clients/qt4/qt4client.h @@ -500,6 +500,15 @@ public: */ static bool sendEvent(QEvent& e, QObject* parent, const QString& name); + /** + * Retrieve a pixmap from global application cache. + * Load and add it to the cache if not found + * @param pixmap Destination pixmap to set + * @param file File name to retrieve or load + * @return True on success, false if failed to load + */ + static bool getPixmapFromCache(QPixmap& pixmap, const QString& file); + protected: virtual void loadWindows(const char* file = 0); private: