/*************************************************************************** cledbutton.cpp - description ------------------- begin : Sun Jan 14 2001 copyright : (C) 2001 by Volker Schroer email : DL1KSV@gmx.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #include "cledbutton.h" #include CLedButton::CLedButton(QWidget *parent, const char *name ) : QPushButton(parent,name) { status=UNDEF; setText("RX"); connect(this,SIGNAL ( clicked() ),this,SLOT(rxtx())); } CLedButton::~CLedButton(){ } /** paint the button and the led in it */ void CLedButton::paintEvent(QPaintEvent *) { QPainter paint(this); drawButton(&paint); switch (status) { case ON: paint.setPen(black); paint.setBrush(red); paint.drawEllipse(4,4,14,14); break; case OFF: paint.setPen(black); paint.setBrush(green); paint.drawEllipse(4,4,14,14); break; case UNDEF: break; } } /** sets the buttonstatus */ void CLedButton::setStatus(BUTTONSTATUS state) { status=state; switch(status) { case UNDEF: case ON: setText("RX"); break; case OFF: setText("TX"); break; } repaint(); } /** No descriptions */ void CLedButton::rxtx() { switch(status) { case UNDEF: case ON: // setStatus(OFF); emit startRx(); break; case OFF: // setStatus(ON); emit startTx(); break; } } BUTTONSTATUS CLedButton::getstatus() { return status; }