Re #3026: add Clear to the flight mode (context menu on the Name label) (ported from master b0d3ae26)
This commit is contained in:
@@ -52,7 +52,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="labelName">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Name</string>
|
<string>Name</string>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ FlightModePanel::FlightModePanel(QWidget * parent, ModelData & model, int phaseI
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
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);
|
int modesCount = firmware->getCapability(FlightModes);
|
||||||
|
|
||||||
// Phase name
|
// 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):
|
FlightModesPanel::FlightModesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware):
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ class FlightModePanel : public ModelPanel
|
|||||||
void phaseGVPopupToggled(bool checked);
|
void phaseGVPopupToggled(bool checked);
|
||||||
void phaseREValue_editingFinished();
|
void phaseREValue_editingFinished();
|
||||||
void phaseREUse_currentIndexChanged(int index);
|
void phaseREUse_currentIndexChanged(int index);
|
||||||
|
void name_customContextMenuRequested(const QPoint & pos);
|
||||||
|
void fmClear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::FlightMode *ui;
|
Ui::FlightMode *ui;
|
||||||
|
|||||||
Reference in New Issue
Block a user