mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +08:00
refs #273, completed / fixed component
* order, first add items to combobox, then connect signal (->no signals during setup) * renamed driver to plugin * improved plugin finding
This commit is contained in:
@@ -21,9 +21,6 @@ namespace BlackGui
|
|||||||
ui(new Ui::CSettingsSimulatorComponent)
|
ui(new Ui::CSettingsSimulatorComponent)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
bool connected = this->connect(this->ui->cb_SimulatorDriver, SIGNAL(currentIndexChanged(int)), this, SLOT(driverHasChanged(int)));
|
|
||||||
Q_ASSERT(connected);
|
|
||||||
Q_UNUSED(connected);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CSettingsSimulatorComponent::~CSettingsSimulatorComponent()
|
CSettingsSimulatorComponent::~CSettingsSimulatorComponent()
|
||||||
@@ -36,16 +33,24 @@ namespace BlackGui
|
|||||||
Q_ASSERT(this->getIContextSimulator());
|
Q_ASSERT(this->getIContextSimulator());
|
||||||
if (this->getIContextSimulator())
|
if (this->getIContextSimulator())
|
||||||
{
|
{
|
||||||
QStringList drivers = this->getIContextSimulator()->getAvailableSimulatorPlugins().toStringList(true);
|
QStringList plugins = this->getIContextSimulator()->getAvailableSimulatorPlugins().toStringList(true);
|
||||||
this->ui->cb_SimulatorDriver->addItems(drivers);
|
CSimulatorInfo currentDriver = this->getIContextSimulator()->getSimulatorInfo();
|
||||||
|
this->ui->cb_SimulatorDriver->addItems(plugins);
|
||||||
|
this->setCurrentPlugin(currentDriver);
|
||||||
|
|
||||||
|
// disable / enable driver specific GUI parts
|
||||||
bool fsxDriver =
|
bool fsxDriver =
|
||||||
this->getIContextSimulator()->getAvailableSimulatorPlugins().supportsSimulator(CSimulatorInfo::FSX());
|
this->getIContextSimulator()->getAvailableSimulatorPlugins().supportsSimulator(CSimulatorInfo::FSX());
|
||||||
this->ui->comp_SettingsSimulatorFsx->setVisible(fsxDriver);
|
this->ui->comp_SettingsSimulatorFsx->setVisible(fsxDriver);
|
||||||
|
|
||||||
|
// only with set GUI values
|
||||||
|
bool connected = this->connect(this->ui->cb_SimulatorDriver, SIGNAL(currentIndexChanged(int)), this, SLOT(pluginHasChanged(int)));
|
||||||
|
Q_ASSERT(connected);
|
||||||
|
Q_UNUSED(connected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingsSimulatorComponent::driverHasChanged(int index)
|
void CSettingsSimulatorComponent::pluginHasChanged(int index)
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->getIContextSimulator());
|
Q_ASSERT(this->getIContextSimulator());
|
||||||
Q_ASSERT(this->getIContextSettings());
|
Q_ASSERT(this->getIContextSettings());
|
||||||
@@ -71,4 +76,20 @@ namespace BlackGui
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSettingsSimulatorComponent::setCurrentPlugin(const CSimulatorInfo &driver)
|
||||||
|
{
|
||||||
|
if (driver.isUnspecified()) return;
|
||||||
|
const QString searchFor = driver.getShortName();
|
||||||
|
for (int i = 0; i < this->ui->cb_SimulatorDriver->count(); ++i)
|
||||||
|
{
|
||||||
|
const QString t = ui->cb_SimulatorDriver->itemText(i);
|
||||||
|
if (t.indexOf(searchFor, 0, Qt::CaseInsensitive) >= 0)
|
||||||
|
{
|
||||||
|
if (i == this->ui->cb_SimulatorDriver->currentIndex()) return;
|
||||||
|
this->ui->cb_SimulatorDriver->setCurrentIndex(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -28,10 +28,14 @@ namespace BlackGui
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//! Driver changed
|
//! Driver changed
|
||||||
void driverHasChanged(int index);
|
void pluginHasChanged(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::CSettingsSimulatorComponent *ui; //!< UI
|
Ui::CSettingsSimulatorComponent *ui; //!< UI
|
||||||
|
|
||||||
|
//! Smarter way to set current driver, avoids unnecessary signals and less formatting dependend
|
||||||
|
void setCurrentPlugin(const BlackSim::CSimulatorInfo &driver);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user