1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

CameraStab UI: more comments to serve as a self-documented code sample

Also disabled "module enable" checkbox reload/default actions.
This commit is contained in:
Oleg Semyonov 2012-08-18 20:45:05 +03:00
parent 57d4aaaf17
commit 0afd923708

View File

@ -2,7 +2,7 @@
****************************************************************************** ******************************************************************************
* *
* @file configcamerastabilizationwidget.cpp * @file configcamerastabilizationwidget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011-2012.
* @addtogroup GCSPlugins GCS Plugins * @addtogroup GCSPlugins GCS Plugins
* @{ * @{
* @addtogroup ConfigPlugin Config Plugin * @addtogroup ConfigPlugin Config Plugin
@ -56,16 +56,21 @@ ConfigCameraStabilizationWidget::ConfigCameraStabilizationWidget(QWidget *parent
// using objrelation dynamic property // using objrelation dynamic property
autoLoadWidgets(); autoLoadWidgets();
QList<int> reloadGroups; // Add some widgets to track their UI dirty state and handle smartsave
reloadGroups<<1;
// Add some widgets and UAVObjects to track widget dirty state
// and monitor UAVObject changes in addition to autoloaded ones
addWidget(m_camerastabilization->enableCameraStabilization); addWidget(m_camerastabilization->enableCameraStabilization);
addWidget(m_camerastabilization->rollChannel); addWidget(m_camerastabilization->rollChannel);
addWidget(m_camerastabilization->pitchChannel); addWidget(m_camerastabilization->pitchChannel);
addWidget(m_camerastabilization->yawChannel); addWidget(m_camerastabilization->yawChannel);
addUAVObject("HwSettings",&reloadGroups);
addUAVObject("MixerSettings",&reloadGroups); // Add some UAVObjects to monitor their changes in addition to autoloaded ones.
// Note also that we want to reload some UAVObjects by "Reload" button and have
// to pass corresponding reload group numbers (defined also in objrelation property)
// to the montitor. We don't reload HwSettings (module enable state) but reload
// output channels.
QList<int> reloadGroups;
reloadGroups << 1;
addUAVObject("HwSettings");
addUAVObject("MixerSettings", &reloadGroups);
// To set special widgets to defaults when requested // To set special widgets to defaults when requested
connect(this, SIGNAL(defaultRequested(int)), this, SLOT(defaultRequestedSlot(int))); connect(this, SIGNAL(defaultRequested(int)), this, SLOT(defaultRequestedSlot(int)));
@ -228,12 +233,19 @@ void ConfigCameraStabilizationWidget::defaultRequestedSlot(int group)
{ {
Q_UNUSED(group); Q_UNUSED(group);
HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager()); // Here is the example of how to reset the state of QCheckBox. It is
HwSettings *hwSettingsDefault=(HwSettings*)hwSettings->dirtyClone(); // commented out because we normally don't want to reset the module
HwSettings::DataFields hwSettingsData = hwSettingsDefault->getData(); // enable state to default "disabled" (or we don't care about values at all).
m_camerastabilization->enableCameraStabilization->setChecked( // But if you want, you could use the dirtyClone() function to get default
hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] == HwSettings::OPTIONALMODULES_ENABLED); // values of an object and then use them to set a widget state.
//
//HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());
//HwSettings *hwSettingsDefault=(HwSettings*)hwSettings->dirtyClone();
//HwSettings::DataFields hwSettingsData = hwSettingsDefault->getData();
//m_camerastabilization->enableCameraStabilization->setChecked(
// hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] == HwSettings::OPTIONALMODULES_ENABLED);
// For outputs we set them all to none, so don't use any UAVObject to get defaults
QComboBox *outputs[] = { QComboBox *outputs[] = {
m_camerastabilization->rollChannel, m_camerastabilization->rollChannel,
m_camerastabilization->pitchChannel, m_camerastabilization->pitchChannel,