mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
NavigationBarToolButton: Add support for inactive state
This commit is contained in:
parent
7f00b51fea
commit
74f45f6028
@ -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));
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ public:
|
||||
|
||||
private:
|
||||
void clicked();
|
||||
void updateIcon();
|
||||
|
||||
AbstractButtonInterface *m_button;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user