Skip to content

Commit

Permalink
Load icon for chainview buttons correctly. Looks like crap though. :-)
Browse files Browse the repository at this point in the history
  • Loading branch information
laudrup committed Jun 23, 2011
1 parent 14f5b12 commit c3d5887
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
23 changes: 1 addition & 22 deletions creox/crbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ void CrButton::drawButton(QPainter* painter)
//if (isOn())
// option.features |= QStyleOptionButton::DefaultButton;
option.text = text();
KIconLoader* const iconLoader = KIconLoader::global();
option.icon = iconLoader->loadIcon(m_iconName, KIconLoader::NoGroup, KIconLoader::SizeSmall,
KIconLoader::DefaultState);
option.icon = KIcon(m_iconName);

//QPainter painter(this);
style()->drawControl(QStyle::CE_PushButton, &option, painter, this);
Expand All @@ -154,25 +152,6 @@ void CrButton::drawButton(QPainter* painter)
//drawButtonLabel(painter);
}

void CrButton::drawButtonLabel(QPainter* painter)
{
//drawIcon
if(!m_iconName.isNull()){
KIconLoader* const iconLoader = KIconLoader::global();
const int state = (isOn()) ? KIconLoader::DefaultState : KIconLoader::DisabledState;
const QPixmap icon = iconLoader->loadIcon(m_iconName, KIconLoader::NoGroup,
KIconLoader::SizeSmall, state);
const QPoint point(ICON_HOFFSET, (height() - icon.height())/2);
painter->drawPixmap(point, icon);
}
if(!text().isNull()){
const int hOffset = ICON_HOFFSET + m_iconWidth + TEXT_HOFFSET ;
const QRect textRect(hOffset, 0, width() - hOffset - ICON_HOFFSET, height());
painter->setPen(colorGroup().buttonText());
painter->drawText(textRect, Qt::AlignLeft|Qt::AlignVCenter, text());
}
}

void CrButton::setIcon(const QString& iconName)
{
m_iconName = iconName;
Expand Down
1 change: 0 additions & 1 deletion creox/crbutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class CrButton : public QAbstractButton {
void setIntermediateState(const bool on);
virtual void paintEvent(QPaintEvent* event);
virtual void drawButton(QPainter* painter);
virtual void drawButtonLabel(QPainter* painter);

private:
QString m_iconName;
Expand Down

0 comments on commit c3d5887

Please sign in to comment.