mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-21 22:13:25 -06:00
AppFwk: Made updateUiIconFromState handle dynamically assigned icons, and become uiConfigName aware.
This commit is contained in:
parent
a29fe1f7c1
commit
392dfac190
@ -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
|
||||
|
@ -221,7 +221,7 @@ public:
|
||||
|
||||
void updateConnectedEditors();
|
||||
|
||||
void updateUiIconFromState(bool active);
|
||||
void updateUiIconFromState(bool isActive, QString uiConfigName = "");
|
||||
|
||||
public: // Pdm-Private only
|
||||
//==================================================================================================
|
||||
|
Loading…
Reference in New Issue
Block a user