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

GCS/coreplugin: Bugfix to uavgadget toolbar.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@391 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
ephy 2010-03-26 08:48:21 +00:00 committed by ephy
parent 31107be978
commit ad0382215f
3 changed files with 10 additions and 1 deletions

View File

@ -35,6 +35,7 @@ IUAVGadget::IUAVGadget(QString classId, QList<IUAVGadgetConfiguration*> *configu
IContext(parent),
m_toolbar(new QComboBox),
m_classId(classId),
m_activeConfiguration(0),
m_configurations(configurations)
{
m_toolbar->setMinimumContentsLength(15);
@ -43,6 +44,7 @@ IUAVGadget::IUAVGadget(QString classId, QList<IUAVGadgetConfiguration*> *configu
connect(m_toolbar, SIGNAL(activated(int)), this, SLOT(loadConfiguration(int)));
if (m_configurations->count() > 0)
loadConfiguration(0);
updateToolbar();
}
void IUAVGadget::loadConfiguration(int index) {
@ -69,6 +71,7 @@ void IUAVGadget::configurationAdded(IUAVGadgetConfiguration* config)
{
m_configurations->append(config);
m_toolbar->addItem(config->name());
updateToolbar();
}
void IUAVGadget::configurationToBeDeleted(IUAVGadgetConfiguration* config)
@ -78,6 +81,7 @@ void IUAVGadget::configurationToBeDeleted(IUAVGadgetConfiguration* config)
m_toolbar->removeItem(index);
m_configurations->removeAt(index);
}
updateToolbar();
}
void IUAVGadget::configurationNameChanged(QString oldName, QString newName)
@ -88,6 +92,11 @@ void IUAVGadget::configurationNameChanged(QString oldName, QString newName)
}
}
void IUAVGadget::updateToolbar()
{
m_toolbar->setEnabled(m_toolbar->count() > 1);
}
QByteArray IUAVGadget::saveState()
{
QByteArray bytes;

View File

@ -70,6 +70,7 @@ private slots:
protected:
QComboBox *m_toolbar;
private:
void updateToolbar();
QString m_classId;
IUAVGadgetConfiguration *m_activeConfiguration;
QList<IUAVGadgetConfiguration*> *m_configurations;

View File

@ -208,7 +208,6 @@ void UAVGadgetView::updateToolBar()
if (m_activeToolBar == toolBar)
return;
toolBar->setVisible(toolBar->count() > 0);
toolBar->setEnabled(toolBar->count() > 1);
m_toolBar->layout()->addWidget(toolBar);
m_activeToolBar->setVisible(false);
m_activeToolBar = toolBar;