Commit b916894d authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - the combiner-actionlist now uses the module default icon too

parent 565ff8e6
......@@ -46,7 +46,7 @@ QIcon WIconManager::getIcon( const std::string name )
}
else if( WModuleFactory::getModuleFactory()->getPrototypeByName( name ) )
{
icon = QIcon( QPixmap( WModuleFactory::getModuleFactory()->getPrototypeByName( name )->getXPMIcon() ) );
icon = QIcon( QPixmap( WModuleFactory::getModuleFactory()->getPrototypeByName( name )->getXPMIcon() ) );
}
else
{
......@@ -55,3 +55,19 @@ QIcon WIconManager::getIcon( const std::string name )
return icon;
}
QIcon WIconManager::getIcon( const std::string name, const QIcon& defaultIcon )
{
if( m_iconList.count( name ) != 0 )
{
return *m_iconList[name];
}
else if( WModuleFactory::getModuleFactory()->getPrototypeByName( name ) )
{
return QIcon( QPixmap( WModuleFactory::getModuleFactory()->getPrototypeByName( name )->getXPMIcon() ) );
}
else
{
return QIcon( defaultIcon );
}
}
......@@ -50,6 +50,14 @@ public:
*/
QIcon getIcon( const std::string name );
/**
* Searches icons in the internal map and all modules for the given icon name. I contrast to the single argument getIcon, this does not throw
* an exception if the icon is not found. It returns a default.
* \param name Name of the requested icon
* \param defaultIcon the default icon to return if no other icon was found.
* \return A QIcon copy if the icon name was found otherwise, the default is returned
*/
QIcon getIcon( const std::string name, const QIcon& defaultIcon );
protected:
private:
std::map< std::string, QIcon* > m_iconList; //!< A map storing icons and the names used to identify them
......
......@@ -69,7 +69,9 @@ WQtModuleOneToOneCombinerAction::WQtModuleOneToOneCombinerAction( QWidget* paren
setToolTip( tooltip.c_str() );
setText( advancedText ? advancedTextString.c_str() : targetName.c_str() );
setIconText( advancedText ? tooltip.c_str() : targetName.c_str() );
setIcon( iconManager->getIcon( m_combiner->getTargetModule()->getName().c_str() ) );
// get an icon for this module
setIcon( iconManager->getIcon( m_combiner->getTargetModule()->getName().c_str(), iconManager->getIcon( "DefaultModuleIcon" ) ) );
// we need to use released signal here, as the pushed signal also gets emitted on newly created buttons which are under the mouse pointer with
// pressed left button.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment