31 #include <QtCore/QByteArray>
32 #include <QtCore/QDebug>
39 :
IUAVGadget(gadget->classId(), gadget->parent())
41 , m_toolbar(new QComboBox)
42 , m_activeConfiguration(nullptr)
43 , m_configurations(configurations)
45 m_gadget->setParent(
this);
46 m_toolbar->setMinimumContentsLength(15);
48 m_toolbar->addItem(config->
name());
53 if ((m_configurations->count() > 0) && loadDefault) {
64 delete m_configurations;
76 m_activeConfiguration = config;
77 int index = m_toolbar->findText(config->
name());
78 m_toolbar->setCurrentIndex(index);
84 if (config == m_activeConfiguration)
92 m_configurations->append(config);
93 m_toolbar->addItem(config->
name());
101 int index = m_configurations->indexOf(config);
103 m_toolbar->removeItem(index);
104 m_configurations->removeAt(index);
114 for (
int i = 0;
i < m_toolbar->count(); ++
i) {
115 if (m_toolbar->itemText(
i) == oldName)
116 m_toolbar->setItemText(
i, newName);
120 void UAVGadgetDecorator::updateToolbar()
122 m_toolbar->setEnabled(m_toolbar->count() > 1);
127 if (m_activeConfiguration) {
128 qSettings->setValue(
"activeConfiguration", m_activeConfiguration->
name());
134 QString configName = qSetting->value(
"activeConfiguration").toString();
136 if (config->
name() == configName) {
137 m_activeConfiguration = config;
void restoreState(QSettings *qSettings)
void loadConfiguration(IUAVGadgetConfiguration *config)
virtual void loadConfiguration(IUAVGadgetConfiguration *)
void configurationAdded(IUAVGadgetConfiguration *config)
void configurationChanged(IUAVGadgetConfiguration *config)
void configurationToBeDeleted(IUAVGadgetConfiguration *config)
void configurationNameChanged(IUAVGadgetConfiguration *config, QString oldName, QString newName)
UAVGadgetDecorator(IUAVGadget *gadget, QList< IUAVGadgetConfiguration * > *configurations, bool loadDefault=false)
void saveState(QSettings *qSettings)