diff --git a/qledlabel.cpp b/qledlabel.cpp new file mode 100644 index 0000000..2a13395 --- /dev/null +++ b/qledlabel.cpp @@ -0,0 +1,41 @@ +#include "qledlabel.h" +#include + +static const int SIZE = 16; +static const QString greenSS = QString("color: white;border-radius: %1;background-color: qlineargradient(spread:pad, x1:0.145, y1:0.16, x2:1, y2:1, stop:0 rgba(20, 252, 7, 255), stop:1 rgba(25, 134, 5, 255));").arg(SIZE / 2); +static const QString redSS = QString("color: white;border-radius: %1;background-color: qlineargradient(spread:pad, x1:0.145, y1:0.16, x2:0.92, y2:0.988636, stop:0 rgba(255, 12, 12, 255), stop:0.869347 rgba(103, 0, 0, 255));").arg(SIZE / 2); +static const QString orangeSS = QString("color: white;border-radius: %1;background-color: qlineargradient(spread:pad, x1:0.232, y1:0.272, x2:0.98, y2:0.959773, stop:0 rgba(255, 113, 4, 255), stop:1 rgba(91, 41, 7, 255))").arg(SIZE / 2); +static const QString blueSS = QString("color: white;border-radius: %1;background-color: qlineargradient(spread:pad, x1:0.04, y1:0.0565909, x2:0.799, y2:0.795, stop:0 rgba(203, 220, 255, 255), stop:0.41206 rgba(0, 115, 255, 255), stop:1 rgba(0, 49, 109, 255));").arg(SIZE / 2); + +QLedLabel::QLedLabel(QWidget* parent) : + QLabel(parent) +{ + //Set to ok by default + setState(StateOkBlue); + setFixedSize(SIZE, SIZE); +} + +void QLedLabel::setState(State state) +{ + qDebug() << "setState" << state; + switch (state) { + case StateOk: + setStyleSheet(greenSS); + break; + case StateWarning: + setStyleSheet(orangeSS); + break; + case StateError: + setStyleSheet(redSS); + break; + case StateOkBlue: + default: + setStyleSheet(blueSS); + break; + } +} + +void QLedLabel::setState(bool state) +{ + setState(state ? StateOk : StateError); +} \ No newline at end of file diff --git a/qledlabel.h b/qledlabel.h new file mode 100644 index 0000000..b5dc706 --- /dev/null +++ b/qledlabel.h @@ -0,0 +1,27 @@ +#ifndef QLEDLABEL_H +#define QLEDLABEL_H + +#include + +class QLedLabel : public QLabel +{ + Q_OBJECT +public: + explicit QLedLabel(QWidget* parent = 0); + + enum State { + StateOk, + StateOkBlue, + StateWarning, + StateError + }; + + +signals: + +public slots: + void setState(State state); + void setState(bool state); +}; + +#endif // QLEDLABEL_H diff --git a/wfmain.cpp b/wfmain.cpp index a452f8c..f6b73b6 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -277,6 +277,18 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent ui->statusBar->addPermanentWidget(rigStatus); ui->statusBar->showMessage("Connecting to rig...", 1000); + pttLed = new QLedLabel(this); + ui->statusBar->addPermanentWidget(pttLed); + pttLed->setState(QLedLabel::State::StateOk); + + connectedLed = new QLedLabel(this); + ui->statusBar->addPermanentWidget(connectedLed); + + rigName = new QLabel(this); + ui->statusBar->addPermanentWidget(rigName); + rigName->setText("NONE"); + rigName->setFixedWidth(40); + delayedCommand = new QTimer(this); delayedCommand->setInterval(250); // 250ms until we find rig civ and id, then 100ms. delayedCommand->setSingleShot(true); @@ -1065,7 +1077,7 @@ void wfmain::prepareWf() spectRowCurrent = 0; wf->yAxis->setRangeReversed(true); wf->xAxis->setVisible(false); - + rigName->setText(rigCaps.modelName); } else { qDebug(logSystem()) << "Cannot prepare WF view without rigCaps. Waiting on this."; return; @@ -1891,6 +1903,14 @@ void wfmain::receivePTTstatus(bool pttOn) { // This is the only place where amTransmitting and the transmit button text should be changed: qDebug(logSystem()) << "PTT status: " << pttOn; + if (pttOn && !amTransmitting) + { + pttLed->setState(QLedLabel::State::StateError); + } + else if (!pttOn && amTransmitting) + { + pttLed->setState(QLedLabel::State::StateOk); + } amTransmitting = pttOn; changeTxBtn(); } diff --git a/wfmain.h b/wfmain.h index 7b94268..f4963de 100644 --- a/wfmain.h +++ b/wfmain.h @@ -20,6 +20,7 @@ #include "satellitesetup.h" #include "udpserversetup.h" #include "udpserver.h" +#include "qledlabel.h" #include #include @@ -448,6 +449,9 @@ private: QStringList edges; QStringList commPorts; QLabel* rigStatus; + QLabel* rigName; + QLedLabel* pttLed; + QLedLabel* connectedLed; quint16 spectWidth; quint16 wfLength; diff --git a/wfview.pro b/wfview.pro index b4e71fe..b0c1ce6 100644 --- a/wfview.pro +++ b/wfview.pro @@ -86,7 +86,8 @@ SOURCES += main.cpp\ satellitesetup.cpp \ udpserversetup.cpp \ udpserver.cpp \ - meter.cpp + meter.cpp \ + qledlabel.cpp HEADERS += wfmain.h \ commhandler.h \ @@ -101,7 +102,8 @@ HEADERS += wfmain.h \ udpserversetup.h \ udpserver.h \ packettypes.h \ - meter.h + meter.h \ + qledlabel.h FORMS += wfmain.ui \