| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2023-11-18 13:12:18 +01:00
										 |  |  | // Copyright (C) 2020, 2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com>         //
 | 
					
						
							|  |  |  | // Copyright (C) 2021-2023 Jon Beniston, M7RCE <jon@beniston.com>                //
 | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // This program is free software; you can redistribute it and/or modify          //
 | 
					
						
							|  |  |  | // it under the terms of the GNU General Public License as published by          //
 | 
					
						
							|  |  |  | // the Free Software Foundation as version 3 of the License, or                  //
 | 
					
						
							|  |  |  | // (at your option) any later version.                                           //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // This program is distributed in the hope that it will be useful,               //
 | 
					
						
							|  |  |  | // but WITHOUT ANY WARRANTY; without even the implied warranty of                //
 | 
					
						
							|  |  |  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  //
 | 
					
						
							|  |  |  | // GNU General Public License V3 for more details.                               //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // You should have received a copy of the GNU General Public License             //
 | 
					
						
							|  |  |  | // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QMessageBox>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "feature/featureuiset.h"
 | 
					
						
							|  |  |  | #include "gui/basicfeaturesettingsdialog.h"
 | 
					
						
							| 
									
										
										
										
											2022-12-20 10:31:15 +00:00
										 |  |  | #include "gui/dialogpositioner.h"
 | 
					
						
							| 
									
										
										
										
											2020-10-12 21:59:04 +02:00
										 |  |  | #include "device/deviceset.h"
 | 
					
						
							|  |  |  | #include "maincore.h"
 | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "ui_rigctlservergui.h"
 | 
					
						
							|  |  |  | #include "rigctlserver.h"
 | 
					
						
							|  |  |  | #include "rigctlservergui.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | RigCtlServerGUI* RigCtlServerGUI::create(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feature) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	RigCtlServerGUI* gui = new RigCtlServerGUI(pluginAPI, featureUISet, feature); | 
					
						
							|  |  |  | 	return gui; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void RigCtlServerGUI::destroy() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	delete this; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void RigCtlServerGUI::resetToDefaults() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.resetToDefaults(); | 
					
						
							|  |  |  |     displaySettings(); | 
					
						
							|  |  |  | 	applySettings(true); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QByteArray RigCtlServerGUI::serialize() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_settings.serialize(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool RigCtlServerGUI::deserialize(const QByteArray& data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_settings.deserialize(data)) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-05-13 22:24:48 +02:00
										 |  |  |         m_feature->setWorkspaceIndex(m_settings.m_workspaceIndex); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  |         updateDeviceSetList(); | 
					
						
							|  |  |  |         displaySettings(); | 
					
						
							|  |  |  |         applySettings(true); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         resetToDefaults(); | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool RigCtlServerGUI::handleMessage(const Message& message) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (RigCtlServer::MsgConfigureRigCtlServer::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         qDebug("RigCtlServerGUI::handleMessage: RigCtlServer::MsgConfigureRigCtlServer"); | 
					
						
							|  |  |  |         const RigCtlServer::MsgConfigureRigCtlServer& cfg = (RigCtlServer::MsgConfigureRigCtlServer&) message; | 
					
						
							| 
									
										
										
										
											2022-11-27 13:36:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (cfg.getForce()) { | 
					
						
							|  |  |  |             m_settings = cfg.getSettings(); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  |         blockApplySettings(true); | 
					
						
							|  |  |  |         displaySettings(); | 
					
						
							|  |  |  |         blockApplySettings(false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (RigCtlServerSettings::MsgChannelIndexChange::match(message)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         const RigCtlServerSettings::MsgChannelIndexChange& cfg = (RigCtlServerSettings::MsgChannelIndexChange&) message; | 
					
						
							|  |  |  |         int newChannelIndex = cfg.getIndex(); | 
					
						
							|  |  |  |         qDebug("RigCtlServerGUI::handleMessage: RigCtlServerSettings::MsgChannelIndexChange: %d", newChannelIndex); | 
					
						
							|  |  |  |         ui->channel->blockSignals(true); | 
					
						
							|  |  |  |         ui->channel->setCurrentIndex(newChannelIndex); | 
					
						
							|  |  |  |         m_settings.m_channelIndex = newChannelIndex; | 
					
						
							|  |  |  |         ui->channel->blockSignals(false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void RigCtlServerGUI::handleInputMessages() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Message* message; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     while ((message = getInputMessageQueue()->pop())) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (handleMessage(*message)) { | 
					
						
							|  |  |  |             delete message; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void RigCtlServerGUI::onWidgetRolled(QWidget* widget, bool rollDown) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     (void) widget; | 
					
						
							|  |  |  |     (void) rollDown; | 
					
						
							| 
									
										
										
										
											2021-11-23 13:35:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-04 10:23:52 +02:00
										 |  |  |     getRollupContents()->saveState(m_rollupState); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | RigCtlServerGUI::RigCtlServerGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feature, QWidget* parent) : | 
					
						
							| 
									
										
										
										
											2020-10-03 23:55:24 +02:00
										 |  |  | 	FeatureGUI(parent), | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  | 	ui(new Ui::RigCtlServerGUI), | 
					
						
							|  |  |  | 	m_pluginAPI(pluginAPI), | 
					
						
							|  |  |  |     m_featureUISet(featureUISet), | 
					
						
							|  |  |  | 	m_doApplySettings(true), | 
					
						
							|  |  |  |     m_lastFeatureState(0) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-05-13 22:24:48 +02:00
										 |  |  |     m_feature = feature; | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  | 	setAttribute(Qt::WA_DeleteOnClose, true); | 
					
						
							| 
									
										
										
										
											2022-04-24 19:34:48 +02:00
										 |  |  |     m_helpURL = "plugins/feature/rigctlserver/readme.md"; | 
					
						
							|  |  |  |     RollupContents *rollupContents = getRollupContents(); | 
					
						
							|  |  |  | 	ui->setupUi(rollupContents); | 
					
						
							|  |  |  |     rollupContents->arrangeRollups(); | 
					
						
							|  |  |  | 	connect(rollupContents, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  |     m_rigCtlServer = reinterpret_cast<RigCtlServer*>(feature); | 
					
						
							|  |  |  |     m_rigCtlServer->setMessageQueueToGUI(&m_inputMessageQueue); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-09 05:27:12 +01:00
										 |  |  |     m_settings.setRollupState(&m_rollupState); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &))); | 
					
						
							|  |  |  |     connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages())); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus())); | 
					
						
							|  |  |  | 	m_statusTimer.start(1000); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     updateDeviceSetList(); | 
					
						
							|  |  |  |     displaySettings(); | 
					
						
							|  |  |  | 	applySettings(true); | 
					
						
							| 
									
										
										
										
											2022-04-04 10:23:52 +02:00
										 |  |  |     makeUIConnections(); | 
					
						
							| 
									
										
										
										
											2023-11-13 20:51:03 +00:00
										 |  |  |     m_resizer.enableChildMouseTracking(); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | RigCtlServerGUI::~RigCtlServerGUI() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	delete ui; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-13 22:24:48 +02:00
										 |  |  | void RigCtlServerGUI::setWorkspaceIndex(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_workspaceIndex = index; | 
					
						
							| 
									
										
										
										
											2022-11-27 13:36:48 +01:00
										 |  |  |     m_settingsKeys.append("workspaceIndex"); | 
					
						
							| 
									
										
										
										
											2022-05-13 22:24:48 +02:00
										 |  |  |     m_feature->setWorkspaceIndex(index); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  | void RigCtlServerGUI::blockApplySettings(bool block) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_doApplySettings = !block; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void RigCtlServerGUI::displaySettings() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     setTitleColor(m_settings.m_rgbColor); | 
					
						
							|  |  |  |     setWindowTitle(m_settings.m_title); | 
					
						
							| 
									
										
										
										
											2022-04-04 10:23:52 +02:00
										 |  |  |     setTitle(m_settings.m_title); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  |     blockApplySettings(true); | 
					
						
							|  |  |  |     ui->rigCtrlPort->setValue(m_settings.m_rigCtlPort); | 
					
						
							|  |  |  |     ui->maxFrequencyOffset->setValue(m_settings.m_maxFrequencyOffset); | 
					
						
							| 
									
										
										
										
											2022-04-04 10:23:52 +02:00
										 |  |  |     getRollupContents()->restoreState(m_rollupState); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  |     blockApplySettings(false); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void RigCtlServerGUI::updateDeviceSetList() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-10-12 21:59:04 +02:00
										 |  |  |     MainCore *mainCore = MainCore::instance(); | 
					
						
							|  |  |  |     std::vector<DeviceSet*>& deviceSets = mainCore->getDeviceSets(); | 
					
						
							|  |  |  |     std::vector<DeviceSet*>::const_iterator it = deviceSets.begin(); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ui->device->blockSignals(true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->device->clear(); | 
					
						
							|  |  |  |     unsigned int deviceIndex = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-12 21:59:04 +02:00
										 |  |  |     for (; it != deviceSets.end(); ++it, deviceIndex++) | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-10-12 21:59:04 +02:00
										 |  |  |         DSPDeviceSourceEngine *deviceSourceEngine = (*it)->m_deviceSourceEngine; | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (deviceSourceEngine) { | 
					
						
							|  |  |  |             ui->device->addItem(QString("R%1").arg(deviceIndex), deviceIndex); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     int newDeviceIndex; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-12 21:59:04 +02:00
										 |  |  |     if (it != deviceSets.begin()) | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (m_settings.m_deviceIndex < 0) { | 
					
						
							|  |  |  |             ui->device->setCurrentIndex(0); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             ui->device->setCurrentIndex(m_settings.m_deviceIndex); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         newDeviceIndex = ui->device->currentData().toInt(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         newDeviceIndex = -1; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (newDeviceIndex != m_settings.m_deviceIndex) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         qDebug("RigCtlServerGUI::updateDeviceSetLists: device index changed: %d", newDeviceIndex); | 
					
						
							|  |  |  |         m_settings.m_deviceIndex = newDeviceIndex; | 
					
						
							| 
									
										
										
										
											2022-11-27 13:36:48 +01:00
										 |  |  |         m_settingsKeys.append("deviceIndex"); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     updateChannelList(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->device->blockSignals(false); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool RigCtlServerGUI::updateChannelList() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int newChannelIndex; | 
					
						
							|  |  |  |     ui->channel->blockSignals(true); | 
					
						
							|  |  |  |     ui->channel->clear(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_settings.m_deviceIndex < 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         newChannelIndex = -1; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-10-12 21:59:04 +02:00
										 |  |  |         MainCore *mainCore = MainCore::instance(); | 
					
						
							|  |  |  |         std::vector<DeviceSet*>& deviceSets = mainCore->getDeviceSets(); | 
					
						
							|  |  |  |         DeviceSet *deviceSet = deviceSets[m_settings.m_deviceIndex]; | 
					
						
							|  |  |  |         int nbChannels = deviceSet->getNumberOfChannels(); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         for (int ch = 0; ch < nbChannels; ch++) { | 
					
						
							|  |  |  |             ui->channel->addItem(QString("%1").arg(ch), ch); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (nbChannels > 0) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             if (m_settings.m_channelIndex < 0) { | 
					
						
							|  |  |  |                 ui->channel->setCurrentIndex(0); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 ui->channel->setCurrentIndex(m_settings.m_channelIndex); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             newChannelIndex = ui->channel->currentIndex(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             newChannelIndex = -1; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ui->channel->blockSignals(false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (newChannelIndex != m_settings.m_channelIndex) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         qDebug("RigCtlServerGUI::updateChannelList: channel index changed: %d", newChannelIndex); | 
					
						
							|  |  |  |         m_settings.m_channelIndex = newChannelIndex; | 
					
						
							| 
									
										
										
										
											2022-11-27 13:36:48 +01:00
										 |  |  |         m_settingsKeys.append("channelIndex"); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void RigCtlServerGUI::onMenuDialogCalled(const QPoint &p) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_contextMenuType == ContextMenuChannelSettings) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         BasicFeatureSettingsDialog dialog(this); | 
					
						
							|  |  |  |         dialog.setTitle(m_settings.m_title); | 
					
						
							|  |  |  |         dialog.setUseReverseAPI(m_settings.m_useReverseAPI); | 
					
						
							|  |  |  |         dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress); | 
					
						
							|  |  |  |         dialog.setReverseAPIPort(m_settings.m_reverseAPIPort); | 
					
						
							|  |  |  |         dialog.setReverseAPIFeatureSetIndex(m_settings.m_reverseAPIFeatureSetIndex); | 
					
						
							|  |  |  |         dialog.setReverseAPIFeatureIndex(m_settings.m_reverseAPIFeatureIndex); | 
					
						
							| 
									
										
										
										
											2022-04-18 12:08:33 +02:00
										 |  |  |         dialog.setDefaultTitle(m_displayedName); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         dialog.move(p); | 
					
						
							| 
									
										
										
										
											2022-12-20 10:31:15 +00:00
										 |  |  |         new DialogPositioner(&dialog, false); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  |         dialog.exec(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         m_settings.m_title = dialog.getTitle(); | 
					
						
							|  |  |  |         m_settings.m_useReverseAPI = dialog.useReverseAPI(); | 
					
						
							|  |  |  |         m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress(); | 
					
						
							|  |  |  |         m_settings.m_reverseAPIPort = dialog.getReverseAPIPort(); | 
					
						
							|  |  |  |         m_settings.m_reverseAPIFeatureSetIndex = dialog.getReverseAPIFeatureSetIndex(); | 
					
						
							|  |  |  |         m_settings.m_reverseAPIFeatureIndex = dialog.getReverseAPIFeatureIndex(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-18 12:08:33 +02:00
										 |  |  |         setTitle(m_settings.m_title); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  |         setTitleColor(m_settings.m_rgbColor); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-27 13:36:48 +01:00
										 |  |  |         m_settingsKeys.append("title"); | 
					
						
							|  |  |  |         m_settingsKeys.append("rgbColor"); | 
					
						
							|  |  |  |         m_settingsKeys.append("useReverseAPI"); | 
					
						
							|  |  |  |         m_settingsKeys.append("reverseAPIAddress"); | 
					
						
							|  |  |  |         m_settingsKeys.append("reverseAPIPort"); | 
					
						
							|  |  |  |         m_settingsKeys.append("reverseAPIFeatureSetIndex"); | 
					
						
							|  |  |  |         m_settingsKeys.append("reverseAPIFeatureIndex"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  |         applySettings(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     resetContextMenuType(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void RigCtlServerGUI::on_startStop_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_doApplySettings) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         RigCtlServer::MsgStartStop *message = RigCtlServer::MsgStartStop::create(checked); | 
					
						
							|  |  |  |         m_rigCtlServer->getInputMessageQueue()->push(message); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void RigCtlServerGUI::on_enable_toggled(bool checked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_enabled = checked; | 
					
						
							| 
									
										
										
										
											2022-11-27 13:36:48 +01:00
										 |  |  |     m_settingsKeys.append("enabled"); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  |     applySettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void RigCtlServerGUI::on_devicesRefresh_clicked() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     updateDeviceSetList(); | 
					
						
							|  |  |  |     displaySettings(); | 
					
						
							|  |  |  |     applySettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void RigCtlServerGUI::on_device_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (index >= 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_settings.m_deviceIndex = ui->device->currentData().toInt(); | 
					
						
							| 
									
										
										
										
											2022-11-27 13:36:48 +01:00
										 |  |  |         m_settingsKeys.append("deviceIndex"); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  |         updateChannelList(); | 
					
						
							|  |  |  |         applySettings(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void RigCtlServerGUI::on_channel_currentIndexChanged(int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (index >= 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_settings.m_channelIndex = index; | 
					
						
							| 
									
										
										
										
											2022-11-27 13:36:48 +01:00
										 |  |  |         m_settingsKeys.append("channelIndex"); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  |         applySettings(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void RigCtlServerGUI::on_rigCtrlPort_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_rigCtlPort = value; | 
					
						
							| 
									
										
										
										
											2022-11-27 13:36:48 +01:00
										 |  |  |     m_settingsKeys.append("rigCtlPort"); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  |     applySettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void RigCtlServerGUI::on_maxFrequencyOffset_valueChanged(int value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_settings.m_maxFrequencyOffset = value; | 
					
						
							| 
									
										
										
										
											2022-11-27 13:36:48 +01:00
										 |  |  |     m_settingsKeys.append("maxFrequencyOffset"); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  |     applySettings(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void RigCtlServerGUI::updateStatus() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int state = m_rigCtlServer->getState(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_lastFeatureState != state) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         switch (state) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             case Feature::StNotStarted: | 
					
						
							|  |  |  |                 ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case Feature::StIdle: | 
					
						
							|  |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : blue; }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case Feature::StRunning: | 
					
						
							|  |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : green; }"); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case Feature::StError: | 
					
						
							|  |  |  |                 ui->startStop->setStyleSheet("QToolButton { background-color : red; }"); | 
					
						
							|  |  |  |                 QMessageBox::information(this, tr("Message"), m_rigCtlServer->getErrorMessage()); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             default: | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         m_lastFeatureState = state; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void RigCtlServerGUI::applySettings(bool force) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (m_doApplySettings) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2022-11-27 13:36:48 +01:00
										 |  |  | 	    RigCtlServer::MsgConfigureRigCtlServer* message = RigCtlServer::MsgConfigureRigCtlServer::create(m_settings, m_settingsKeys, force); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  | 	    m_rigCtlServer->getInputMessageQueue()->push(message); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-11-27 13:36:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     m_settingsKeys.clear(); | 
					
						
							| 
									
										
										
										
											2020-09-28 00:31:08 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-04-04 10:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void RigCtlServerGUI::makeUIConnections() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	QObject::connect(ui->startStop, &ButtonSwitch::toggled, this, &RigCtlServerGUI::on_startStop_toggled); | 
					
						
							|  |  |  | 	QObject::connect(ui->enable, &QCheckBox::toggled, this, &RigCtlServerGUI::on_enable_toggled); | 
					
						
							|  |  |  | 	QObject::connect(ui->devicesRefresh, &QPushButton::clicked, this, &RigCtlServerGUI::on_devicesRefresh_clicked); | 
					
						
							|  |  |  | 	QObject::connect(ui->device, qOverload<int>(&QComboBox::currentIndexChanged), this, &RigCtlServerGUI::on_device_currentIndexChanged); | 
					
						
							|  |  |  | 	QObject::connect(ui->channel, qOverload<int>(&QComboBox::currentIndexChanged), this, &RigCtlServerGUI::on_channel_currentIndexChanged); | 
					
						
							|  |  |  | 	QObject::connect(ui->rigCtrlPort, qOverload<int>(&QSpinBox::valueChanged), this, &RigCtlServerGUI::on_rigCtrlPort_valueChanged); | 
					
						
							|  |  |  | 	QObject::connect(ui->maxFrequencyOffset, qOverload<int>(&QSpinBox::valueChanged), this, &RigCtlServerGUI::on_maxFrequencyOffset_valueChanged); | 
					
						
							|  |  |  | } |