From 0961695faea5c8b09d5ed350ec3c96a1074141c5 Mon Sep 17 00:00:00 2001 From: Allan Bazinet Date: Sun, 20 Oct 2024 14:23:10 -0700 Subject: [PATCH] Eliminate changeFreq SIGNAL and SLOT macro usage --- mainwindow.cpp | 12 +++++------- mainwindow.h | 2 +- plotter.cpp | 11 ++++------- plotter.h | 4 ++-- widegraph.cpp | 16 ++++++++-------- widegraph.h | 3 +-- 6 files changed, 21 insertions(+), 27 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index a7e9e97b..5a0b4886 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -713,11 +713,9 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, repeatTimer.setInterval(1000); connect(&repeatTimer, &QTimer::timeout, this, &MainWindow::checkRepeat); - connect(m_wideGraph.data (), SIGNAL(setFreq3(int)), this, SLOT(setFreq4(int))); - - connect(m_wideGraph.data(), &WideGraph::qsy, this, &MainWindow::qsy); - - connect(m_wideGraph.data(), &WideGraph::drifted, this, &MainWindow::drifted); + connect(m_wideGraph.data(), &WideGraph::changeFreq, this, &MainWindow::changeFreq); + connect(m_wideGraph.data(), &WideGraph::qsy, this, &MainWindow::qsy); + connect(m_wideGraph.data(), &WideGraph::drifted, this, &MainWindow::drifted); decodeBusy(false); @@ -8032,7 +8030,7 @@ void MainWindow::drifted(int /*prev*/, int /*cur*/){ } void MainWindow::setFreqOffsetForRestore(int freq, bool shouldRestore){ - setFreq4(freq); + changeFreq(freq); if(shouldRestore){ m_shouldRestoreFreq = true; } else { @@ -8051,7 +8049,7 @@ bool MainWindow::tryRestoreFreqOffset(){ } void -MainWindow::setFreq4(int const newFreq) +MainWindow::changeFreq(int const newFreq) { // Don't allow QSY if we've already queued a transmission, // unless we have that functionality enabled. diff --git a/mainwindow.h b/mainwindow.h index b8203962..afefddb9 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -132,7 +132,7 @@ public slots: void drifted(int prev, int cur); void setFreqOffsetForRestore(int freq, bool shouldRestore); bool tryRestoreFreqOffset(); - void setFreq4(int); + void changeFreq(int); bool hasExistingMessageBufferToMe(int *pOffset); bool hasExistingMessageBuffer(int submode, int offset, bool drift, int *pPrevOffset); diff --git a/plotter.cpp b/plotter.cpp index 893d0436..9728ac00 100644 --- a/plotter.cpp +++ b/plotter.cpp @@ -624,19 +624,16 @@ CPlotter::wheelEvent(QWheelEvent * event) return; } - int const dir = delta.y() > 0 ? 1 : -1; - int newFreq = freq(); + int const dir = delta.y() > 0 ? 1 : -1; if(event->modifiers() & Qt::ControlModifier) { - newFreq += dir; + emit changeFreq(freq() + dir); } else { - newFreq = newFreq / 10 * 10 + dir * 10; + emit changeFreq(freq() / 10 * 10 + dir * 10); } - - emit setFreq1(newFreq); } void @@ -659,7 +656,7 @@ CPlotter::mouseReleaseEvent(QMouseEvent * event) auto const x = std::clamp(static_cast(event->position().x()), 0, m_w); auto const newFreq = static_cast(freqFromX(x) + 0.5); - emit setFreq1(newFreq); + emit changeFreq(newFreq); } else { diff --git a/plotter.h b/plotter.h index 19bdcf97..1473da2e 100644 --- a/plotter.h +++ b/plotter.h @@ -89,9 +89,9 @@ public: void setPercent2DScreen(int percent); void setSubMode(int nSubMode); - signals: - void setFreq1(int); + + void changeFreq(int); protected: diff --git a/widegraph.cpp b/widegraph.cpp index 5429010c..b909f0ba 100644 --- a/widegraph.cpp +++ b/widegraph.cpp @@ -132,7 +132,13 @@ WideGraph::WideGraph(QSettings * settings, menu->popup(ui->widePlot->mapToGlobal(pos)); }); - connect(ui->widePlot, SIGNAL(setFreq1(int)), this, SLOT(setFreq2(int))); + connect(ui->widePlot, + &CPlotter::changeFreq, + this, + [this](int const freq) + { + emit changeFreq(freq); + }); { @@ -516,7 +522,7 @@ WideGraph::on_offsetSpinBox_valueChanged(int const n) auto const newFreq = qMax(0, n); setFreq(newFreq); - setFreq2(newFreq); + emit changeFreq(newFreq); } void @@ -700,12 +706,6 @@ WideGraph::on_spec2dComboBox_currentIndexChanged(int const index) replot(); } -void -WideGraph::setFreq2(int const freq) -{ - emit setFreq3(freq); -} - void WideGraph::setDialFreq(double const d) { diff --git a/widegraph.h b/widegraph.h index da96e56f..901e5774 100644 --- a/widegraph.h +++ b/widegraph.h @@ -86,14 +86,13 @@ public: void setSubMode(int); signals: + void changeFreq(int); void f11f12(int n); void setXIT2(int n); - void setFreq3(int); void qsy(int); void drifted(int, int); public slots: - void setFreq2(int); void setDialFreq(double); void setTimeControlsVisible(bool); bool timeControlsVisible() const;