kopia lustrzana https://gitlab.com/eliggett/wfview
Add PTT Led and rigname to Permanent Widgets on Status Bar
rodzic
18b287a047
commit
6b795e1d6d
|
@ -0,0 +1,41 @@
|
||||||
|
#include "qledlabel.h"
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef QLEDLABEL_H
|
||||||
|
#define QLEDLABEL_H
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
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
|
22
wfmain.cpp
22
wfmain.cpp
|
@ -277,6 +277,18 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
|
||||||
ui->statusBar->addPermanentWidget(rigStatus);
|
ui->statusBar->addPermanentWidget(rigStatus);
|
||||||
ui->statusBar->showMessage("Connecting to rig...", 1000);
|
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 = new QTimer(this);
|
||||||
delayedCommand->setInterval(250); // 250ms until we find rig civ and id, then 100ms.
|
delayedCommand->setInterval(250); // 250ms until we find rig civ and id, then 100ms.
|
||||||
delayedCommand->setSingleShot(true);
|
delayedCommand->setSingleShot(true);
|
||||||
|
@ -1065,7 +1077,7 @@ void wfmain::prepareWf()
|
||||||
spectRowCurrent = 0;
|
spectRowCurrent = 0;
|
||||||
wf->yAxis->setRangeReversed(true);
|
wf->yAxis->setRangeReversed(true);
|
||||||
wf->xAxis->setVisible(false);
|
wf->xAxis->setVisible(false);
|
||||||
|
rigName->setText(rigCaps.modelName);
|
||||||
} else {
|
} else {
|
||||||
qDebug(logSystem()) << "Cannot prepare WF view without rigCaps. Waiting on this.";
|
qDebug(logSystem()) << "Cannot prepare WF view without rigCaps. Waiting on this.";
|
||||||
return;
|
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:
|
// This is the only place where amTransmitting and the transmit button text should be changed:
|
||||||
qDebug(logSystem()) << "PTT status: " << pttOn;
|
qDebug(logSystem()) << "PTT status: " << pttOn;
|
||||||
|
if (pttOn && !amTransmitting)
|
||||||
|
{
|
||||||
|
pttLed->setState(QLedLabel::State::StateError);
|
||||||
|
}
|
||||||
|
else if (!pttOn && amTransmitting)
|
||||||
|
{
|
||||||
|
pttLed->setState(QLedLabel::State::StateOk);
|
||||||
|
}
|
||||||
amTransmitting = pttOn;
|
amTransmitting = pttOn;
|
||||||
changeTxBtn();
|
changeTxBtn();
|
||||||
}
|
}
|
||||||
|
|
4
wfmain.h
4
wfmain.h
|
@ -20,6 +20,7 @@
|
||||||
#include "satellitesetup.h"
|
#include "satellitesetup.h"
|
||||||
#include "udpserversetup.h"
|
#include "udpserversetup.h"
|
||||||
#include "udpserver.h"
|
#include "udpserver.h"
|
||||||
|
#include "qledlabel.h"
|
||||||
|
|
||||||
#include <qcustomplot.h>
|
#include <qcustomplot.h>
|
||||||
#include <qserialportinfo.h>
|
#include <qserialportinfo.h>
|
||||||
|
@ -448,6 +449,9 @@ private:
|
||||||
QStringList edges;
|
QStringList edges;
|
||||||
QStringList commPorts;
|
QStringList commPorts;
|
||||||
QLabel* rigStatus;
|
QLabel* rigStatus;
|
||||||
|
QLabel* rigName;
|
||||||
|
QLedLabel* pttLed;
|
||||||
|
QLedLabel* connectedLed;
|
||||||
|
|
||||||
quint16 spectWidth;
|
quint16 spectWidth;
|
||||||
quint16 wfLength;
|
quint16 wfLength;
|
||||||
|
|
|
@ -86,7 +86,8 @@ SOURCES += main.cpp\
|
||||||
satellitesetup.cpp \
|
satellitesetup.cpp \
|
||||||
udpserversetup.cpp \
|
udpserversetup.cpp \
|
||||||
udpserver.cpp \
|
udpserver.cpp \
|
||||||
meter.cpp
|
meter.cpp \
|
||||||
|
qledlabel.cpp
|
||||||
|
|
||||||
HEADERS += wfmain.h \
|
HEADERS += wfmain.h \
|
||||||
commhandler.h \
|
commhandler.h \
|
||||||
|
@ -101,7 +102,8 @@ HEADERS += wfmain.h \
|
||||||
udpserversetup.h \
|
udpserversetup.h \
|
||||||
udpserver.h \
|
udpserver.h \
|
||||||
packettypes.h \
|
packettypes.h \
|
||||||
meter.h
|
meter.h \
|
||||||
|
qledlabel.h
|
||||||
|
|
||||||
|
|
||||||
FORMS += wfmain.ui \
|
FORMS += wfmain.ui \
|
||||||
|
|
Ładowanie…
Reference in New Issue