1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-12 19:36:10 -05:00

Button switch: added methods to set color and reset to default button colors

This commit is contained in:
f4exb 2020-08-02 00:59:42 +02:00
parent fa554d8244
commit b747966c8e
2 changed files with 24 additions and 0 deletions

View File

@ -31,3 +31,25 @@ void ButtonSwitch::doToggle(bool checked)
{
onToggled(checked);
}
void ButtonSwitch::setColor(QColor color)
{
QPalette p = m_originalPalette;
p.setColor(QPalette::Button, color);
setPalette(p);
}
void ButtonSwitch::resetColor()
{
if (isChecked())
{
QPalette p = m_originalPalette;
p.setColor(QPalette::Button, QColor(0x80, 0x46, 0x00));
setPalette(p);
}
else
{
setPalette(m_originalPalette);
}
}

View File

@ -11,6 +11,8 @@ class SDRGUI_API ButtonSwitch : public QToolButton {
public:
ButtonSwitch(QWidget* parent = NULL);
void doToggle(bool checked);
void setColor(QColor color);
void resetColor();
private slots:
void onToggled(bool checked);