Migrate code to Qt 5.14.2

This commit is contained in:
f4exb 2020-11-04 08:59:16 +01:00
parent 76926ab550
commit 379096cbdd
12 changed files with 41 additions and 48 deletions

View File

@ -523,8 +523,7 @@ void BFMDemodGUI::tick()
ui->channelPower->setText(QString::number(powDbAvg, 'f', 1)); ui->channelPower->setText(QString::number(powDbAvg, 'f', 1));
Real pilotPowDb = CalcDb::dbPower(m_bfmDemod->getPilotLevel()); Real pilotPowDb = CalcDb::dbPower(m_bfmDemod->getPilotLevel());
QString pilotPowDbStr; QString pilotPowDbStr = QString("%1%2").arg(pilotPowDb < 0 ? '-' : '+').arg(pilotPowDb, 3, 'f', 1, QLatin1Char('0'));
pilotPowDbStr.sprintf("%+02.1f", pilotPowDb);
ui->pilotPower->setText(pilotPowDbStr); ui->pilotPower->setText(pilotPowDbStr);
if (m_bfmDemod->getAudioSampleRate() < 0) if (m_bfmDemod->getAudioSampleRate() < 0)

View File

@ -670,19 +670,20 @@ void DATVDemodGUI::on_udpTS_clicked(bool checked)
void DATVDemodGUI::on_StreamMetaDataChanged(DataTSMetaData2 *objMetaData) void DATVDemodGUI::on_StreamMetaDataChanged(DataTSMetaData2 *objMetaData)
{ {
QString strMetaData="";
if (objMetaData != nullptr) if (objMetaData != nullptr)
{ {
QString strMetaData = "";
if (objMetaData->OK_TransportStream == true) if (objMetaData->OK_TransportStream == true)
{ {
strMetaData.sprintf("PID: %d - Width: %d - Height: %d\r\n%s%s\r\nCodec: %s\r\n", strMetaData = tr("PID: %1 - Width: %2 - Height: %3\r\n%4%5\r\nCodec: %6\r\n")
objMetaData->PID, .arg(objMetaData->PID)
objMetaData->Width, .arg(objMetaData->Width)
objMetaData->Height, .arg(objMetaData->Height)
objMetaData->Program.toStdString().c_str(), .arg(objMetaData->Program)
objMetaData->Stream.toStdString().c_str(), .arg(objMetaData->Stream)
objMetaData->CodecDescription.toStdString().c_str()); .arg(objMetaData->CodecDescription);
} }
ui->streamInfo->setText(strMetaData); ui->streamInfo->setText(strMetaData);

View File

@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // // along with this program. If not, see <http://www.gnu.org/licenses/>. //
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include "remotesourcegui.h" #include <QTime>
#include "device/deviceapi.h" #include "device/deviceapi.h"
#include "device/deviceuiset.h" #include "device/deviceuiset.h"
@ -26,6 +26,8 @@
#include "remotesource.h" #include "remotesource.h"
#include "ui_remotesourcegui.h" #include "ui_remotesourcegui.h"
#include "remotesourcegui.h"
RemoteSourceGUI* RemoteSourceGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx) RemoteSourceGUI* RemoteSourceGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx)
{ {
RemoteSourceGUI* gui = new RemoteSourceGUI(pluginAPI, deviceUISet, channelTx); RemoteSourceGUI* gui = new RemoteSourceGUI(pluginAPI, deviceUISet, channelTx);

View File

@ -18,7 +18,7 @@
#ifndef PLUGINS_CHANNELTX_REMOTESRC_REMOTESRCGUI_H_ #ifndef PLUGINS_CHANNELTX_REMOTESRC_REMOTESRCGUI_H_
#define PLUGINS_CHANNELTX_REMOTESRC_REMOTESRCGUI_H_ #define PLUGINS_CHANNELTX_REMOTESRC_REMOTESRCGUI_H_
#include <QTime> #include <QElapsedTimer>
#include "dsp/channelmarker.h" #include "dsp/channelmarker.h"
#include "channel/channelgui.h" #include "channel/channelgui.h"
@ -69,7 +69,7 @@ private:
uint32_t m_lastSampleCount; uint32_t m_lastSampleCount;
uint64_t m_lastTimestampUs; uint64_t m_lastTimestampUs;
bool m_resetCounts; bool m_resetCounts;
QTime m_time; QElapsedTimer m_time;
uint32_t m_tickCount; uint32_t m_tickCount;
explicit RemoteSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx, QWidget* parent = 0); explicit RemoteSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx, QWidget* parent = 0);

View File

@ -144,16 +144,14 @@ bool SDRPlayGui::handleMessage(const Message& message)
ui->gainMixer->setChecked(msg.getMixerGain() != 0); ui->gainMixer->setChecked(msg.getMixerGain() != 0);
ui->gainBaseband->setValue(msg.getBasebandGain()); ui->gainBaseband->setValue(msg.getBasebandGain());
QString gainText; QString gainText = QStringLiteral("%1").arg(msg.getBasebandGain(), 2, 10, QLatin1Char('0'));
gainText.sprintf("%02d", msg.getBasebandGain());
ui->gainBasebandText->setText(gainText); ui->gainBasebandText->setText(gainText);
} }
else else
{ {
ui->gainTuner->setValue(msg.getTunerGain()); ui->gainTuner->setValue(msg.getTunerGain());
QString gainText; QString gainText = QStringLiteral("%1").arg(msg.getTunerGain(), 3, 10, QLatin1Char('0'));
gainText.sprintf("%03d", msg.getTunerGain());
ui->gainTunerText->setText(gainText); ui->gainTunerText->setText(gainText);
} }
@ -241,8 +239,7 @@ void SDRPlayGui::displaySettings()
int gain = m_settings.m_tunerGain; int gain = m_settings.m_tunerGain;
ui->gainTuner->setValue(gain); ui->gainTuner->setValue(gain);
QString gainText; QString gainText = QStringLiteral("%1").arg(gain, 3, 10, QLatin1Char('0'));
gainText.sprintf("%03d", gain);
ui->gainTunerText->setText(gainText); ui->gainTunerText->setText(gainText);
m_settings.m_tunerGain = gain; m_settings.m_tunerGain = gain;
} }
@ -258,8 +255,7 @@ void SDRPlayGui::displaySettings()
int gain = m_settings.m_basebandGain; int gain = m_settings.m_basebandGain;
ui->gainBaseband->setValue(gain); ui->gainBaseband->setValue(gain);
QString gainText; QString gainText = QStringLiteral("%1").arg(gain, 2, 10, QLatin1Char('0'));
gainText.sprintf("%02d", gain);
ui->gainBasebandText->setText(gainText); ui->gainBasebandText->setText(gainText);
} }
} }
@ -393,9 +389,7 @@ void SDRPlayGui::on_gainTunerOn_toggled(bool checked)
void SDRPlayGui::on_gainTuner_valueChanged(int value) void SDRPlayGui::on_gainTuner_valueChanged(int value)
{ {
int gain = value; int gain = value;
QString gainText; QString gainText = QStringLiteral("%1").arg(gain, 3, 10, QLatin1Char('0'));
gainText.sprintf("%03d", gain);
ui->gainTunerText->setText(gainText);
m_settings.m_tunerGain = gain; m_settings.m_tunerGain = gain;
sendSettings(); sendSettings();
@ -429,8 +423,7 @@ void SDRPlayGui::on_gainBaseband_valueChanged(int value)
{ {
m_settings.m_basebandGain = value; m_settings.m_basebandGain = value;
QString gainText; QString gainText = QStringLiteral("%1").arg(value, 2, 10, QLatin1Char('0'));
gainText.sprintf("%02d", value);
ui->gainBasebandText->setText(gainText); ui->gainBasebandText->setText(gainText);
sendSettings(); sendSettings();

View File

@ -34,11 +34,11 @@ int SyncMessenger::sendWait(Message& message, unsigned long msPollTime)
{ {
m_message = &message; m_message = &message;
m_mutex.lock(); m_mutex.lock();
m_complete.store(0); m_complete.storeRelaxed(0);
emit messageSent(); emit messageSent();
while (!m_complete.load()) while (!m_complete.loadRelaxed())
{ {
m_waitCondition.wait(&m_mutex, msPollTime); m_waitCondition.wait(&m_mutex, msPollTime);
} }
@ -52,7 +52,7 @@ int SyncMessenger::sendWait(Message& message, unsigned long msPollTime)
void SyncMessenger::done(int result) void SyncMessenger::done(int result)
{ {
m_result = result; m_result = result;
m_complete.store(1); m_complete.storeRelaxed(1);
m_waitCondition.wakeAll(); m_waitCondition.wakeAll();
} }

View File

@ -619,13 +619,13 @@ int ScopeVis::processTraces(const SampleVector::const_iterator& cbegin, const Sa
// display only at trace end if trace time is less than 1 second // display only at trace end if trace time is less than 1 second
if (traceTime < 1.0f) if (traceTime < 1.0f)
{ {
if (m_glScope->getProcessingTraceIndex().load() < 0) { if (m_glScope->getProcessingTraceIndex().loadRelaxed() < 0) {
m_glScope->newTraces(m_traces.m_traces, m_traces.currentBufferIndex(), &m_traces.m_projectionTypes); m_glScope->newTraces(m_traces.m_traces, m_traces.currentBufferIndex(), &m_traces.m_projectionTypes);
} }
} }
// switch to next buffer only if it is not being processed by the scope // switch to next buffer only if it is not being processed by the scope
if (m_glScope->getProcessingTraceIndex().load() != (((int) m_traces.currentBufferIndex() + 1) % 2)) { if (m_glScope->getProcessingTraceIndex().loadRelaxed() != (((int) m_traces.currentBufferIndex() + 1) % 2)) {
m_traces.switchBuffer(); m_traces.switchBuffer();
} }

View File

@ -135,7 +135,7 @@ void GLScope::newTraces(std::vector<float *> *traces, int traceIndex, std::vecto
if (m_dataChanged.testAndSetOrdered(0, 1)) if (m_dataChanged.testAndSetOrdered(0, 1))
{ {
m_processingTraceIndex.store(traceIndex); m_processingTraceIndex.storeRelaxed(traceIndex);
m_traces = &traces[traceIndex]; m_traces = &traces[traceIndex];
m_projectionTypes = projectionTypes; m_projectionTypes = projectionTypes;
} }
@ -834,8 +834,8 @@ void GLScope::paintGL()
drawMarkers(); drawMarkers();
m_dataChanged.store(0); m_dataChanged.storeRelaxed(0);
m_processingTraceIndex.store(-1); m_processingTraceIndex.storeRelaxed(-1);
m_mutex.unlock(); m_mutex.unlock();
} }
@ -1113,7 +1113,7 @@ void GLScope::applyConfig()
void GLScope::setUniqueDisplays() void GLScope::setUniqueDisplays()
{ {
QFontMetrics fm(font()); QFontMetrics fm(font());
int M = fm.width("-"); int M = fm.horizontalAdvance("-");
int scopeHeight = height() - m_topMargin - m_botMargin; int scopeHeight = height() - m_topMargin - m_botMargin;
int scopeWidth = width() - m_leftMargin - m_rightMargin; int scopeWidth = width() - m_leftMargin - m_rightMargin;
@ -1297,7 +1297,7 @@ void GLScope::setUniqueDisplays()
void GLScope::setVerticalDisplays() void GLScope::setVerticalDisplays()
{ {
QFontMetrics fm(font()); QFontMetrics fm(font());
int M = fm.width("-"); int M = fm.horizontalAdvance("-");
int scopeHeight = (height() - m_topMargin) / 2 - m_botMargin; int scopeHeight = (height() - m_topMargin) / 2 - m_botMargin;
int scopeWidth = width() - m_leftMargin - m_rightMargin; int scopeWidth = width() - m_leftMargin - m_rightMargin;
@ -1480,7 +1480,7 @@ void GLScope::setVerticalDisplays()
void GLScope::setHorizontalDisplays() void GLScope::setHorizontalDisplays()
{ {
QFontMetrics fm(font()); QFontMetrics fm(font());
int M = fm.width("-"); int M = fm.horizontalAdvance("-");
int scopeHeight = height() - m_topMargin - m_botMargin; int scopeHeight = height() - m_topMargin - m_botMargin;
int scopeWidth = (width() - m_rightMargin) / 2 - m_leftMargin; int scopeWidth = (width() - m_rightMargin) / 2 - m_leftMargin;
@ -1662,7 +1662,7 @@ void GLScope::setHorizontalDisplays()
void GLScope::setPolarDisplays() void GLScope::setPolarDisplays()
{ {
QFontMetrics fm(font()); QFontMetrics fm(font());
int M = fm.width("-"); int M = fm.horizontalAdvance("-");
int scopeHeight = height() - m_topMargin - m_botMargin; int scopeHeight = height() - m_topMargin - m_botMargin;
int scopeWidth = (width() - m_rightMargin) / 2 - m_leftMargin; int scopeWidth = (width() - m_rightMargin) / 2 - m_leftMargin;
int scopeDim = std::min(scopeWidth, scopeHeight); int scopeDim = std::min(scopeWidth, scopeHeight);
@ -2012,7 +2012,7 @@ void GLScope::drawTextOverlay(
void GLScope::tick() void GLScope::tick()
{ {
if (m_dataChanged.load()) { if (m_dataChanged.loadRelaxed()) {
update(); update();
} }
} }

View File

@ -872,8 +872,7 @@ void GLScopeGUI::on_memoryLoad_clicked(bool checked)
void GLScopeGUI::on_mem_valueChanged(int value) void GLScopeGUI::on_mem_valueChanged(int value)
{ {
QString text; QString text = QStringLiteral("%1").arg(value, 2, 10, QLatin1Char('0'));
text.sprintf("%02d", value);
ui->memText->setText(text); ui->memText->setText(text);
disableLiveMode(value > 0); // live / memory mode toggle disableLiveMode(value > 0); // live / memory mode toggle
m_scopeVis->setMemoryIndex(value); m_scopeVis->setMemoryIndex(value);
@ -1013,8 +1012,7 @@ void GLScopeGUI::setTraceIndexDisplay()
void GLScopeGUI::setTrigCountDisplay() void GLScopeGUI::setTrigCountDisplay()
{ {
QString text; QString text = QStringLiteral("%1").arg(ui->trigCount->value(), 2, 10, QLatin1Char('0'));
text.sprintf("%02d", ui->trigCount->value());
ui->trigCountText->setText(text); ui->trigCountText->setText(text);
} }

View File

@ -1251,7 +1251,7 @@ void GLSpectrum::applyChanges()
} }
QFontMetrics fm(font()); QFontMetrics fm(font());
int M = fm.width("-"); int M = fm.horizontalAdvance("-");
m_topMargin = fm.ascent() * 1.5; m_topMargin = fm.ascent() * 1.5;
m_bottomMargin = fm.ascent() * 1.5; m_bottomMargin = fm.ascent() * 1.5;
@ -1261,7 +1261,7 @@ void GLSpectrum::applyChanges()
int frequencyScaleTop = 0; int frequencyScaleTop = 0;
int histogramTop = 0; int histogramTop = 0;
//int m_leftMargin; //int m_leftMargin;
m_rightMargin = fm.width("000"); m_rightMargin = fm.horizontalAdvance("000");
// displays both histogram and waterfall // displays both histogram and waterfall
if (m_displayWaterfall && (m_displayHistogram | m_displayMaxHold | m_displayCurrent)) if (m_displayWaterfall && (m_displayHistogram | m_displayMaxHold | m_displayCurrent))
@ -1800,7 +1800,7 @@ void GLSpectrum::applyChanges()
shift = 0; shift = 0;
} else { // right half of scale } else { // right half of scale
ftext = ftext + " "; ftext = ftext + " ";
shift = - fm.width(ftext); shift = - fm.horizontalAdvance(ftext);
} }
painter.drawText(QPointF(m_leftMargin + m_frequencyScale.getPosFromValue(xc) + shift, 2*fm.height() + fm.ascent() / 2 - 1), ftext); painter.drawText(QPointF(m_leftMargin + m_frequencyScale.getPosFromValue(xc) + shift, 2*fm.height() + fm.ascent() / 2 - 1), ftext);
} }

View File

@ -77,7 +77,7 @@ void ValueDial::setFont(const QFont &font)
QWidget::setFont(font); QWidget::setFont(font);
QFontMetrics fm(font); QFontMetrics fm(font);
m_digitWidth = fm.width('0'); m_digitWidth = fm.horizontalAdvance('0');
m_digitHeight = fm.ascent(); m_digitHeight = fm.ascent();
if (m_digitWidth < m_digitHeight) { if (m_digitWidth < m_digitHeight) {
m_digitWidth = m_digitHeight; m_digitWidth = m_digitHeight;

View File

@ -79,7 +79,7 @@ void ValueDialZ::setFont(const QFont& font)
QWidget::setFont(font); QWidget::setFont(font);
QFontMetrics fm(font); QFontMetrics fm(font);
m_digitWidth = fm.width('0'); m_digitWidth = fm.horizontalAdvance('0');
m_digitHeight = fm.ascent(); m_digitHeight = fm.ascent();
if(m_digitWidth < m_digitHeight) if(m_digitWidth < m_digitHeight)
m_digitWidth = m_digitHeight; m_digitWidth = m_digitHeight;