mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 09:48:45 -05:00
Jogdial Controller feature: Make settings assignments atomic. Part of #1329
This commit is contained in:
parent
005cee925d
commit
e50d9dc78a
@ -100,7 +100,7 @@ bool JogdialController::handleMessage(const Message& cmd)
|
|||||||
{
|
{
|
||||||
MsgConfigureJogdialController& cfg = (MsgConfigureJogdialController&) cmd;
|
MsgConfigureJogdialController& cfg = (MsgConfigureJogdialController&) cmd;
|
||||||
qDebug() << "JogdialController::handleMessage: MsgConfigureJogdialController";
|
qDebug() << "JogdialController::handleMessage: MsgConfigureJogdialController";
|
||||||
applySettings(cfg.getSettings(), cfg.getForce());
|
applySettings(cfg.getSettings(), cfg.getSettingsKeys(), cfg.getForce());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -161,48 +161,31 @@ bool JogdialController::deserialize(const QByteArray& data)
|
|||||||
{
|
{
|
||||||
if (m_settings.deserialize(data))
|
if (m_settings.deserialize(data))
|
||||||
{
|
{
|
||||||
MsgConfigureJogdialController *msg = MsgConfigureJogdialController::create(m_settings, true);
|
MsgConfigureJogdialController *msg = MsgConfigureJogdialController::create(m_settings, QList<QString>(), true);
|
||||||
m_inputMessageQueue.push(msg);
|
m_inputMessageQueue.push(msg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_settings.resetToDefaults();
|
m_settings.resetToDefaults();
|
||||||
MsgConfigureJogdialController *msg = MsgConfigureJogdialController::create(m_settings, true);
|
MsgConfigureJogdialController *msg = MsgConfigureJogdialController::create(m_settings, QList<QString>(), true);
|
||||||
m_inputMessageQueue.push(msg);
|
m_inputMessageQueue.push(msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JogdialController::applySettings(const JogdialControllerSettings& settings, bool force)
|
void JogdialController::applySettings(const JogdialControllerSettings& settings, const QList<QString>& settingsKeys, bool force)
|
||||||
{
|
{
|
||||||
qDebug() << "JogdialController::applySettings:"
|
qDebug() << "JogdialController::applySettings:" << settings.getDebugString(settingsKeys, force) << " force: " << force;
|
||||||
<< " 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;
|
|
||||||
|
|
||||||
QList<QString> reverseAPIKeys;
|
if (settingsKeys.contains("useReverseAPI"))
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
|
bool fullUpdate = (settingsKeys.contains("useReverseAPI") && settings.m_useReverseAPI) ||
|
||||||
(m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) ||
|
settingsKeys.contains("reverseAPIAddress") ||
|
||||||
(m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) ||
|
settingsKeys.contains("reverseAPIPort") ||
|
||||||
(m_settings.m_reverseAPIFeatureSetIndex != settings.m_reverseAPIFeatureSetIndex) ||
|
settingsKeys.contains("reverseAPIFeatureSetIndex") ||
|
||||||
(m_settings.m_reverseAPIFeatureIndex != settings.m_reverseAPIFeatureIndex);
|
settingsKeys.contains("m_reverseAPIFeatureIndex");
|
||||||
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
|
webapiReverseSendSettings(settingsKeys, settings, fullUpdate || force);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_settings = settings;
|
m_settings = settings;
|
||||||
@ -329,13 +312,13 @@ int JogdialController::webapiSettingsPutPatch(
|
|||||||
JogdialControllerSettings settings = m_settings;
|
JogdialControllerSettings settings = m_settings;
|
||||||
webapiUpdateFeatureSettings(settings, featureSettingsKeys, response);
|
webapiUpdateFeatureSettings(settings, featureSettingsKeys, response);
|
||||||
|
|
||||||
MsgConfigureJogdialController *msg = MsgConfigureJogdialController::create(settings, force);
|
MsgConfigureJogdialController *msg = MsgConfigureJogdialController::create(settings, featureSettingsKeys, force);
|
||||||
m_inputMessageQueue.push(msg);
|
m_inputMessageQueue.push(msg);
|
||||||
|
|
||||||
qDebug("JogdialController::webapiSettingsPutPatch: forward to GUI: %p", m_guiMessageQueue);
|
qDebug("JogdialController::webapiSettingsPutPatch: forward to GUI: %p", m_guiMessageQueue);
|
||||||
if (m_guiMessageQueue) // forward to GUI if any
|
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);
|
m_guiMessageQueue->push(msgToGUI);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +396,7 @@ void JogdialController::webapiUpdateFeatureSettings(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JogdialController::webapiReverseSendSettings(QList<QString>& featureSettingsKeys, const JogdialControllerSettings& settings, bool force)
|
void JogdialController::webapiReverseSendSettings(const QList<QString>& featureSettingsKeys, const JogdialControllerSettings& settings, bool force)
|
||||||
{
|
{
|
||||||
SWGSDRangel::SWGFeatureSettings *swgFeatureSettings = new SWGSDRangel::SWGFeatureSettings();
|
SWGSDRangel::SWGFeatureSettings *swgFeatureSettings = new SWGSDRangel::SWGFeatureSettings();
|
||||||
// swgFeatureSettings->setOriginatorFeatureIndex(getIndexInDeviceSet());
|
// swgFeatureSettings->setOriginatorFeatureIndex(getIndexInDeviceSet());
|
||||||
|
@ -44,19 +44,22 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
const JogdialControllerSettings& getSettings() const { return m_settings; }
|
const JogdialControllerSettings& getSettings() const { return m_settings; }
|
||||||
|
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
|
||||||
bool getForce() const { return m_force; }
|
bool getForce() const { return m_force; }
|
||||||
|
|
||||||
static MsgConfigureJogdialController* create(const JogdialControllerSettings& settings, bool force) {
|
static MsgConfigureJogdialController* create(const JogdialControllerSettings& settings, const QList<QString>& settingsKeys, bool force) {
|
||||||
return new MsgConfigureJogdialController(settings, force);
|
return new MsgConfigureJogdialController(settings, settingsKeys, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JogdialControllerSettings m_settings;
|
JogdialControllerSettings m_settings;
|
||||||
|
QList<QString> m_settingsKeys;
|
||||||
bool m_force;
|
bool m_force;
|
||||||
|
|
||||||
MsgConfigureJogdialController(const JogdialControllerSettings& settings, bool force) :
|
MsgConfigureJogdialController(const JogdialControllerSettings& settings, const QList<QString>& settingsKeys, bool force) :
|
||||||
Message(),
|
Message(),
|
||||||
m_settings(settings),
|
m_settings(settings),
|
||||||
|
m_settingsKeys(settingsKeys),
|
||||||
m_force(force)
|
m_force(force)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
@ -209,11 +212,11 @@ private:
|
|||||||
|
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
void applySettings(const JogdialControllerSettings& settings, bool force = false);
|
void applySettings(const JogdialControllerSettings& settings, const QList<QString>& settingsKeys, bool force = false);
|
||||||
void updateChannels();
|
void updateChannels();
|
||||||
void channelUp();
|
void channelUp();
|
||||||
void channelDown();
|
void channelDown();
|
||||||
void webapiReverseSendSettings(QList<QString>& featureSettingsKeys, const JogdialControllerSettings& settings, bool force);
|
void webapiReverseSendSettings(const QList<QString>& featureSettingsKeys, const JogdialControllerSettings& settings, bool force);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void networkManagerFinished(QNetworkReply *reply);
|
void networkManagerFinished(QNetworkReply *reply);
|
||||||
|
@ -73,7 +73,13 @@ bool JogdialControllerGUI::handleMessage(const Message& message)
|
|||||||
{
|
{
|
||||||
qDebug("JogdialControllerGUI::handleMessage: JogdialController::MsgConfigureJogdialController");
|
qDebug("JogdialControllerGUI::handleMessage: JogdialController::MsgConfigureJogdialController");
|
||||||
const JogdialController::MsgConfigureJogdialController& cfg = (JogdialController::MsgConfigureJogdialController&) message;
|
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);
|
blockApplySettings(true);
|
||||||
displaySettings();
|
displaySettings();
|
||||||
blockApplySettings(false);
|
blockApplySettings(false);
|
||||||
@ -264,6 +270,14 @@ void JogdialControllerGUI::onMenuDialogCalled(const QPoint &p)
|
|||||||
setTitle(m_settings.m_title);
|
setTitle(m_settings.m_title);
|
||||||
setTitleColor(m_settings.m_rgbColor);
|
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();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,9 +358,11 @@ void JogdialControllerGUI::applySettings(bool force)
|
|||||||
{
|
{
|
||||||
if (m_doApplySettings)
|
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_jogdialController->getInputMessageQueue()->push(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_settingsKeys.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JogdialControllerGUI::focusInEvent(QFocusEvent*)
|
void JogdialControllerGUI::focusInEvent(QFocusEvent*)
|
||||||
|
@ -61,6 +61,7 @@ private:
|
|||||||
PluginAPI* m_pluginAPI;
|
PluginAPI* m_pluginAPI;
|
||||||
FeatureUISet* m_featureUISet;
|
FeatureUISet* m_featureUISet;
|
||||||
JogdialControllerSettings m_settings;
|
JogdialControllerSettings m_settings;
|
||||||
|
QList<QString> m_settingsKeys;
|
||||||
RollupState m_rollupState;
|
RollupState m_rollupState;
|
||||||
bool m_doApplySettings;
|
bool m_doApplySettings;
|
||||||
|
|
||||||
|
@ -146,3 +146,63 @@ bool JogdialControllerSettings::deserialize(const QByteArray& data)
|
|||||||
return false;
|
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());
|
||||||
|
}
|
||||||
|
@ -60,6 +60,8 @@ struct JogdialControllerSettings
|
|||||||
QByteArray serialize() const;
|
QByteArray serialize() const;
|
||||||
bool deserialize(const QByteArray& data);
|
bool deserialize(const QByteArray& data);
|
||||||
void setRollupState(Serializable *rollupState) { m_rollupState = rollupState; }
|
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_channelTypes;
|
||||||
static const QStringList m_channelURIs;
|
static const QStringList m_channelURIs;
|
||||||
|
Loading…
Reference in New Issue
Block a user