From 6c742be8627389d4de6a8373da80beac5ae6ef1e Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Fri, 27 May 2011 15:44:59 +0200 Subject: [PATCH] Resolved missing icon for Favorite --- src/board/UBLibraryController.cpp | 7 +++++-- src/tools/UBToolsManager.cpp | 6 +++++- src/tools/UBToolsManager.h | 3 +++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/board/UBLibraryController.cpp b/src/board/UBLibraryController.cpp index ebe780fd..78e39792 100644 --- a/src/board/UBLibraryController.cpp +++ b/src/board/UBLibraryController.cpp @@ -262,6 +262,9 @@ QImage* UBLibraryController::createThumbnail(UBLibElement* pElement) QImage* UBLibraryController::thumbnailForFile(UBLibElement* pElement) { + if (pElement->path().toString().contains("uniboardTool://")) + return &UBToolsManager::manager()->iconFromToolId(pElement->path().toString()).toImage(); + QString thumbnailPath = UBFileSystemUtils::thumbnailPath(pElement->path().toLocalFile()); if (!thumbnailPath.length()) @@ -490,7 +493,7 @@ void UBLibraryController::persistFavoriteList() foreach(UBLibElement* eachElement, mFavoriteList) { out << (quint32)eachElement->type(); - out << eachElement->path(); + out << eachElement->path().toString(); out << eachElement->information(); out << eachElement->name(); out << eachElement->extension(); @@ -517,7 +520,7 @@ void UBLibraryController::readFavoriteList() in >> type >> path >> info >> name >> extension; - UBLibElement* eachElement = new UBLibElement((eUBLibElementType)type, path, name); + UBLibElement* eachElement = new UBLibElement((eUBLibElementType)type, QUrl(path), name); eachElement->setInformation(info); eachElement->setExtension(extension); eachElement->setThumbnail(thumbnailForFile(eachElement)); diff --git a/src/tools/UBToolsManager.cpp b/src/tools/UBToolsManager.cpp index f4ad0164..72cc8d0c 100644 --- a/src/tools/UBToolsManager.cpp +++ b/src/tools/UBToolsManager.cpp @@ -17,24 +17,28 @@ UBToolsManager::UBToolsManager(QObject *parent) mask.icon = QPixmap(":/images/toolPalette/maskTool.png"); mask.label = tr("Mask"); mask.version = "1.0"; + mToolsIcon.insert(mask.id, mask.icon); mDescriptors << mask; ruler.id = "uniboardTool://uniboard.mnemis.com/ruler"; ruler.icon = QPixmap(":/images/toolPalette/rulerTool.png"); ruler.label = tr("Ruler"); ruler.version = "1.0"; + mToolsIcon.insert(ruler.id, ruler.icon); mDescriptors << ruler; compass.id = "uniboardTool://uniboard.mnemis.com/compass"; compass.icon = QPixmap(":/images/toolPalette/compassTool.png"); compass.label = tr("Compass"); compass.version = "1.0"; + mToolsIcon.insert(compass.id, compass.icon); mDescriptors << compass; protractor.id = "uniboardTool://uniboard.mnemis.com/protractor"; protractor.icon = QPixmap(":/images/toolPalette/protractorTool.png"); protractor.label = tr("Protractor"); protractor.version = "1.0"; + mToolsIcon.insert(protractor.id, protractor.icon); mDescriptors << protractor; } @@ -42,4 +46,4 @@ UBToolsManager::UBToolsManager(QObject *parent) UBToolsManager::~UBToolsManager() { // NOOP -} +} \ No newline at end of file diff --git a/src/tools/UBToolsManager.h b/src/tools/UBToolsManager.h index a483fbe3..f07512b4 100644 --- a/src/tools/UBToolsManager.h +++ b/src/tools/UBToolsManager.h @@ -70,6 +70,7 @@ class UBToolsManager : public QObject UBToolDescriptor compass; UBToolDescriptor mask; + QPixmap iconFromToolId(QString id) { return mToolsIcon.value(id);} private: UBToolsManager(QObject *parent = 0); @@ -79,6 +80,8 @@ class UBToolsManager : public QObject QList mDescriptors; + QMap mToolsIcon; + }; #endif /* UBTOOLSMANAGER_H_ */