AppFwk: Made updateUiIconFromState handle dynamically assigned icons, and become uiConfigName aware.

This commit is contained in:
Jacob Støren 2017-02-15 18:23:14 +01:00
parent a29fe1f7c1
commit 392dfac190
2 changed files with 17 additions and 15 deletions

View File

@ -280,26 +280,28 @@ PdmUiItem::~PdmUiItem()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiItem::updateUiIconFromState(bool active)
void PdmUiItem::updateUiIconFromState(bool isActive, QString uiConfigName)
{
// Reset dynamic icon
this->setUiIcon(QIcon());
// Get static one
QIcon icon = this->uiIcon();
static const QString iconStorageConfigNamePostfix = "_Internally_StoredNormalIcon";
const PdmUiItemInfo* conInfo = configInfo(uiConfigName + iconStorageConfigNamePostfix);
QIcon normalIcon;
// Get a pixmap, and modify it
if (conInfo) normalIcon = conInfo->m_icon;
else normalIcon = this->uiIcon(uiConfigName);
QPixmap icPixmap;
icPixmap = icon.pixmap(16, 16, QIcon::Normal);
this->setUiIcon(normalIcon, uiConfigName + iconStorageConfigNamePostfix);
if (!active)
if ( isActive )
{
QIcon temp(icPixmap);
icPixmap = temp.pixmap(16, 16, QIcon::Disabled);
this->setUiIcon(normalIcon, uiConfigName);
m_configItemInfos.erase(uiConfigName + iconStorageConfigNamePostfix);
}
else
{
QIcon disabledIcon(normalIcon.pixmap(16, 16, QIcon::Disabled));
this->setUiIcon(disabledIcon, uiConfigName);
this->setUiIcon(normalIcon, uiConfigName + iconStorageConfigNamePostfix);
}
QIcon newIcon(icPixmap);
this->setUiIcon(newIcon);
}
} //End of namespace caf

View File

@ -221,7 +221,7 @@ public:
void updateConnectedEditors();
void updateUiIconFromState(bool active);
void updateUiIconFromState(bool isActive, QString uiConfigName = "");
public: // Pdm-Private only
//==================================================================================================