Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed missing icons in certain states #31

Merged
merged 1 commit into from
Feb 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
63 changes: 9 additions & 54 deletions QtAwesome/QtAwesome.cpp
Expand Up @@ -35,6 +35,9 @@ class QtAwesomeCharIconPainter: public QtAwesomeIconPainter
case QIcon::Selected:
modePostfix = "-selected";
break;
default: // QIcon::Normal:
// modePostfix = "";
break;
}

QString statePostfix;
Expand All @@ -60,23 +63,19 @@ class QtAwesomeCharIconPainter: public QtAwesomeIconPainter
QVariant optionValueForModeAndState( const QString& baseKey, QIcon::Mode mode, QIcon::State state, const QVariantMap& options )
{
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);
}




public:


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();

QVariant var =options.value("anim");
Expand All @@ -85,56 +84,12 @@ class QtAwesomeCharIconPainter: public QtAwesomeIconPainter
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
QColor color = optionValueForModeAndState("color", mode, state, options).value<QColor>();
QString text = optionValueForModeAndState("text", mode, state, options).toString();


/*
// 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();
}
}
*/

Q_ASSERT(color.isValid());
Q_ASSERT(!text.isEmpty());

painter->setPen(color);

Expand Down