1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-18 14:21:49 -05:00
sdrangel/sdrgui/gui/buttonswitch.cpp

29 lines
833 B
C++
Raw Normal View History

#include <QPainter>
#include "gui/buttonswitch.h"
ButtonSwitch::ButtonSwitch(QWidget* parent) :
QToolButton(parent)
{
setCheckable(true);
setStyleSheet(QString("QToolButton{ background-color: %1; } QToolButton:checked{ background-color: %2; }")
.arg(palette().button().color().name())
.arg(palette().highlight().color().darker(150).name()));
}
void ButtonSwitch::doToggle(bool checked)
{
setChecked(checked);
}
void ButtonSwitch::setColor(QColor color)
{
setStyleSheet(QString("QToolButton{ background-color: %1; }").arg(color.name()));
}
void ButtonSwitch::resetColor()
{
setStyleSheet(QString("QToolButton{ background-color: %1; } QToolButton:checked{ background-color: %2; }")
.arg(palette().button().color().name())
.arg(palette().highlight().color().darker(150).name()));
}