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: