1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

OP-1756 Added handling for svg item highlight when calibrating all motors.

This commit is contained in:
m_thread 2015-03-01 12:12:50 +01:00
parent c2c5d41311
commit 662f1fb3f3
3 changed files with 28 additions and 2 deletions

View File

@ -43,6 +43,8 @@ OutputCalibrationPage::OutputCalibrationPage(SetupWizard *wizard, QWidget *paren
qDebug() << "calling output calibration page";
m_vehicleRenderer = new QSvgRenderer();
connect(ui->calibrateAllMotors, SIGNAL(toggled(bool)), this, SLOT(calibrateAllMotorsChanged()));
// move the code that was here to setupVehicle() so we can determine which image to use.
m_vehicleScene = new QGraphicsScene(this);
ui->vehicleView->setScene(m_vehicleScene);
@ -308,6 +310,7 @@ void OutputCalibrationPage::setupVehicleItems()
void OutputCalibrationPage::startWizard()
{
ui->calibrationStack->setCurrentIndex(m_wizardIndexes[0]);
enableAllMotorsCheckBox(true);
setupVehicleHighlightedPart();
}
@ -319,7 +322,11 @@ void OutputCalibrationPage::setupVehicleHighlightedPart()
for (int i = 0; i < m_vehicleItems.size(); i++) {
QGraphicsSvgItem *item = m_vehicleItems[i];
item->setOpacity((highlightedIndex == i) ? highlightOpaque : dimOpaque);
if (highlightedIndex == i || (ui->calibrateAllMotors->isChecked() && m_wizardIndexes[m_currentWizardIndex] == 1)) {
item->setOpacity(highlightOpaque);
} else {
item->setOpacity(dimOpaque);
}
}
}
@ -421,12 +428,24 @@ quint16 OutputCalibrationPage::getCurrentChannel()
return m_channelIndex[m_currentWizardIndex];
}
void OutputCalibrationPage::enableAllMotorsCheckBox(bool enable)
{
if (getWizard()->getVehicleType() == SetupWizard::VEHICLE_MULTI) {
ui->calibrateAllMotors->setVisible(true);
ui->calibrateAllMotors->setEnabled(enable);
} else {
ui->calibrateAllMotors->setChecked(false);
ui->calibrateAllMotors->setVisible(false);
}
}
void OutputCalibrationPage::enableButtons(bool enable)
{
getWizard()->button(QWizard::NextButton)->setEnabled(enable);
getWizard()->button(QWizard::CustomButton1)->setEnabled(enable);
getWizard()->button(QWizard::CancelButton)->setEnabled(enable);
getWizard()->button(QWizard::BackButton)->setEnabled(enable);
enableAllMotorsCheckBox(enable);
QApplication::processEvents();
}
@ -651,6 +670,11 @@ void OutputCalibrationPage::on_reverseCheckbox_toggled(bool checked)
}
}
void OutputCalibrationPage::on_calibrateAllMotors_toggled(bool checked)
{
setupVehicleHighlightedPart();
}
void OutputCalibrationPage::resetOutputCalibrationUtil()
{
if (m_calibrationUtil) {

View File

@ -70,6 +70,7 @@ private slots:
void on_servoMinAngleSlider_valueChanged(int position);
void on_servoMaxAngleSlider_valueChanged(int position);
void on_reverseCheckbox_toggled(bool checked);
void on_calibrateAllMotors_toggled(bool checked);
private:
void setupVehicle();
@ -83,6 +84,7 @@ private:
bool checkAlarms();
void debugLogChannelValues();
quint16 getCurrentChannel();
void enableAllMotorsCheckBox(bool enable);
Ui::OutputCalibrationPage *ui;
QSvgRenderer *m_vehicleRenderer;

View File

@ -124,7 +124,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_all_motor_outputs">
<widget class="QCheckBox" name="calibrateAllMotors">
<property name="text">
<string>Calibrate all motor outputs at the same time</string>
</property>