mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-22 04:11:16 -05:00
3dd824ad6b
The Rx meter is now a better Qt citizen and can be resized. Added a more obvious peak signal indicator. It is now a custom widget derived from QFrame and is now directly added via promotion in Designer. Added a custom widget to act as a letter spin box, this is used for sub mode control. Switched the frequency tolerance widget to a combo box with preset values so that it is more uniform across systems and font sizes. Added container widgets for group control of various UI widgets such as QSO controls, DX call controls and WSPR controls. Introduced a stacked widget to allow the WSPR controls to be swapped in in place of the "QSO" controls. The "QSO" controls are are the Rx, Tx and related controls along with the main tab widget with the message buttons and fields. This means that the WSPR version of the main window (and EME Echo mode) are now much cleaner. Increased the size of the rig control widget and styled its colour using a dynamic property so that it can be defined in the Designer UI definition. Reinstated it as a push button to do a rig control reset and retry after an error. Reset most UI widgets to default properties, particularly removing any fixed sizes so that they can resize freely when fonts are changed. The overall layout is now controlled almost exclusively by stretch factors on some of the rows and columns of the various grid layout managers. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5630 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
70 lines
1.5 KiB
C++
70 lines
1.5 KiB
C++
// Simple bargraph meter
|
|
// Implemented by Edson Pereira PY2SDR
|
|
|
|
#include "meterwidget.h"
|
|
|
|
#include <QPainter>
|
|
#include <QPolygon>
|
|
|
|
#include "moc_meterwidget.cpp"
|
|
|
|
MeterWidget::MeterWidget(QWidget * parent)
|
|
: QWidget {parent}
|
|
, m_top_padding {0}
|
|
, m_bottom_padding {0}
|
|
, m_signal {0}
|
|
{
|
|
for ( int i = 0; i < 10; i++ ) {
|
|
signalQueue.enqueue(0);
|
|
}
|
|
}
|
|
|
|
void MeterWidget::setValue(int value)
|
|
{
|
|
m_signal = value;
|
|
signalQueue.enqueue(value);
|
|
signalQueue.dequeue();
|
|
|
|
// Get signal peak
|
|
int tmp = 0;
|
|
for (int i = 0; i < signalQueue.size(); ++i) {
|
|
if (signalQueue.at(i) > tmp)
|
|
tmp = signalQueue.at(i);
|
|
}
|
|
m_sigPeak = tmp;
|
|
|
|
update();
|
|
}
|
|
|
|
QSize MeterWidget::sizeHint () const
|
|
{
|
|
return {10, 100};
|
|
}
|
|
|
|
void MeterWidget::paintEvent (QPaintEvent * event)
|
|
{
|
|
QWidget::paintEvent (event);
|
|
|
|
// Sanitize
|
|
m_signal = m_signal < 0 ? 0 : m_signal;
|
|
m_signal = m_signal > 60 ? 60 : m_signal;
|
|
|
|
QPainter p {this};
|
|
p.setPen (Qt::NoPen);
|
|
|
|
auto const& target = contentsRect ();
|
|
QRect r {QPoint {target.left (), static_cast<int> (target.top () + target.height () - m_signal / 60. * target.height ())}
|
|
, QPoint {target.right (), target.bottom ()}};
|
|
p.setBrush (QColor {255, 150, 0});
|
|
p.drawRect (r);
|
|
|
|
if (m_sigPeak)
|
|
{
|
|
// Draw peak hold indicator
|
|
auto peak = static_cast<int> (target.top () + target.height () - m_sigPeak / 60. * target.height ());
|
|
p.setBrush (Qt::black);
|
|
p.translate (target.left (), peak);
|
|
p.drawPolygon (QPolygon {{{0, -4}, {0, 4}, {target.width (), 0}}});
|
|
}
|
|
}
|