35 : QGraphicsView(parent)
37 setMinimumSize(200, parent->height());
38 setMaximumSize(200, parent->height());
39 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
40 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
41 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
42 setAlignment(Qt::AlignCenter);
43 setFrameStyle(QFrame::NoFrame);
44 setStyleSheet(
"QGraphicsView{background:transparent;}");
46 setAttribute(Qt::WA_TranslucentBackground);
47 setWindowFlags(Qt::FramelessWindowHint);
50 QGraphicsScene *scene =
new QGraphicsScene(0, 0, 1240, 144,
this);
52 renderer =
new QSvgRenderer();
53 if (renderer->load(QString(
":/core/images/tx-rx.svg"))) {
54 graph =
new QGraphicsSvgItem();
55 graph->setSharedRenderer(renderer);
56 graph->setElementId(
"txrxBackground");
66 name = QString(
"tx%0").arg(
i);
67 if (renderer->elementExists(name)) {
69 pt =
new QGraphicsSvgItem();
70 pt->setSharedRenderer(renderer);
71 pt->setElementId(name);
72 pt->setParentItem(graph);
73 orig = renderer->boundsOnElement(name);
74 Matrix = renderer->matrixForElement(name);
75 orig = Matrix.mapRect(orig);
76 trans.translate(orig.x(), orig.y());
77 pt->setTransform(trans,
false);
81 name = QString(
"rx%0").arg(
i);
82 if (renderer->elementExists(name)) {
84 pt =
new QGraphicsSvgItem();
85 pt->setSharedRenderer(renderer);
86 pt->setElementId(name);
87 pt->setParentItem(graph);
88 orig = renderer->boundsOnElement(name);
89 Matrix = renderer->matrixForElement(name);
90 orig = Matrix.mapRect(orig);
91 trans.translate(orig.x(), orig.y());
92 pt->setTransform(trans,
false);
96 scene->addItem(graph);
97 txSpeed =
new QGraphicsTextItem();
98 txSpeed->setDefaultTextColor(Qt::white);
99 txSpeed->setFont(QFont(
"Helvetica", 30, 2));
100 txSpeed->setParentItem(graph);
101 orig = renderer->boundsOnElement(
"txPH");
102 Matrix = renderer->matrixForElement(
"txPH");
103 orig = Matrix.mapRect(orig);
105 trans.translate(orig.x(), orig.y() - 8);
106 txSpeed->setTransform(trans,
false);
107 rxSpeed =
new QGraphicsTextItem();
108 rxSpeed->setDefaultTextColor(Qt::white);
109 rxSpeed->setFont(QFont(
"Helvetica", 30, 2));
110 rxSpeed->setParentItem(graph);
112 orig = renderer->boundsOnElement(
"rxPH");
113 Matrix = renderer->matrixForElement(
"rxPH");
114 orig = Matrix.mapRect(orig);
115 trans.translate(orig.x(), orig.y() - 8);
116 rxSpeed->setTransform(trans,
false);
118 scene->setSceneRect(graph->boundingRect());
135 while (!txNodes.isEmpty())
136 delete txNodes.takeFirst();
138 while (!rxNodes.isEmpty())
139 delete rxNodes.takeFirst();
176 txIndex = (txValue - minValue) / (maxValue - minValue) *
NODE_NUMELEM;
177 rxIndex = (rxValue - minValue) / (maxValue - minValue) *
NODE_NUMELEM;
180 this->setToolTip(QString(
"Tx: %0 bytes/sec\nRx: %1 bytes/sec")
181 .arg(txValue, 0,
'f', 0)
182 .arg(rxValue, 0,
'f', 0));
184 this->setToolTip(QString(
"Disconnected"));
189 for (i = 0; i < txNodes.count(); i++) {
190 node = txNodes.at(i);
191 node->setVisible(m_connected && i < txIndex);
195 for (i = 0; i < rxNodes.count(); i++) {
196 node = rxNodes.at(i);
197 node->setVisible(m_connected && i < rxIndex);
201 txSpeed->setPlainText(QString::number(txValue,
'f', 0));
202 txSpeed->setVisible(m_connected);
204 rxSpeed->setPlainText(QString::number(rxValue,
'f', 0));
205 rxSpeed->setVisible(m_connected);
214 fitInView(graph, Qt::KeepAspectRatio);
221 fitInView(graph, Qt::KeepAspectRatio);
TelemetryMonitorWidget(QWidget *parent=nullptr)
static const int NODE_NUMELEM
void resizeEvent(QResizeEvent *event)
void showEvent(QShowEvent *event)
void updateTelemetry(double txRate, double rxRate)
Called by the UAVObject which got updated Updates the numeric value and/or the icon if the dial wants...
~TelemetryMonitorWidget()