OpenWalnut
1.5.0dev
|
Manages icon access. More...
#include <WIconManager.h>
Public Member Functions | |
QIcon | getIcon (const std::string name) |
Searches icons in the internal map and all modules for the given icon name. More... | |
QIcon | getIcon (const std::string name, const QIcon &defaultIcon) |
Searches icons in the internal map and all modules for the given icon name. More... | |
void | addMapping (const std::string &newName, const std::string &mapToThis) |
Add a mapping for icons. More... | |
Static Public Member Functions | |
static QIcon | convertToIcon (WGEImage::SPtr image) |
Convert a WGEImage to an QIcon. More... | |
static QIcon | getNoIconDefault () |
Return an icon representing a default "No Icon" icon. More... | |
Private Attributes | |
std::map< std::string, std::string > | m_iconMappingList |
A map storing icons and the names used to identify them. More... | |
Manages icon access.
Icons stored either here inside or inside of modules.
Definition at line 40 of file WIconManager.h.
void WIconManager::addMapping | ( | const std::string & | newName, |
const std::string & | mapToThis | ||
) |
Add a mapping for icons.
This is useful if you want to use "telling" icons names in your code but want to map these names to some standard icon. The mapping of the new name needs to be unique. Adding multiple mappings for the newName will be ignored. You can overwrite a mapping.
newName | the name getting mapped |
mapToThis | the icon to use when calling getIcon( newName ). Never add a file anding as png or jpg! |
Definition at line 40 of file WIconManager.cpp.
References m_iconMappingList.
Referenced by WMainWindow::setupGUI().
|
static |
Convert a WGEImage to an QIcon.
Image must be 2D. Everything else causes an empty icon to be returned.
image | the image. |
Definition at line 141 of file WIconManager.cpp.
References WGEImage::BOTTOM_LEFT, wlog::error(), and getNoIconDefault().
Referenced by WUIQtViewWidget::addCameraPresetGT(), and WQtDockWidget::addTitleProperty().
QIcon WIconManager::getIcon | ( | const std::string | name | ) |
Searches icons in the internal map and all modules for the given icon name.
name | Name of the requested icon |
Definition at line 52 of file WIconManager.cpp.
References WPathHelper::getPathHelper().
Referenced by WMainWindow::setupGUI(), WQtDataModuleInput::WQtDataModuleInput(), WQtModuleConfig::WQtModuleConfig(), and WQtModuleOneToOneCombinerAction::WQtModuleOneToOneCombinerAction().
QIcon WIconManager::getIcon | ( | const std::string | name, |
const QIcon & | defaultIcon | ||
) |
Searches icons in the internal map and all modules for the given icon name.
In contrast to the single argument getIcon, this does not throw an exception if the icon is not found. It returns a default.
name | Name of the requested icon |
defaultIcon | the default icon to return if no other icon was found. |
Definition at line 60 of file WIconManager.cpp.
References wlog::debug(), WModuleFactory::getModuleFactory(), WPathHelper::getPathHelper(), and m_iconMappingList.
|
static |
Return an icon representing a default "No Icon" icon.
Definition at line 181 of file WIconManager.cpp.
Referenced by convertToIcon().
|
private |
A map storing icons and the names used to identify them.
Definition at line 86 of file WIconManager.h.
Referenced by addMapping(), and getIcon().