Added a new, more obvious frequency control and a menu item for setting the frequency
This commit is contained in:
		
							parent
							
								
									d3f398e538
								
							
						
					
					
						commit
						8738132836
					
				
							
								
								
									
										15
									
								
								keyeater.cpp
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								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<QMouseEvent *>(event); | ||||
|         bool processed = false; | ||||
|         emit this->mousePressed(obj, mouseEvent, &processed); | ||||
|         if(processed){ | ||||
|             return true; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     // standard event processing
 | ||||
|     return QObject::eventFilter(obj, event); | ||||
| } | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										18
									
								
								keyeater.h
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								keyeater.h
									
									
									
									
									
								
							| @ -3,6 +3,7 @@ | ||||
| 
 | ||||
| #include <QObject> | ||||
| #include <QKeyEvent> | ||||
| #include <QMouseEvent> | ||||
| 
 | ||||
| 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
 | ||||
|  | ||||
| @ -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); | ||||
| 
 | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
| @ -194,6 +194,40 @@ | ||||
|                 </property> | ||||
|                </spacer> | ||||
|               </item> | ||||
|               <item> | ||||
|                <widget class="QLCDNumber" name="currentFreq"> | ||||
|                 <property name="minimumSize"> | ||||
|                  <size> | ||||
|                   <width>200</width> | ||||
|                   <height>40</height> | ||||
|                  </size> | ||||
|                 </property> | ||||
|                 <property name="frameShape"> | ||||
|                  <enum>QFrame::NoFrame</enum> | ||||
|                 </property> | ||||
|                 <property name="frameShadow"> | ||||
|                  <enum>QFrame::Plain</enum> | ||||
|                 </property> | ||||
|                 <property name="lineWidth"> | ||||
|                  <number>0</number> | ||||
|                 </property> | ||||
|                 <property name="smallDecimalPoint"> | ||||
|                  <bool>false</bool> | ||||
|                 </property> | ||||
|                 <property name="digitCount"> | ||||
|                  <number>10</number> | ||||
|                 </property> | ||||
|                 <property name="segmentStyle"> | ||||
|                  <enum>QLCDNumber::Flat</enum> | ||||
|                 </property> | ||||
|                 <property name="value" stdset="0"> | ||||
|                  <double>1234567890.000000000000000</double> | ||||
|                 </property> | ||||
|                 <property name="intValue" stdset="0"> | ||||
|                  <number>1234567890</number> | ||||
|                 </property> | ||||
|                </widget> | ||||
|               </item> | ||||
|               <item> | ||||
|                <widget class="QComboBox" name="bandComboBox"> | ||||
|                 <property name="minimumSize"> | ||||
| @ -203,7 +237,7 @@ | ||||
|                  </size> | ||||
|                 </property> | ||||
|                 <property name="visible"> | ||||
|                  <bool>true</bool> | ||||
|                  <bool>false</bool> | ||||
|                 </property> | ||||
|                 <property name="toolTip"> | ||||
|                  <string><html><head/><body><p>Select operating band or enter frequency in MHz or enter kHz increment followed by k.</p></body></html></string> | ||||
| @ -224,6 +258,9 @@ | ||||
|               </item> | ||||
|               <item> | ||||
|                <widget class="QPushButton" name="labDialFreq"> | ||||
|                 <property name="visible"> | ||||
|                  <bool>false</bool> | ||||
|                 </property> | ||||
|                 <property name="styleSheet"> | ||||
|                  <string notr="true">QPushButton { | ||||
|  font-family: MS Shell Dlg 2; | ||||
| @ -253,6 +290,9 @@ QPushButton[oob="true"] { | ||||
|                   <verstretch>0</verstretch> | ||||
|                  </sizepolicy> | ||||
|                 </property> | ||||
|                 <property name="visible"> | ||||
|                  <bool>true</bool> | ||||
|                 </property> | ||||
|                 <property name="toolTip"> | ||||
|                  <string>Current frequency offset</string> | ||||
|                 </property> | ||||
| @ -4705,6 +4745,8 @@ list. The list can be maintained in Settings (F2).</string> | ||||
|     <property name="title"> | ||||
|      <string>C&ontrol</string> | ||||
|     </property> | ||||
|     <addaction name="actionSetFrequency"/> | ||||
|     <addaction name="separator"/> | ||||
|     <addaction name="actionEnable_Spotting"/> | ||||
|     <addaction name="actionEnable_Auto_Reply"/> | ||||
|     <addaction name="separator"/> | ||||
| @ -5589,6 +5631,11 @@ list. The list can be maintained in Settings (F2).</string> | ||||
|     <string>Show Statusbar</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="actionSetFrequency"> | ||||
|    <property name="text"> | ||||
|     <string>Set Frequency...</string> | ||||
|    </property> | ||||
|   </action> | ||||
|  </widget> | ||||
|  <layoutdefault spacing="6" margin="11"/> | ||||
|  <customwidgets> | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Jordan Sherer
						Jordan Sherer