1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-20 14:55:13 +03:00

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

This commit is contained in:
Damjan Adamic 2015-11-22 12:37:19 +01:00
parent 682fa5dcf1
commit b0d3ae2605
3 changed files with 29 additions and 1 deletions

View file

@ -52,7 +52,7 @@
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<widget class="QLabel" name="labelName">
<property name="text">
<string>Name</string>
</property>

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):

View file

@ -41,6 +41,8 @@ class FlightModePanel : public ModelPanel
void phaseGVPopupToggled(bool checked);
void phaseREValue_editingFinished();
void phaseREUse_currentIndexChanged(int index);
void name_customContextMenuRequested(const QPoint & pos);
void fmClear();
private:
Ui::FlightMode *ui;