Fixed missing icons in certain states

This commit is contained in:
Jan Lochmatter 2018-01-10 10:07:38 +01:00
parent 8c99d8127e
commit 4c78c5d41b

View File

@ -35,6 +35,9 @@ protected:
case QIcon::Selected: case QIcon::Selected:
modePostfix = "-selected"; modePostfix = "-selected";
break; break;
default: // QIcon::Normal:
// modePostfix = "";
break;
} }
QString statePostfix; QString statePostfix;
@ -60,23 +63,19 @@ protected:
QVariant optionValueForModeAndState( const QString& baseKey, QIcon::Mode mode, QIcon::State state, const QVariantMap& options ) QVariant optionValueForModeAndState( const QString& baseKey, QIcon::Mode mode, QIcon::State state, const QVariantMap& options )
{ {
foreach( QString key, optionKeysForModeAndState(baseKey, mode, state) ) { foreach( QString key, optionKeysForModeAndState(baseKey, mode, state) ) {
if( options.contains(key)) return options.value(key); //if ( options.contains(key) && options.value(key).toString().isEmpty()) qDebug() << "Not found:" << key;
if( options.contains(key) && !(options.value(key).toString().isEmpty()) )
return options.value(key);
} }
return options.value(baseKey); return options.value(baseKey);
} }
public: public:
virtual void paint( QtAwesome* awesome, QPainter* painter, const QRect& rect, QIcon::Mode mode, QIcon::State state, const QVariantMap& options ) virtual void paint( QtAwesome* awesome, QPainter* painter, const QRect& rect, QIcon::Mode mode, QIcon::State state, const QVariantMap& options )
{ {
Q_UNUSED(mode);
Q_UNUSED(state);
Q_UNUSED(options);
painter->save(); painter->save();
QVariant var =options.value("anim"); QVariant var =options.value("anim");
@ -85,56 +84,12 @@ public:
anim->setup( *painter, rect ); anim->setup( *painter, rect );
} }
// get the correct key postfix
QString modePostfix;
switch(mode) {
case QIcon::Disabled:
modePostfix = "-disabled";
break;
case QIcon::Active:
modePostfix = "-active";
break;
case QIcon::Selected:
modePostfix = "-selected";
break;
}
QString statePostFix;
if( state == QIcon::Off) {
statePostFix = "-off";
}
// set the default options // set the default options
QColor color = optionValueForModeAndState("color", mode, state, options).value<QColor>(); QColor color = optionValueForModeAndState("color", mode, state, options).value<QColor>();
QString text = optionValueForModeAndState("text", mode, state, options).toString(); QString text = optionValueForModeAndState("text", mode, state, options).toString();
Q_ASSERT(color.isValid());
/* Q_ASSERT(!text.isEmpty());
// set the correct color
QColor color = options.value("color").value<QColor>();
QString text = options.value("text").toString();
if( mode == QIcon::Disabled ) {
color = options.value("color-disabled").value<QColor>();
QVariant alt = options.value("text-disabled");
if( alt.isValid() ) {
text = alt.toString();
}
} else if( mode == QIcon::Active ) {
color = options.value("color-active").value<QColor>();
QVariant alt = options.value("text-active");
if( alt.isValid() ) {
text = alt.toString();
}
} else if( mode == QIcon::Selected ) {
color = options.value("color-selected").value<QColor>();
QVariant alt = options.value("text-selected");
if( alt.isValid() ) {
text = alt.toString();
}
}
*/
painter->setPen(color); painter->setPen(color);