1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 17:28:50 -05:00
sdrangel/sdrgui/gui/buttonswitch.cpp

29 lines
833 B
C++

#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()));
}