1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-30 08:24:11 +01:00

OP-803 fix attempt

This commit is contained in:
filnet 2013-01-16 23:43:22 +01:00
parent 481005cc69
commit 1e3aeaf988
4 changed files with 29 additions and 7 deletions

View File

@ -45,8 +45,8 @@ UAVGadgetDecorator::UAVGadgetDecorator(IUAVGadget *gadget, QList<IUAVGadgetConfi
foreach (IUAVGadgetConfiguration *config, *m_configurations)
m_toolbar->addItem(config->name());
connect(m_toolbar, SIGNAL(activated(int)), this, SLOT(loadConfiguration(int)));
if (m_configurations->count() > 0)
loadConfiguration(0);
// if (m_configurations->count() > 0)
// loadConfiguration(0);
updateToolbar();
}

View File

@ -253,13 +253,17 @@ void UAVGadgetInstanceManager::createOptionsPages()
}
IUAVGadget *UAVGadgetInstanceManager::createGadget(QString classId, QWidget *parent)
IUAVGadget *UAVGadgetInstanceManager::createGadget(QString classId, QWidget *parent, bool loadDefaultConfiguration)
{
IUAVGadgetFactory *f = factory(classId);
if (f) {
QList<IUAVGadgetConfiguration*> *configs = configurations(classId);
IUAVGadget *g = f->createGadget(parent);
IUAVGadget *gadget = new UAVGadgetDecorator(g, configs);
UAVGadgetDecorator *gadget = new UAVGadgetDecorator(g, configs);
if ((loadDefaultConfiguration && configs && configs->count()) > 0) {
gadget->loadConfiguration(configs->at(0));
}
m_gadgetInstances.append(gadget);
connect(this, SIGNAL(configurationAdded(IUAVGadgetConfiguration*)), gadget, SLOT(configurationAdded(IUAVGadgetConfiguration*)));
connect(this, SIGNAL(configurationChanged(IUAVGadgetConfiguration*)), gadget, SLOT(configurationChanged(IUAVGadgetConfiguration*)));

View File

@ -61,7 +61,7 @@ public:
~UAVGadgetInstanceManager();
void readSettings(QSettings *qs);
void saveSettings(QSettings *qs);
IUAVGadget *createGadget(QString classId, QWidget *parent);
IUAVGadget *createGadget(QString classId, QWidget *parent, bool loadDefaultConfiguration = true);
void removeGadget(IUAVGadget *gadget);
void removeAllGadgets();
bool canDeleteConfiguration(IUAVGadgetConfiguration *config);

View File

@ -265,11 +265,29 @@ void UAVGadgetView::saveState(QSettings* qSettings)
void UAVGadgetView::restoreState(QSettings* qSettings)
{
QString classId = qSettings->value("classId").toString();
int index = indexOfClassId(classId);
listSelectionActivated(index);
if (index < 0) {
index = m_defaultIndex;
}
classId = m_uavGadgetList->itemData(index).toString();
IUAVGadget *newGadget;
UAVGadgetInstanceManager *im = ICore::instance()->uavGadgetInstanceManager();
if(qSettings->childGroups().contains("gadget")) {
newGadget = im->createGadget(classId, this, false);
qSettings->beginGroup("gadget");
gadget()->restoreState(qSettings);
newGadget->restoreState(qSettings);
qSettings->endGroup();
}
else {
newGadget = im->createGadget(classId, this);
}
IUAVGadget *gadgetToRemove = m_uavGadget;
setGadget(newGadget);
m_uavGadgetManager->setCurrentGadget(newGadget);
im->removeGadget(gadgetToRemove);
}