diff --git a/plugins/feature/jogdialcontroller/jogdialcontroller.cpp b/plugins/feature/jogdialcontroller/jogdialcontroller.cpp index 6e4f14c43..ab6c01360 100644 --- a/plugins/feature/jogdialcontroller/jogdialcontroller.cpp +++ b/plugins/feature/jogdialcontroller/jogdialcontroller.cpp @@ -100,7 +100,7 @@ bool JogdialController::handleMessage(const Message& cmd) { MsgConfigureJogdialController& cfg = (MsgConfigureJogdialController&) cmd; qDebug() << "JogdialController::handleMessage: MsgConfigureJogdialController"; - applySettings(cfg.getSettings(), cfg.getForce()); + applySettings(cfg.getSettings(), cfg.getSettingsKeys(), cfg.getForce()); return true; } @@ -161,48 +161,31 @@ bool JogdialController::deserialize(const QByteArray& data) { if (m_settings.deserialize(data)) { - MsgConfigureJogdialController *msg = MsgConfigureJogdialController::create(m_settings, true); + MsgConfigureJogdialController *msg = MsgConfigureJogdialController::create(m_settings, QList(), true); m_inputMessageQueue.push(msg); return true; } else { m_settings.resetToDefaults(); - MsgConfigureJogdialController *msg = MsgConfigureJogdialController::create(m_settings, true); + MsgConfigureJogdialController *msg = MsgConfigureJogdialController::create(m_settings, QList(), true); m_inputMessageQueue.push(msg); return false; } } -void JogdialController::applySettings(const JogdialControllerSettings& settings, bool force) +void JogdialController::applySettings(const JogdialControllerSettings& settings, const QList& settingsKeys, bool force) { - qDebug() << "JogdialController::applySettings:" - << " m_title: " << settings.m_title - << " m_rgbColor: " << settings.m_rgbColor - << " m_useReverseAPI: " << settings.m_useReverseAPI - << " m_reverseAPIAddress: " << settings.m_reverseAPIAddress - << " m_reverseAPIPort: " << settings.m_reverseAPIPort - << " m_reverseAPIFeatureSetIndex: " << settings.m_reverseAPIFeatureSetIndex - << " m_reverseAPIFeatureIndex: " << settings.m_reverseAPIFeatureIndex - << " force: " << force; + qDebug() << "JogdialController::applySettings:" << settings.getDebugString(settingsKeys, force) << " force: " << force; - QList reverseAPIKeys; - - if ((m_settings.m_title != settings.m_title) || force) { - reverseAPIKeys.append("title"); - } - if ((m_settings.m_rgbColor != settings.m_rgbColor) || force) { - reverseAPIKeys.append("rgbColor"); - } - - if (settings.m_useReverseAPI) + if (settingsKeys.contains("useReverseAPI")) { - bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) || - (m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) || - (m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) || - (m_settings.m_reverseAPIFeatureSetIndex != settings.m_reverseAPIFeatureSetIndex) || - (m_settings.m_reverseAPIFeatureIndex != settings.m_reverseAPIFeatureIndex); - webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force); + bool fullUpdate = (settingsKeys.contains("useReverseAPI") && settings.m_useReverseAPI) || + settingsKeys.contains("reverseAPIAddress") || + settingsKeys.contains("reverseAPIPort") || + settingsKeys.contains("reverseAPIFeatureSetIndex") || + settingsKeys.contains("m_reverseAPIFeatureIndex"); + webapiReverseSendSettings(settingsKeys, settings, fullUpdate || force); } m_settings = settings; @@ -329,13 +312,13 @@ int JogdialController::webapiSettingsPutPatch( JogdialControllerSettings settings = m_settings; webapiUpdateFeatureSettings(settings, featureSettingsKeys, response); - MsgConfigureJogdialController *msg = MsgConfigureJogdialController::create(settings, force); + MsgConfigureJogdialController *msg = MsgConfigureJogdialController::create(settings, featureSettingsKeys, force); m_inputMessageQueue.push(msg); qDebug("JogdialController::webapiSettingsPutPatch: forward to GUI: %p", m_guiMessageQueue); if (m_guiMessageQueue) // forward to GUI if any { - MsgConfigureJogdialController *msgToGUI = MsgConfigureJogdialController::create(settings, force); + MsgConfigureJogdialController *msgToGUI = MsgConfigureJogdialController::create(settings, featureSettingsKeys, force); m_guiMessageQueue->push(msgToGUI); } @@ -413,7 +396,7 @@ void JogdialController::webapiUpdateFeatureSettings( } } -void JogdialController::webapiReverseSendSettings(QList& featureSettingsKeys, const JogdialControllerSettings& settings, bool force) +void JogdialController::webapiReverseSendSettings(const QList& featureSettingsKeys, const JogdialControllerSettings& settings, bool force) { SWGSDRangel::SWGFeatureSettings *swgFeatureSettings = new SWGSDRangel::SWGFeatureSettings(); // swgFeatureSettings->setOriginatorFeatureIndex(getIndexInDeviceSet()); diff --git a/plugins/feature/jogdialcontroller/jogdialcontroller.h b/plugins/feature/jogdialcontroller/jogdialcontroller.h index 58e621d21..2e6a887c4 100644 --- a/plugins/feature/jogdialcontroller/jogdialcontroller.h +++ b/plugins/feature/jogdialcontroller/jogdialcontroller.h @@ -44,19 +44,22 @@ public: public: const JogdialControllerSettings& getSettings() const { return m_settings; } + const QList& getSettingsKeys() const { return m_settingsKeys; } bool getForce() const { return m_force; } - static MsgConfigureJogdialController* create(const JogdialControllerSettings& settings, bool force) { - return new MsgConfigureJogdialController(settings, force); + static MsgConfigureJogdialController* create(const JogdialControllerSettings& settings, const QList& settingsKeys, bool force) { + return new MsgConfigureJogdialController(settings, settingsKeys, force); } private: JogdialControllerSettings m_settings; + QList m_settingsKeys; bool m_force; - MsgConfigureJogdialController(const JogdialControllerSettings& settings, bool force) : + MsgConfigureJogdialController(const JogdialControllerSettings& settings, const QList& settingsKeys, bool force) : Message(), m_settings(settings), + m_settingsKeys(settingsKeys), m_force(force) { } }; @@ -209,11 +212,11 @@ private: void start(); void stop(); - void applySettings(const JogdialControllerSettings& settings, bool force = false); + void applySettings(const JogdialControllerSettings& settings, const QList& settingsKeys, bool force = false); void updateChannels(); void channelUp(); void channelDown(); - void webapiReverseSendSettings(QList& featureSettingsKeys, const JogdialControllerSettings& settings, bool force); + void webapiReverseSendSettings(const QList& featureSettingsKeys, const JogdialControllerSettings& settings, bool force); private slots: void networkManagerFinished(QNetworkReply *reply); diff --git a/plugins/feature/jogdialcontroller/jogdialcontrollergui.cpp b/plugins/feature/jogdialcontroller/jogdialcontrollergui.cpp index 249b9d013..e94d200ec 100644 --- a/plugins/feature/jogdialcontroller/jogdialcontrollergui.cpp +++ b/plugins/feature/jogdialcontroller/jogdialcontrollergui.cpp @@ -73,7 +73,13 @@ bool JogdialControllerGUI::handleMessage(const Message& message) { qDebug("JogdialControllerGUI::handleMessage: JogdialController::MsgConfigureJogdialController"); const JogdialController::MsgConfigureJogdialController& cfg = (JogdialController::MsgConfigureJogdialController&) message; - m_settings = cfg.getSettings(); + + if (cfg.getForce()) { + m_settings = cfg.getSettings(); + } else { + m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings()); + } + blockApplySettings(true); displaySettings(); blockApplySettings(false); @@ -264,6 +270,14 @@ void JogdialControllerGUI::onMenuDialogCalled(const QPoint &p) setTitle(m_settings.m_title); setTitleColor(m_settings.m_rgbColor); + 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"); + applySettings(); } @@ -344,9 +358,11 @@ void JogdialControllerGUI::applySettings(bool force) { if (m_doApplySettings) { - JogdialController::MsgConfigureJogdialController* message = JogdialController::MsgConfigureJogdialController::create( m_settings, force); + JogdialController::MsgConfigureJogdialController* message = JogdialController::MsgConfigureJogdialController::create( m_settings, m_settingsKeys, force); m_jogdialController->getInputMessageQueue()->push(message); } + + m_settingsKeys.clear(); } void JogdialControllerGUI::focusInEvent(QFocusEvent*) diff --git a/plugins/feature/jogdialcontroller/jogdialcontrollergui.h b/plugins/feature/jogdialcontroller/jogdialcontrollergui.h index f9095b202..9e691dbb9 100644 --- a/plugins/feature/jogdialcontroller/jogdialcontrollergui.h +++ b/plugins/feature/jogdialcontroller/jogdialcontrollergui.h @@ -61,6 +61,7 @@ private: PluginAPI* m_pluginAPI; FeatureUISet* m_featureUISet; JogdialControllerSettings m_settings; + QList m_settingsKeys; RollupState m_rollupState; bool m_doApplySettings; diff --git a/plugins/feature/jogdialcontroller/jogdialcontrollersettings.cpp b/plugins/feature/jogdialcontroller/jogdialcontrollersettings.cpp index 01900a482..a355426ce 100644 --- a/plugins/feature/jogdialcontroller/jogdialcontrollersettings.cpp +++ b/plugins/feature/jogdialcontroller/jogdialcontrollersettings.cpp @@ -146,3 +146,63 @@ bool JogdialControllerSettings::deserialize(const QByteArray& data) return false; } } + +void JogdialControllerSettings::applySettings(const QStringList& settingsKeys, const JogdialControllerSettings& settings) +{ + if (settingsKeys.contains("title")) { + m_title = settings.m_title; + } + if (settingsKeys.contains("rgbColor")) { + m_rgbColor = settings.m_rgbColor; + } + if (settingsKeys.contains("useReverseAPI")) { + m_useReverseAPI = settings.m_useReverseAPI; + } + if (settingsKeys.contains("reverseAPIAddress")) { + m_reverseAPIAddress = settings.m_reverseAPIAddress; + } + if (settingsKeys.contains("reverseAPIPort")) { + m_reverseAPIPort = settings.m_reverseAPIPort; + } + if (settingsKeys.contains("reverseAPIFeatureSetIndex")) { + m_reverseAPIFeatureSetIndex = settings.m_reverseAPIFeatureSetIndex; + } + if (settingsKeys.contains("reverseAPIFeatureIndex")) { + m_reverseAPIFeatureIndex = settings.m_reverseAPIFeatureIndex; + } + if (settingsKeys.contains("workspaceIndex")) { + m_workspaceIndex = settings.m_workspaceIndex; + } +} + +QString JogdialControllerSettings::getDebugString(const QStringList& settingsKeys, bool force) const +{ + std::ostringstream ostr; + + if (settingsKeys.contains("title") || force) { + ostr << " m_title: " << m_title.toStdString(); + } + if (settingsKeys.contains("rgbColor") || force) { + ostr << " m_rgbColor: " << m_rgbColor; + } + if (settingsKeys.contains("useReverseAPI") || force) { + ostr << " m_useReverseAPI: " << m_useReverseAPI; + } + if (settingsKeys.contains("reverseAPIAddress") || force) { + ostr << " m_reverseAPIAddress: " << m_reverseAPIAddress.toStdString(); + } + if (settingsKeys.contains("reverseAPIPort") || force) { + ostr << " m_reverseAPIPort: " << m_reverseAPIPort; + } + if (settingsKeys.contains("reverseAPIFeatureSetIndex") || force) { + ostr << " m_reverseAPIFeatureSetIndex: " << m_reverseAPIFeatureSetIndex; + } + if (settingsKeys.contains("reverseAPIFeatureIndex") || force) { + ostr << " m_reverseAPIFeatureIndex: " << m_reverseAPIFeatureIndex; + } + if (settingsKeys.contains("workspaceIndex") || force) { + ostr << " m_workspaceIndex: " << m_workspaceIndex; + } + + return QString(ostr.str().c_str()); +} diff --git a/plugins/feature/jogdialcontroller/jogdialcontrollersettings.h b/plugins/feature/jogdialcontroller/jogdialcontrollersettings.h index fecb052a4..49adde648 100644 --- a/plugins/feature/jogdialcontroller/jogdialcontrollersettings.h +++ b/plugins/feature/jogdialcontroller/jogdialcontrollersettings.h @@ -60,6 +60,8 @@ struct JogdialControllerSettings QByteArray serialize() const; bool deserialize(const QByteArray& data); void setRollupState(Serializable *rollupState) { m_rollupState = rollupState; } + void applySettings(const QStringList& settingsKeys, const JogdialControllerSettings& settings); + QString getDebugString(const QStringList& settingsKeys, bool force=false) const; static const QStringList m_channelTypes; static const QStringList m_channelURIs;