1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

NavigationBarToolButton: Add support for inactive state

This commit is contained in:
David Rosca 2018-01-05 21:15:03 +01:00
parent 7f00b51fea
commit 74f45f6028
2 changed files with 12 additions and 3 deletions

View File

@ -29,10 +29,11 @@ NavigationBarToolButton::NavigationBarToolButton(AbstractButtonInterface *button
setFocusPolicy(Qt::NoFocus);
setToolTip(button->toolTip());
setIcon(button->icon());
updateIcon();
connect(button, &AbstractButtonInterface::iconChanged, this, &ToolButton::setIcon);
connect(button, &AbstractButtonInterface::toolTipChanged, this, &ToolButton::setToolTip);
connect(button, &AbstractButtonInterface::iconChanged, this, &NavigationBarToolButton::updateIcon);
connect(button, &AbstractButtonInterface::activeChanged, this, &NavigationBarToolButton::updateIcon);
connect(button, &AbstractButtonInterface::toolTipChanged, this, &NavigationBarToolButton::setToolTip);
connect(this, &ToolButton::clicked, this, &NavigationBarToolButton::clicked);
}
@ -53,3 +54,10 @@ void NavigationBarToolButton::clicked()
emit m_button->clicked(&c);
setDown(false);
}
void NavigationBarToolButton::updateIcon()
{
const QIcon::Mode mode = m_button->isActive() ? QIcon::Normal : QIcon::Disabled;
const QImage img = m_button->icon().pixmap(iconSize(), mode).toImage();
setIcon(QPixmap::fromImage(img, Qt::MonoOnly));
}

View File

@ -29,6 +29,7 @@ public:
private:
void clicked();
void updateIcon();
AbstractButtonInterface *m_button;
};