SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
buttonswitch.cpp
Go to the documentation of this file.
1 #include <QPainter>
2 #include "gui/buttonswitch.h"
3 
4 ButtonSwitch::ButtonSwitch(QWidget* parent) :
5  QToolButton(parent)
6 {
7  setCheckable(true);
8  m_originalPalette = palette();
9  connect(this, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool)));
10 }
11 
12 void ButtonSwitch::onToggled(bool checked)
13 {
14  if(checked) {
15  QPalette p = m_originalPalette;
16  p.setColor(QPalette::Button, QColor(0x80, 0x46, 0x00));
17  setPalette(p);
18  } else {
19  setPalette(m_originalPalette);
20  }
21 }
22 
23 void ButtonSwitch::doToggle(bool checked)
24 {
25  onToggled(checked);
26 }
QPalette m_originalPalette
Definition: buttonswitch.h:19
void onToggled(bool checked)
ButtonSwitch(QWidget *parent=NULL)
Definition: buttonswitch.cpp:4
void doToggle(bool checked)