2014-05-18 11:52:39 -04:00
|
|
|
#include <QPainter>
|
|
|
|
#include "gui/buttonswitch.h"
|
|
|
|
|
|
|
|
ButtonSwitch::ButtonSwitch(QWidget* parent) :
|
|
|
|
QToolButton(parent)
|
|
|
|
{
|
|
|
|
setCheckable(true);
|
2022-05-19 11:51:51 -04:00
|
|
|
setStyleSheet(QString("QToolButton{ background-color: %1; } QToolButton:checked{ background-color: %2; }")
|
|
|
|
.arg(palette().button().color().name())
|
|
|
|
.arg(palette().highlight().color().darker(150).name()));
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
2017-02-09 22:35:08 -05:00
|
|
|
|
|
|
|
void ButtonSwitch::doToggle(bool checked)
|
|
|
|
{
|
2022-05-19 11:51:51 -04:00
|
|
|
setChecked(checked);
|
2017-02-09 22:35:08 -05:00
|
|
|
}
|
2020-08-01 18:59:42 -04:00
|
|
|
|
|
|
|
void ButtonSwitch::setColor(QColor color)
|
|
|
|
{
|
2022-05-19 11:51:51 -04:00
|
|
|
setStyleSheet(QString("QToolButton{ background-color: %1; }").arg(color.name()));
|
2020-08-01 18:59:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ButtonSwitch::resetColor()
|
|
|
|
{
|
2022-05-19 11:51:51 -04:00
|
|
|
setStyleSheet(QString("QToolButton{ background-color: %1; } QToolButton:checked{ background-color: %2; }")
|
|
|
|
.arg(palette().button().color().name())
|
|
|
|
.arg(palette().highlight().color().darker(150).name()));
|
2020-08-01 18:59:42 -04:00
|
|
|
}
|