mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-16 08:29:15 +01:00
OP-1797 avoid redundant calls to loadConfiguration when setting a configuration on a gadget
This commit is contained in:
parent
be9f4aec6a
commit
505801c3a5
@ -44,7 +44,7 @@ UAVGadgetDecorator::UAVGadgetDecorator(IUAVGadget *gadget, QList<IUAVGadgetConfi
|
||||
m_toolbar->setMinimumContentsLength(15);
|
||||
foreach(IUAVGadgetConfiguration * config, *m_configurations)
|
||||
m_toolbar->addItem(config->name());
|
||||
connect(m_toolbar, SIGNAL(activated(int)), this, SLOT(loadConfiguration(int)));
|
||||
connect(m_toolbar, SIGNAL(currentIndexChanged(int)), this, SLOT(loadConfiguration(int)));
|
||||
updateToolbar();
|
||||
}
|
||||
|
||||
@ -63,15 +63,22 @@ void UAVGadgetDecorator::loadConfiguration(int index)
|
||||
|
||||
void UAVGadgetDecorator::loadConfiguration(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
if (m_activeConfiguration == config) {
|
||||
return;
|
||||
}
|
||||
m_activeConfiguration = config;
|
||||
int index = m_toolbar->findText(config->name());
|
||||
m_toolbar->setCurrentIndex(index);
|
||||
if (m_toolbar->currentIndex() != index) {
|
||||
m_toolbar->setCurrentIndex(index);
|
||||
}
|
||||
m_gadget->loadConfiguration(config);
|
||||
}
|
||||
|
||||
void UAVGadgetDecorator::configurationChanged(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
if (config == m_activeConfiguration) {
|
||||
// force a configuration reload
|
||||
m_activeConfiguration = NULL;
|
||||
loadConfiguration(config);
|
||||
}
|
||||
}
|
||||
@ -133,7 +140,6 @@ void UAVGadgetDecorator::restoreState(QSettings *qSettings)
|
||||
|
||||
foreach(IUAVGadgetConfiguration * config, *m_configurations) {
|
||||
if (config->name() == configName) {
|
||||
m_activeConfiguration = config;
|
||||
loadConfiguration(config);
|
||||
break;
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ void UAVGadgetInstanceManager::readConfigs_1_1_0(QSettings *qs)
|
||||
|
||||
configs = qs->childGroups();
|
||||
foreach(QString configName, configs) {
|
||||
qDebug() << "Loading config: " << classId << "," << configName;
|
||||
qDebug().nospace() << "Loading config: " << classId << ", " << configName;
|
||||
qs->beginGroup(configName);
|
||||
bool locked = qs->value("config.locked").toBool();
|
||||
configInfo.setNameOfConfigurable(classId + "-" + configName);
|
||||
|
Loading…
x
Reference in New Issue
Block a user