From 87381328360d69defc6f851fe3f774c7dc10effd Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Mon, 21 Jan 2019 17:45:52 -0500 Subject: [PATCH] Added a new, more obvious frequency control and a menu item for setting the frequency --- keyeater.cpp | 15 +++++++++++++++ keyeater.h | 18 +++++++++++++++++ mainwindow.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ mainwindow.h | 1 + mainwindow.ui | 51 +++++++++++++++++++++++++++++++++++++++++++++++-- 5 files changed, 135 insertions(+), 2 deletions(-) diff --git a/keyeater.cpp b/keyeater.cpp index c7aefcc..3a37242 100644 --- a/keyeater.cpp +++ b/keyeater.cpp @@ -27,3 +27,18 @@ bool EnterKeyPressEater::eventFilter(QObject *obj, QEvent *event){ // standard event processing return QObject::eventFilter(obj, event); } + +bool MousePressEater::eventFilter(QObject *obj, QEvent *event){ + if (event->type() == QEvent::MouseButtonPress) { + QMouseEvent *mouseEvent = static_cast(event); + bool processed = false; + emit this->mousePressed(obj, mouseEvent, &processed); + if(processed){ + return true; + } + } + + // standard event processing + return QObject::eventFilter(obj, event); +} + diff --git a/keyeater.h b/keyeater.h index 9f96d79..88719ae 100644 --- a/keyeater.h +++ b/keyeater.h @@ -3,6 +3,7 @@ #include #include +#include class EscapeKeyPressEater : public QObject { @@ -29,5 +30,22 @@ public: Q_SIGNAL void enterKeyPressed(QObject *obj, QKeyEvent *evt, bool *pProcessed); }; +class MousePressEater : public QObject +{ + Q_OBJECT +public: + MousePressEater(){} + virtual ~MousePressEater(){} + +protected: + bool eventFilter(QObject *obj, QEvent *event); + +public: + Q_SIGNAL void mousePressed(QObject *obj, QMouseEvent *evt, bool *pProcessed); +}; + + + + #endif // KEYEATER_H diff --git a/mainwindow.cpp b/mainwindow.cpp index 172132b..83f5586 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -791,6 +791,18 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, }); // Hook up working frequencies. + ui->currentFreq->setCursor(QCursor(Qt::PointingHandCursor)); + ui->currentFreq->display("14.078 000"); + auto mp = new MousePressEater(); + connect(mp, &MousePressEater::mousePressed, this, [this](QObject *, QMouseEvent * e, bool *pProcessed){ + QMenu * menu = new QMenu(ui->currentFreq); + buildFrequencyMenu(menu); + menu->popup(e->globalPos()); + if(pProcessed) *pProcessed = true; + }); + ui->currentFreq->installEventFilter(mp); + + ui->bandComboBox->setVisible(false); ui->bandComboBox->setModel (m_config.frequencies ()); ui->bandComboBox->setModelColumn (FrequencyList_v2::frequency_mhz_column); @@ -2409,6 +2421,13 @@ void rebuildMacQAction(QMenu *menu, QAction *existingAction){ } void MainWindow::on_menuControl_aboutToShow(){ + QMenu * freqMenu = new QMenu(this->menuBar()); + buildFrequencyMenu(freqMenu); + ui->actionSetFrequency->setMenu(freqMenu); +#if __APPLE__ + rebuildMacQAction(ui->menuControl, ui->actionSetFrequency); +#endif + ui->actionEnable_Spotting->setChecked(ui->spotButton->isChecked()); ui->actionEnable_Auto_Reply->setChecked(ui->autoReplyButton->isChecked()); @@ -2924,6 +2943,10 @@ void MainWindow::displayDialFrequency (){ update_dynamic_property (ui->labDialFreq, "oob", !valid); ui->labDialFreq->setText (Radio::pretty_frequency_MHz_string (dial_frequency)); + auto sFreq = Radio::pretty_frequency_MHz_string (dial_frequency); + ui->currentFreq->setDigitCount(sFreq.length()); + ui->currentFreq->display(sFreq); + if(m_splitMode && m_transmitting){ audio_frequency -= m_XIT; } @@ -6775,6 +6798,35 @@ void MainWindow::on_clearAction_triggered(QObject * sender){ } } +void MainWindow::buildFrequencyMenu(QMenu *menu){ + auto custom = menu->addAction("Set a Custom Frequency..."); + + connect(custom, &QAction::triggered, this, [this](){ + bool ok = false; + auto currentFreq = Radio::frequency_MHz_string(dialFrequency()); + QString newFreq = QInputDialog::getText(this, tr("Set a Custom Frequency..."), + tr("Frequency in MHz:"), QLineEdit::Normal, + currentFreq, &ok).toUpper().trimmed(); + if(!ok){ + return; + } + + setRig(Radio::frequency(newFreq, 6)); + }); + + menu->addSeparator(); + + foreach(auto f, m_config.frequencies()->frequency_list()){ + auto freq = Radio::pretty_frequency_MHz_string(f.frequency_); + auto const& band = m_config.bands ()->find (f.frequency_); + + auto a = menu->addAction(QString("(%1)%2%2%3 MHz").arg(band).arg(QString(" ").repeated(6-band.length())).arg(freq)); + connect(a, &QAction::triggered, this, [this, f](){ + setRig(f.frequency_); + }); + } +} + void MainWindow::buildHeartbeatMenu(QMenu *menu){ buildRepeatMenu(menu, ui->hbMacroButton, &m_hbInterval); diff --git a/mainwindow.h b/mainwindow.h index 5c9f422..2a6a251 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -277,6 +277,7 @@ private slots: void on_rbGenMsg_clicked(bool checked); void on_rbFreeText_clicked(bool checked); void on_clearAction_triggered(QObject * sender); + void buildFrequencyMenu(QMenu *menu); void buildHeartbeatMenu(QMenu *menu); void buildCQMenu(QMenu *menu); void buildRepeatMenu(QMenu *menu, QPushButton * button, int * interval); diff --git a/mainwindow.ui b/mainwindow.ui index a0ca34c..ee4525c 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -194,6 +194,40 @@ + + + + + 200 + 40 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 0 + + + false + + + 10 + + + QLCDNumber::Flat + + + 1234567890.000000000000000 + + + 1234567890 + + + @@ -203,7 +237,7 @@ - true + false <html><head/><body><p>Select operating band or enter frequency in MHz or enter kHz increment followed by k.</p></body></html> @@ -224,6 +258,9 @@ + + false + QPushButton { font-family: MS Shell Dlg 2; @@ -253,6 +290,9 @@ QPushButton[oob="true"] { 0 + + true + Current frequency offset @@ -1118,7 +1158,7 @@ QTextEdit[transmitting="true"] { - false + false QFrame::Box @@ -4705,6 +4745,8 @@ list. The list can be maintained in Settings (F2). C&ontrol + + @@ -5589,6 +5631,11 @@ list. The list can be maintained in Settings (F2). Show Statusbar + + + Set Frequency... + +