From 8833b56d91c3d625ccc57c6629cb3f2e49268901 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Wed, 3 Jun 2020 17:43:27 +0100 Subject: [PATCH] Fix issue with 2D spectrum selection in translated UIs For completeness this fixes the other occurrence of widget signals with text arguments that are liable to misbehaviour with translated UIs. --- widgets/mainwindow.cpp | 8 ++++---- widgets/mainwindow.h | 2 +- widgets/widegraph.cpp | 28 +++++++++++++++++----------- widgets/widegraph.h | 2 +- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp index 37dad9ebc..0e5fd551a 100644 --- a/widgets/mainwindow.cpp +++ b/widgets/mainwindow.cpp @@ -812,7 +812,8 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, char const * const power[] = {"1 mW","2 mW","5 mW","10 mW","20 mW","50 mW","100 mW","200 mW","500 mW", "1 W","2 W","5 W","10 W","20 W","50 W","100 W","200 W","500 W","1 kW"}; for(auto i = 0u; i < sizeof power / sizeof power[0]; ++i) { //Initialize dBm values - ui->TxPowerComboBox->addItem (QString {"%1 dBm %2"}.arg (int ((10. * i / 3.) + .5)).arg (power[i])); + auto dBm = int ((10. * i / 3.) + .5); + ui->TxPowerComboBox->addItem (QString {"%1 dBm %2"}.arg (dBm).arg (power[i]), dBm); } m_dateTimeRcvdRR73=QDateTime::currentDateTimeUtc(); @@ -7781,10 +7782,9 @@ void MainWindow::uploadResponse(QString response) } } -void MainWindow::on_TxPowerComboBox_currentIndexChanged(const QString &arg1) +void MainWindow::on_TxPowerComboBox_currentIndexChanged(int index) { - int i1=arg1.indexOf(" "); - m_dBm=arg1.mid(0,i1).toInt(); + m_dBm = ui->TxPowerComboBox->itemData (index).toInt (); } void MainWindow::on_sbTxPercent_valueChanged(int n) diff --git a/widgets/mainwindow.h b/widgets/mainwindow.h index 969993098..82f879fcd 100644 --- a/widgets/mainwindow.h +++ b/widgets/mainwindow.h @@ -276,7 +276,7 @@ private slots: void on_actionWSPR_triggered(); void on_actionWSPR_LF_triggered(); void on_syncSpinBox_valueChanged(int n); - void on_TxPowerComboBox_currentIndexChanged(const QString &arg1); + void on_TxPowerComboBox_currentIndexChanged(int); void on_sbTxPercent_valueChanged(int n); void on_cbUploadWSPR_Spots_toggled(bool b); void WSPR_config(bool b); diff --git a/widgets/widegraph.cpp b/widgets/widegraph.cpp index 6234f731a..a78874c79 100644 --- a/widgets/widegraph.cpp +++ b/widgets/widegraph.cpp @@ -315,23 +315,29 @@ void WideGraph::setModeTx(QString modeTx) //setModeTx ui->widePlot->update(); } - //Current-Cumulative-Yellow -void WideGraph::on_spec2dComboBox_currentIndexChanged(const QString &arg1) +void WideGraph::on_spec2dComboBox_currentIndexChanged(int index) { ui->widePlot->setCurrent(false); ui->widePlot->setCumulative(false); ui->widePlot->setLinearAvg(false); ui->widePlot->setReference(false); ui->smoSpinBox->setEnabled(false); - if(arg1=="Current") ui->widePlot->setCurrent(true); - if(arg1=="Cumulative") ui->widePlot->setCumulative(true); - if(arg1=="Linear Avg") { - ui->widePlot->setLinearAvg(true); - ui->smoSpinBox->setEnabled(true); - } - if(arg1=="Reference") { - ui->widePlot->setReference(true); - } + switch (index) + { + case 0: // Current + ui->widePlot->setCurrent(true); + break; + case 1: // Cumulative + ui->widePlot->setCumulative(true); + break; + case 2: // Linear Avg + ui->widePlot->setLinearAvg(true); + ui->smoSpinBox->setEnabled(true); + break; + case 3: // Reference + ui->widePlot->setReference(true); + break; + } replot(); } diff --git a/widgets/widegraph.h b/widgets/widegraph.h index c87bab050..90f7b51aa 100644 --- a/widgets/widegraph.h +++ b/widgets/widegraph.h @@ -68,7 +68,7 @@ protected: private slots: void on_waterfallAvgSpinBox_valueChanged(int arg1); void on_bppSpinBox_valueChanged(int arg1); - void on_spec2dComboBox_currentIndexChanged(const QString &arg1); + void on_spec2dComboBox_currentIndexChanged(int); void on_fSplitSpinBox_valueChanged(int n); void on_fStartSpinBox_valueChanged(int n); void on_paletteComboBox_activated(const QString &palette);