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
This commit is contained in:
marian 2011-04-27 11:26:49 +00:00
parent dc434fea6d
commit 0aac201c77
2 changed files with 31 additions and 0 deletions

View File

@ -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

View File

@ -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: