2014-05-18 11:52:39 -04:00
|
|
|
#include <QPainter>
|
|
|
|
#include "gui/buttonswitch.h"
|
|
|
|
|
|
|
|
ButtonSwitch::ButtonSwitch(QWidget* parent) :
|
|
|
|
QToolButton(parent)
|
|
|
|
{
|
|
|
|
setCheckable(true);
|
|
|
|
m_originalPalette = palette();
|
|
|
|
connect(this, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ButtonSwitch::onToggled(bool checked)
|
|
|
|
{
|
2020-07-09 18:06:55 -04:00
|
|
|
blockSignals(true);
|
|
|
|
setChecked(checked);
|
|
|
|
blockSignals(false);
|
|
|
|
|
|
|
|
if (checked)
|
|
|
|
{
|
2014-05-18 11:52:39 -04:00
|
|
|
QPalette p = m_originalPalette;
|
|
|
|
p.setColor(QPalette::Button, QColor(0x80, 0x46, 0x00));
|
|
|
|
setPalette(p);
|
2020-07-09 18:06:55 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-05-18 11:52:39 -04:00
|
|
|
setPalette(m_originalPalette);
|
|
|
|
}
|
|
|
|
}
|
2017-02-09 22:35:08 -05:00
|
|
|
|
|
|
|
void ButtonSwitch::doToggle(bool checked)
|
|
|
|
{
|
|
|
|
onToggled(checked);
|
|
|
|
}
|