Re #3026: add Clear to the flight mode (context menu on the Name label) (ported from master b0d3ae26)

This commit is contained in:
Damjan Adamic
2015-11-22 18:11:29 +01:00
parent 683f6e22e2
commit 18e36657f8
3 changed files with 29 additions and 1 deletions
+26
View File
@@ -15,6 +15,9 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
{
ui->setupUi(this);
ui->labelName->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->labelName, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(name_customContextMenuRequested(const QPoint &)));
int modesCount = firmware->getCapability(FlightModes);
// Phase name
@@ -426,6 +429,29 @@ void FlightModePanel::phaseTrimSlider_valueChanged()
}
}
void FlightModePanel::name_customContextMenuRequested(const QPoint & pos)
{
QLabel *label = (QLabel *)sender();
QPoint globalPos = label->mapToGlobal(pos);
QMenu contextMenu;
contextMenu.addAction(CompanionIcon("clear.png"), tr("&Clear"),this,SLOT(fmClear()),tr("Clear"));
contextMenu.exec(globalPos);
}
void FlightModePanel::fmClear()
{
int res = QMessageBox::question(this, "Companion", tr("Clear all current Flight Mode properties?"), QMessageBox::Yes | QMessageBox::No);
if (res == QMessageBox::Yes) {
phase.clear();
for(int i=0; i < 4; ++i) {
model->setTrimValue(phaseIdx, i, 0);
}
update();
emit modified();
emit nameModified();
}
}
/**********************************************************/
FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware):