OpenWalnut  1.5.0dev
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
WIconManager Class Reference

Manages icon access. More...

#include <WIconManager.h>

+ Collaboration diagram for WIconManager:

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

Detailed Description

Manages icon access.

Icons stored either here inside or inside of modules.

Definition at line 40 of file WIconManager.h.

Member Function Documentation

◆ addMapping()

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.

Parameters
newNamethe name getting mapped
mapToThisthe 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().

+ Here is the caller graph for this function:

◆ convertToIcon()

QIcon WIconManager::convertToIcon ( WGEImage::SPtr  image)
static

Convert a WGEImage to an QIcon.

Image must be 2D. Everything else causes an empty icon to be returned.

Parameters
imagethe image.
Returns
icon

Definition at line 141 of file WIconManager.cpp.

References WGEImage::BOTTOM_LEFT, wlog::error(), and getNoIconDefault().

Referenced by WUIQtViewWidget::addCameraPresetGT(), and WQtDockWidget::addTitleProperty().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIcon() [1/2]

QIcon WIconManager::getIcon ( const std::string  name)

Searches icons in the internal map and all modules for the given icon name.

Parameters
nameName of the requested icon
Returns
A QIcon copy if the icon name was found otherwise a WAssert will fail.

Definition at line 52 of file WIconManager.cpp.

References WPathHelper::getPathHelper().

Referenced by WMainWindow::setupGUI(), WQtDataModuleInput::WQtDataModuleInput(), WQtModuleConfig::WQtModuleConfig(), and WQtModuleOneToOneCombinerAction::WQtModuleOneToOneCombinerAction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIcon() [2/2]

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.

Parameters
nameName of the requested icon
defaultIconthe default icon to return if no other icon was found.
Returns
A QIcon copy if the icon name was found otherwise, the default is returned

Definition at line 60 of file WIconManager.cpp.

References wlog::debug(), WModuleFactory::getModuleFactory(), WPathHelper::getPathHelper(), and m_iconMappingList.

+ Here is the call graph for this function:

◆ getNoIconDefault()

QIcon WIconManager::getNoIconDefault ( )
static

Return an icon representing a default "No Icon" icon.

Returns
the icon

Definition at line 181 of file WIconManager.cpp.

Referenced by convertToIcon().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_iconMappingList

std::map< std::string, std::string > WIconManager::m_iconMappingList
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().


The documentation for this class was generated from the following files: