chore(cpn): move global variables from flight/drive modes tab to own tab (#6624)
This commit is contained in:
@@ -9,6 +9,7 @@ set(${PROJECT_NAME}_NAMES
|
||||
customfunctions
|
||||
expodialog
|
||||
flightmodes
|
||||
gvars
|
||||
inputs
|
||||
heli
|
||||
logicalswitches
|
||||
|
||||
@@ -333,7 +333,7 @@ CustomScreenPanel::CustomScreenPanel(QWidget * parent, ModelData & model, int in
|
||||
str = tr("Top bar");
|
||||
break;
|
||||
case LAYOUT_OPTION_FM:
|
||||
str = tr("%1 mode").arg(Boards::getRadioTypeString(firmware->getBoard()));
|
||||
str = tr("%1 mode").arg(Boards::getRadioModeString(firmware->getBoard()));
|
||||
break;
|
||||
case LAYOUT_OPTION_SLIDERS:
|
||||
str = tr("Sliders");
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>610</width>
|
||||
<height>499</height>
|
||||
<height>593</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -61,7 +61,7 @@
|
||||
<item row="0" column="6" rowspan="2">
|
||||
<spacer name="spacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -88,7 +88,7 @@
|
||||
<item row="0" column="4">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -101,10 +101,10 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QSlider" name="trim2Slider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
<enum>QSlider::TickPosition::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>25</number>
|
||||
@@ -114,7 +114,7 @@
|
||||
<item row="0" column="3">
|
||||
<widget class="QSlider" name="trim3Slider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
@@ -123,7 +123,7 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
<enum>QSlider::TickPosition::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>25</number>
|
||||
@@ -133,10 +133,10 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
<enum>QFrame::Shape::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
<enum>QFrame::Shadow::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
@@ -146,7 +146,7 @@
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3c_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -162,7 +162,7 @@
|
||||
<item>
|
||||
<widget class="QSpinBox" name="trim2Value">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
@@ -178,7 +178,7 @@
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4a_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -195,7 +195,7 @@
|
||||
<item>
|
||||
<spacer name="verticalSpacer_5b_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -211,7 +211,7 @@
|
||||
<item>
|
||||
<widget class="QSpinBox" name="trim1Value">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
@@ -227,7 +227,7 @@
|
||||
<item>
|
||||
<spacer name="verticalSpacer_6b_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -245,7 +245,7 @@
|
||||
<string notr="true">trim2</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -255,7 +255,7 @@
|
||||
<string notr="true">trim1</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -273,10 +273,10 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
<enum>QSlider::TickPosition::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>25</number>
|
||||
@@ -292,10 +292,10 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
<enum>QSlider::TickPosition::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>25</number>
|
||||
@@ -305,10 +305,10 @@
|
||||
<item row="0" column="2">
|
||||
<widget class="QFrame" name="frame_2">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
<enum>QFrame::Shape::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
<enum>QFrame::Shadow::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
@@ -319,7 +319,7 @@
|
||||
<string notr="true">trim4</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -328,7 +328,7 @@
|
||||
<item>
|
||||
<spacer name="verticalSpacer_9d_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -344,7 +344,7 @@
|
||||
<item>
|
||||
<widget class="QSpinBox" name="trim4Value">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
@@ -360,7 +360,7 @@
|
||||
<item>
|
||||
<spacer name="verticalSpacer_10c_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -377,7 +377,7 @@
|
||||
<item>
|
||||
<spacer name="verticalSpacer_7b_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -393,7 +393,7 @@
|
||||
<item>
|
||||
<widget class="QSpinBox" name="trim3Value">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
@@ -409,7 +409,7 @@
|
||||
<item>
|
||||
<spacer name="verticalSpacer_8d_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -427,7 +427,7 @@
|
||||
<string notr="true">trim3</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -444,7 +444,7 @@
|
||||
<string>trim6</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -456,7 +456,7 @@
|
||||
<item>
|
||||
<widget class="QSpinBox" name="trim6Value">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
@@ -474,10 +474,10 @@
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
<enum>QSizePolicy::Policy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -492,10 +492,10 @@
|
||||
<item row="4" column="2">
|
||||
<widget class="QSlider" name="trim6Slider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
<enum>QSlider::TickPosition::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>25</number>
|
||||
@@ -510,7 +510,7 @@
|
||||
<string>trim8</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -522,7 +522,7 @@
|
||||
<item>
|
||||
<widget class="QSpinBox" name="trim8Value">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
@@ -540,10 +540,10 @@
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
<enum>QSizePolicy::Policy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -558,10 +558,10 @@
|
||||
<item row="6" column="2">
|
||||
<widget class="QSlider" name="trim8Slider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
<enum>QSlider::TickPosition::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>25</number>
|
||||
@@ -571,10 +571,10 @@
|
||||
<item row="4" column="1">
|
||||
<widget class="QSlider" name="trim5Slider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
<enum>QSlider::TickPosition::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>25</number>
|
||||
@@ -589,7 +589,7 @@
|
||||
<string>trim5</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -601,7 +601,7 @@
|
||||
<item>
|
||||
<widget class="QSpinBox" name="trim5Value">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
@@ -619,10 +619,10 @@
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
<enum>QSizePolicy::Policy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -637,10 +637,10 @@
|
||||
<item row="6" column="1">
|
||||
<widget class="QSlider" name="trim7Slider">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBothSides</enum>
|
||||
<enum>QSlider::TickPosition::TicksBothSides</enum>
|
||||
</property>
|
||||
<property name="tickInterval">
|
||||
<number>25</number>
|
||||
@@ -655,7 +655,7 @@
|
||||
<string>trim7</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -667,7 +667,7 @@
|
||||
<item>
|
||||
<widget class="QSpinBox" name="trim7Value">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
@@ -685,10 +685,10 @@
|
||||
<item row="0" column="1">
|
||||
<spacer name="verticalSpacer_11">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
<enum>QSizePolicy::Policy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -702,23 +702,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gvNreLayout" columnstretch="1,1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="gvGB"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="reGB"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -41,14 +41,16 @@ class FlightModePanel : public ModelPanel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FlightModePanel(QWidget *parent, ModelData &model, int modeIdx, GeneralSettings & generalSettings, Firmware * firmware,
|
||||
FilteredItemModel * rawSwitchFilteredModel, QString radioType);
|
||||
FlightModePanel(QWidget *parent, ModelData &model, int modeIdx,
|
||||
GeneralSettings & generalSettings,
|
||||
Firmware * firmware,
|
||||
FilteredItemModel * rawSwitchFilteredModel,
|
||||
QString radioMode);
|
||||
virtual ~FlightModePanel();
|
||||
|
||||
virtual void update();
|
||||
|
||||
signals:
|
||||
void gvNameChanged();
|
||||
void phaseDataChanged();
|
||||
void phaseNameChanged();
|
||||
void phaseSwitchChanged();
|
||||
@@ -64,16 +66,6 @@ class FlightModePanel : public ModelPanel
|
||||
void phaseTrimUse_currentIndexChanged(int index);
|
||||
void phaseTrim_valueChanged();
|
||||
void phaseTrimSlider_valueChanged();
|
||||
void GVName_editingFinished();
|
||||
void phaseGVValue_editingFinished();
|
||||
void phaseGVUse_currentIndexChanged(int index);
|
||||
void phaseGVPopupToggled(bool checked);
|
||||
void phaseGVUnit_currentIndexChanged(int index);
|
||||
void phaseGVPrec_currentIndexChanged(int index);
|
||||
void phaseGVMin_editingFinished();
|
||||
void phaseGVMax_editingFinished();
|
||||
void phaseREValue_editingFinished();
|
||||
void phaseREUse_currentIndexChanged(int index);
|
||||
void onCustomContextMenuRequested(QPoint pos);
|
||||
void cmClear(bool prompt = true);
|
||||
void cmClearAll();
|
||||
@@ -84,16 +76,6 @@ class FlightModePanel : public ModelPanel
|
||||
void cmPaste();
|
||||
void cmMoveDown();
|
||||
void cmMoveUp();
|
||||
void gvOnCustomContextMenuRequested(QPoint pos);
|
||||
void gvCmClear(bool prompt = true);
|
||||
void gvCmClearAll();
|
||||
void gvCmCopy();
|
||||
void gvCmCut();
|
||||
void gvCmDelete();
|
||||
void gvCmInsert();
|
||||
void gvCmPaste();
|
||||
void gvCmMoveDown();
|
||||
void gvCmMoveUp();
|
||||
void onItemModelAboutToBeUpdated();
|
||||
void onItemModelUpdateComplete();
|
||||
|
||||
@@ -102,49 +84,22 @@ class FlightModePanel : public ModelPanel
|
||||
int phaseIdx;
|
||||
FlightModeData & phase;
|
||||
int fmCount;
|
||||
int reCount;
|
||||
int gvCount;
|
||||
int gvIdx;
|
||||
int trimCount;
|
||||
int gvCount;
|
||||
QVector<QLabel *> trimsLabel;
|
||||
QLineEdit * gvNames[CPN_MAX_GVARS];
|
||||
QDoubleSpinBox * gvValues[CPN_MAX_GVARS];
|
||||
QCheckBox * gvPopups[CPN_MAX_GVARS];
|
||||
QComboBox * gvUse[CPN_MAX_GVARS];
|
||||
QComboBox * gvUnit[CPN_MAX_GVARS];
|
||||
QComboBox * gvPrec[CPN_MAX_GVARS];
|
||||
QDoubleSpinBox * gvMin[CPN_MAX_GVARS];
|
||||
QDoubleSpinBox * gvMax[CPN_MAX_GVARS];
|
||||
QSpinBox * reValues[CPN_MAX_ENCODERS];
|
||||
QComboBox * reUse[CPN_MAX_ENCODERS];
|
||||
QVector<QComboBox *> trimsUse;
|
||||
QVector<QSpinBox *> trimsValue;
|
||||
QVector<QSlider *> trimsSlider;
|
||||
Board::Type board;
|
||||
QString radioType;
|
||||
QString radioMode;
|
||||
|
||||
void trimUpdate(unsigned int trim);
|
||||
void updateGVar(int index);
|
||||
void updateRotaryEncoder(int index);
|
||||
void setGVSB(QDoubleSpinBox * spinBox, int min, int max, int val);
|
||||
void populateGvarUnitCB(QComboBox * cb);
|
||||
void populateGvarPrecCB(QComboBox * cb);
|
||||
bool hasClipboardData(QByteArray * data = nullptr) const;
|
||||
bool insertAllowed() const;
|
||||
bool moveDownAllowed() const;
|
||||
bool moveUpAllowed() const;
|
||||
void swapData(int idx1, int idx2);
|
||||
bool gvHasClipboardData() const;
|
||||
bool gvHasDefnClipboardData(QByteArray * data = nullptr) const;
|
||||
bool gvHasValueClipboardData(QByteArray * data = nullptr) const;
|
||||
bool gvHasAllValuesClipboardData(QByteArray * data = nullptr) const;
|
||||
bool gvDeleteAllowed() const;
|
||||
bool gvInsertAllowed() const;
|
||||
bool gvMoveDownAllowed() const;
|
||||
bool gvMoveUpAllowed() const;
|
||||
void gvSwapData(int idx1, int idx2);
|
||||
void connectItemModelEvents(const FilteredItemModel * itemModel);
|
||||
void populateGvarUseCB(QComboBox *b, unsigned int phase);
|
||||
};
|
||||
|
||||
class FlightModesPanel : public ModelPanel
|
||||
@@ -152,7 +107,11 @@ class FlightModesPanel : public ModelPanel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FlightModesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware, CompoundItemModelFactory * sharedItemModels);
|
||||
FlightModesPanel(QWidget *parent, ModelData & model,
|
||||
GeneralSettings & generalSettings,
|
||||
Firmware * firmware,
|
||||
CompoundItemModelFactory * sharedItemModels,
|
||||
QString radioModes);
|
||||
virtual ~FlightModesPanel();
|
||||
|
||||
public slots:
|
||||
@@ -177,7 +136,7 @@ class FlightModesPanel : public ModelPanel
|
||||
CompoundItemModelFactory *sharedItemModels;
|
||||
FilteredItemModel *rawSwitchFilteredModel;
|
||||
QVector<GenericPanel *> panels;
|
||||
QString radioType;
|
||||
QString radioMode;
|
||||
|
||||
void updateItemModels();
|
||||
void connectItemModelEvents(const FilteredItemModel * itemModel);
|
||||
|
||||
@@ -0,0 +1,620 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "gvars.h"
|
||||
#include "gvardata.h"
|
||||
#include "flightmodedata.h"
|
||||
#include "filtereditemmodels.h"
|
||||
#include "eeprominterface.h"
|
||||
#include "helpers.h"
|
||||
#include "namevalidator.h"
|
||||
|
||||
GlobalVariablesPanel::GlobalVariablesPanel(QWidget * parent, ModelData & model,
|
||||
GeneralSettings & generalSettings,
|
||||
Firmware * firmware,
|
||||
CompoundItemModelFactory * sharedItemModels) :
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
sharedItemModels(sharedItemModels),
|
||||
selectedIndex(0),
|
||||
modelsUpdateCnt(0),
|
||||
gvars(firmware->getCapability(Gvars)),
|
||||
modes(firmware->getCapability(FlightModes)),
|
||||
modeName(FlightModeData::modeName()),
|
||||
modePrefix(FlightModeData::modeAbbrev())
|
||||
{
|
||||
AbstractStaticItemModel *unitItemModel = GVarData::unitItemModel();
|
||||
AbstractStaticItemModel *precItemModel = GVarData::precItemModel();
|
||||
CompoundItemModelFactory *gvarModesIMF = new CompoundItemModelFactory(&generalSettings, &model);
|
||||
|
||||
int firstmidx = 0;
|
||||
for (int i = 0; i < modes; i++) {
|
||||
int id = gvarModesIMF->registerItemModel(FlightModeData::gvarModesItemModel(i));
|
||||
if (i == 0)
|
||||
firstmidx = id;
|
||||
}
|
||||
|
||||
// add mode headers post table construction as they span columns
|
||||
QStringList headerLabels;
|
||||
headerLabels << "#" << tr("Name") << tr("Unit") << tr("Prec") << tr("Min")
|
||||
<< tr("Max") << tr("Popup");
|
||||
|
||||
tableLayout = new TableLayout(this, gvars, headerLabels);
|
||||
|
||||
for (int i = 0; i < gvars; i++) {
|
||||
int col = 0;
|
||||
// label
|
||||
QLabel *label = new QLabel(this);
|
||||
label->setText(tr("GV%1").arg(i + 1));
|
||||
label->setProperty("index", i);
|
||||
label->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
label->setToolTip(tr("Popup menu available"));
|
||||
label->setMouseTracking(true);
|
||||
label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
|
||||
connect(label, &QWidget::customContextMenuRequested, this,
|
||||
&GlobalVariablesPanel::onCustomContextMenuRequested);
|
||||
tableLayout->addWidget(i, col++, label);
|
||||
|
||||
// name
|
||||
leName[i] = new QLineEdit(this);
|
||||
QLineEdit *name = leName[i];
|
||||
name->setProperty("index", i);
|
||||
name->setValidator(new NameValidator(firmware->getBoard(), this));
|
||||
name->setMaxLength(firmware->getCapability(GvarsName));
|
||||
connect(name, &QLineEdit::editingFinished, this, &GlobalVariablesPanel::nameEditingFinished);
|
||||
tableLayout->addWidget(i, col++, name);
|
||||
|
||||
// unit
|
||||
cboUnit[i] = new QComboBox(this);
|
||||
QComboBox *unit = cboUnit[i];
|
||||
unit->setProperty("index", i);
|
||||
unit->setModel(unitItemModel);
|
||||
connect(unit, &QComboBox::currentIndexChanged, this, &GlobalVariablesPanel::unitCurrentIndexChanged);
|
||||
tableLayout->addWidget(i, col++, unit);
|
||||
|
||||
// precision
|
||||
cboPrec[i] = new QComboBox(this);
|
||||
QComboBox *prec = cboPrec[i];
|
||||
prec->setProperty("index", i);
|
||||
prec->setModel(precItemModel);
|
||||
connect(prec, &QComboBox::currentIndexChanged, this, &GlobalVariablesPanel::precCurrentIndexChanged);
|
||||
tableLayout->addWidget(i, col++, prec);
|
||||
|
||||
// min
|
||||
dsbMin[i] = new QDoubleSpinBox(this);
|
||||
QDoubleSpinBox *min = dsbMin[i];
|
||||
min->setProperty("index", i);
|
||||
connect(min, &QDoubleSpinBox::editingFinished, this, &GlobalVariablesPanel::minEditingFinished);
|
||||
tableLayout->addWidget(i, col++, min);
|
||||
|
||||
// max
|
||||
dsbMax[i] = new QDoubleSpinBox(this);
|
||||
QDoubleSpinBox *max = dsbMax[i];
|
||||
max->setProperty("index", i);
|
||||
connect(max, &QDoubleSpinBox::editingFinished, this, &GlobalVariablesPanel::maxEditingFinished);
|
||||
tableLayout->addWidget(i, col++, max);
|
||||
|
||||
// popup
|
||||
chkPopup[i] = new QCheckBox(this);
|
||||
QCheckBox *popup = chkPopup[i];
|
||||
popup->setProperty("index", i);
|
||||
connect(popup, &QCheckBox::toggled, this, &GlobalVariablesPanel::popupToggled);
|
||||
tableLayout->addWidget(i, col++, popup, Qt::AlignHCenter);
|
||||
|
||||
// radio modes (drive/flight)
|
||||
for (int j = 0; j < modes; j++) {
|
||||
if (j > 0) {
|
||||
// use mode
|
||||
chkUseMode[i][j] = new QCheckBox(tr("%1M").arg(modePrefix),this);
|
||||
QCheckBox *usemode = chkUseMode[i][j];
|
||||
setIndexes(usemode, i, j);
|
||||
connect(usemode, &QCheckBox::toggled, this, &GlobalVariablesPanel::useModeToggled);
|
||||
tableLayout->addWidget(i, col++, usemode, Qt::AlignHCenter);
|
||||
|
||||
// mode
|
||||
cboMode[i][j] = new QComboBox(this);
|
||||
QComboBox *mode = cboMode[i][j];
|
||||
setIndexes(mode, i, j);
|
||||
mode->setModel(gvarModesIMF->getItemModel(firstmidx + j));
|
||||
connect(mode, &QComboBox::currentIndexChanged, this, &GlobalVariablesPanel::modeCurrentIndexChanged);
|
||||
tableLayout->addWidget(i, col, mode); // do not increment col as either cboMode or dsbValue visible
|
||||
}
|
||||
|
||||
// value
|
||||
dsbValue[i][j] = new QDoubleSpinBox(this);
|
||||
QDoubleSpinBox *value = dsbValue[i][j];
|
||||
setIndexes(value, i, j);
|
||||
connect(value, &QDoubleSpinBox::editingFinished, this, &GlobalVariablesPanel::valueEditingFinished);
|
||||
tableLayout->addWidget(i, col++, value);
|
||||
}
|
||||
}
|
||||
|
||||
int col = headerLabels.size();
|
||||
|
||||
for (int i = 0; i < modes; i++) {
|
||||
int colspan = i > 0 ? 2 : 1;
|
||||
tableLayout->addColumnHead(model.flightModeData[i].nameToString(i), col, colspan);
|
||||
col += colspan;
|
||||
}
|
||||
|
||||
disableMouseScrolling();
|
||||
tableLayout->resizeColumnsToContents();
|
||||
tableLayout->pushRowsUp(gvars + 1);
|
||||
tableLayout->pushColumnsLeft(col);
|
||||
}
|
||||
|
||||
GlobalVariablesPanel::~GlobalVariablesPanel()
|
||||
{
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::cmClear(bool prompt)
|
||||
{
|
||||
if (prompt) {
|
||||
if (QMessageBox::question(this, tr("Edit Global Variables"),
|
||||
tr("Clear global variable #%1. Are you sure?").arg(selectedIndex + 1),
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
||||
return;
|
||||
}
|
||||
|
||||
model->gvarClear(selectedIndex);
|
||||
updateLine(selectedIndex);
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::cmClearAll()
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Edit Global Variables"),
|
||||
tr("Clear all global variables. Are you sure?"),
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < gvars; i++) {
|
||||
model->gvarClear(i);
|
||||
}
|
||||
|
||||
update();
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::cmCopy()
|
||||
{
|
||||
QByteArray data;
|
||||
QDataStream stream(&data, QIODevice::WriteOnly);
|
||||
stream << model->gvarData[selectedIndex];
|
||||
|
||||
for (int j = 0; j < modes; j++) {
|
||||
stream << model->flightModeData[j].gvars[selectedIndex];
|
||||
}
|
||||
|
||||
QMimeData *mimeData = new QMimeData;
|
||||
mimeData->setData(MIMETYPE_GLOBAL_VARIABLE, data);
|
||||
QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::cmCut()
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Edit Global Variables"),
|
||||
tr("Cut global variable #%1. Are you sure?").arg(selectedIndex + 1),
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
||||
return;
|
||||
|
||||
cmCopy();
|
||||
cmClear(false);
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::cmDelete()
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Edit Global Variables"),
|
||||
tr("Delete global variable #%1. Are you sure?").arg(selectedIndex + 1),
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
||||
return;
|
||||
|
||||
model->gvarDelete(selectedIndex);
|
||||
|
||||
for (int i = selectedIndex; i < gvars; i++) {
|
||||
updateLine(i);
|
||||
}
|
||||
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::cmInsert()
|
||||
{
|
||||
model->gvarInsert(selectedIndex);
|
||||
|
||||
for (int i = selectedIndex; i < gvars; i++) {
|
||||
updateLine(i);
|
||||
}
|
||||
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::cmMoveDown()
|
||||
{
|
||||
swapData(selectedIndex, selectedIndex + 1);
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::cmMoveUp()
|
||||
{
|
||||
swapData(selectedIndex, selectedIndex - 1);
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::cmPaste()
|
||||
{
|
||||
QByteArray data;
|
||||
if (hasClipboardData(&data)) {
|
||||
QDataStream stream(&data, QIODevice::ReadOnly);
|
||||
stream >> model->gvarData[selectedIndex];
|
||||
|
||||
for (int j = 0; j < modes; j++) {
|
||||
stream >> model->flightModeData[j].gvars[selectedIndex];
|
||||
}
|
||||
|
||||
updateLine(selectedIndex);
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::connectItemModelEvents(const FilteredItemModel * itemModel)
|
||||
{
|
||||
connect(itemModel, &FilteredItemModel::aboutToBeUpdated, this,
|
||||
&GlobalVariablesPanel::onItemModelAboutToBeUpdated);
|
||||
connect(itemModel, &FilteredItemModel::updateComplete, this,
|
||||
&GlobalVariablesPanel::onItemModelUpdateComplete);
|
||||
}
|
||||
|
||||
bool GlobalVariablesPanel::deleteAllowed() const
|
||||
{
|
||||
return selectedIndex < gvars - 1;
|
||||
}
|
||||
|
||||
bool GlobalVariablesPanel::getIndexes(QWidget * widget, int &gvarIdx, int &modeIdx) {
|
||||
bool ok = false;
|
||||
unsigned int i = (unsigned int)widget->property("index").toInt(&ok);
|
||||
|
||||
if (!ok)
|
||||
return false;
|
||||
|
||||
modeIdx = (int)Helpers::getBitmappedValue(i, 0, 8);
|
||||
gvarIdx = (int)Helpers::getBitmappedValue(i, 1, 8);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GlobalVariablesPanel::hasClipboardData(QByteArray * data) const
|
||||
{
|
||||
const QClipboard * clipboard = QApplication::clipboard();
|
||||
const QMimeData * mimeData = clipboard->mimeData();
|
||||
|
||||
if (mimeData->hasFormat(MIMETYPE_GLOBAL_VARIABLE)) {
|
||||
if (data) {
|
||||
data->append(mimeData->data(MIMETYPE_GLOBAL_VARIABLE));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::maxEditingFinished()
|
||||
{
|
||||
if (!lock) {
|
||||
QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox*>(sender());
|
||||
bool ok;
|
||||
int gidx = dsb->property("index").toInt(&ok);
|
||||
|
||||
if (ok) {
|
||||
model->gvarSetMax(gidx, dsb->value());
|
||||
updateLine(gidx);
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::minEditingFinished()
|
||||
{
|
||||
if (!lock) {
|
||||
QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox*>(sender());
|
||||
bool ok;
|
||||
int gidx = dsb->property("index").toInt(&ok);
|
||||
|
||||
if (ok) {
|
||||
model->gvarSetMin(gidx, dsb->value());
|
||||
updateLine(gidx);
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::modeCurrentIndexChanged(int index)
|
||||
{
|
||||
if (!lock) {
|
||||
QComboBox *cbo = qobject_cast<QComboBox*>(sender());
|
||||
int gidx = 0;
|
||||
int midx = 0;
|
||||
|
||||
if (getIndexes(cbo, gidx, midx)) {
|
||||
model->flightModeData[midx].gvars[gidx] = cbo->currentData().toInt();
|
||||
|
||||
if (model->isGVarLinkedCircular(midx, gidx)) {
|
||||
QMessageBox::warning(this, tr("Edit Global Variables"),
|
||||
tr("Warning: Global variable links back to itself, %1M0 used.")
|
||||
.arg(modePrefix));
|
||||
model->flightModeData[midx].gvars[gidx] =
|
||||
model->flightModeData->linkedGVarFlightModeZero(midx);
|
||||
}
|
||||
|
||||
updateLine(gidx);
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GlobalVariablesPanel::moveDownAllowed() const
|
||||
{
|
||||
return selectedIndex < gvars - 1;
|
||||
}
|
||||
|
||||
bool GlobalVariablesPanel::moveUpAllowed() const
|
||||
{
|
||||
return selectedIndex > 0;
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::nameEditingFinished()
|
||||
{
|
||||
if (!lock) {
|
||||
QLineEdit *lineedit = qobject_cast<QLineEdit*>(sender());
|
||||
bool ok;
|
||||
int gidx = lineedit->property("index").toInt(&ok);
|
||||
|
||||
if (ok) {
|
||||
memset(&model->gvarData[gidx].name, 0, sizeof(model->gvarData[gidx].name));
|
||||
strcpy(model->gvarData[gidx].name, lineedit->text().toLatin1());
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::onCustomContextMenuRequested(QPoint pos)
|
||||
{
|
||||
QLabel *label = (QLabel *)sender();
|
||||
selectedIndex = label->property("index").toInt();
|
||||
QPoint globalPos = label->mapToGlobal(pos);
|
||||
|
||||
QMenu contextMenu;
|
||||
contextMenu.addAction(CompanionIcon("copy.png"), tr("Copy"), this,
|
||||
SLOT(cmCopy()));
|
||||
contextMenu.addAction(CompanionIcon("cut.png"), tr("Cut"), this,
|
||||
SLOT(cmCut()));
|
||||
contextMenu.addAction(CompanionIcon("paste.png"), tr("Paste"), this,
|
||||
SLOT(cmPaste()))->setEnabled(hasClipboardData());
|
||||
contextMenu.addAction(CompanionIcon("clear.png"), tr("Clear"), this,
|
||||
SLOT(cmClear()));
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction(CompanionIcon("arrow-right.png"), tr("Insert"), this,
|
||||
SLOT(cmInsert()))->setEnabled(model->gvarInsertAllowed(selectedIndex));
|
||||
contextMenu.addAction(CompanionIcon("arrow-left.png"), tr("Delete"), this,
|
||||
SLOT(cmDelete()))->setEnabled(deleteAllowed());
|
||||
contextMenu.addAction(CompanionIcon("moveup.png"), tr("Move Up"), this,
|
||||
SLOT(cmMoveUp()))->setEnabled(moveUpAllowed());
|
||||
contextMenu.addAction(CompanionIcon("movedown.png"), tr("Move Down"), this,
|
||||
SLOT(cmMoveDown()))->setEnabled(moveDownAllowed());
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction(CompanionIcon("clear.png"), tr("Clear All"), this,
|
||||
SLOT(cmClearAll()));
|
||||
contextMenu.exec(globalPos);
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::onItemModelAboutToBeUpdated()
|
||||
{
|
||||
lock = true;
|
||||
modelsUpdateCnt++;
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::onItemModelUpdateComplete()
|
||||
{
|
||||
modelsUpdateCnt--;
|
||||
|
||||
if (modelsUpdateCnt < 1) {
|
||||
update();
|
||||
lock = false;
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::popupToggled(bool checked)
|
||||
{
|
||||
if (!lock) {
|
||||
QCheckBox *chk = qobject_cast<QCheckBox*>(sender());
|
||||
bool ok;
|
||||
int gidx = chk->property("index").toInt(&ok);
|
||||
|
||||
if (ok) {
|
||||
model->gvarData[gidx].popup = checked;
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::precCurrentIndexChanged(int index)
|
||||
{
|
||||
if (!lock) {
|
||||
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
|
||||
int gidx = comboBox->property("index").toInt();
|
||||
model->gvarData[gidx].prec = index;
|
||||
updateLine(gidx);
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::setIndexes(QWidget * widget, int gvarIdx, int modeIdx) {
|
||||
unsigned int i = 0;
|
||||
Helpers::setBitmappedValue(i, modeIdx, 0, 8);
|
||||
Helpers::setBitmappedValue(i, gvarIdx, 1, 8);
|
||||
widget->setProperty("index", i);
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::setMinMax(QDoubleSpinBox * dsb, int min, int max, int val)
|
||||
{
|
||||
bool ok;
|
||||
int gidx = dsb->property("index").toInt(&ok);
|
||||
|
||||
if (ok) {
|
||||
float mul = model->gvarData[gidx].multiplierGet();
|
||||
dsb->setDecimals(model->gvarData[gidx].prec);
|
||||
dsb->setSingleStep(mul);
|
||||
dsb->setSuffix(model->gvarData[gidx].unitToString());
|
||||
dsb->setMinimum(min * mul);
|
||||
dsb->setMaximum(max * mul);
|
||||
dsb->setValue(val * mul);
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::setValue(QDoubleSpinBox * dsb, int val)
|
||||
{
|
||||
int gidx = 0;
|
||||
int midx = 0;
|
||||
|
||||
if (getIndexes(dsb, gidx, midx)) {
|
||||
float mul = model->gvarData[gidx].multiplierGet();
|
||||
dsb->setDecimals(model->gvarData[gidx].prec);
|
||||
dsb->setSingleStep(mul);
|
||||
dsb->setSuffix(model->gvarData[gidx].unitToString());
|
||||
dsb->setMinimum(model->gvarData[gidx].getMinPrec());
|
||||
dsb->setMaximum(model->gvarData[gidx].getMaxPrec());
|
||||
dsb->setValue(val * mul);
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::swapData(int index1, int index2)
|
||||
{
|
||||
if ((index1 != index2)) {
|
||||
model->gvarSwap(index1, index2);
|
||||
updateLine(index1);
|
||||
updateLine(index2);
|
||||
updateItemModels();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::unitCurrentIndexChanged(int index)
|
||||
{
|
||||
if (!lock) {
|
||||
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
|
||||
int gidx = comboBox->property("index").toInt();
|
||||
model->gvarData[gidx].unit = index;
|
||||
updateLine(gidx);
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::update()
|
||||
{
|
||||
int col = 7;
|
||||
|
||||
for (int i = 0; i < CPN_MAX_FLIGHT_MODES; i++) {
|
||||
QString text(model->flightModeData[i].nameToString(i));
|
||||
tableLayout->updateColumnHeading(col, text);
|
||||
i == 0 ? col++ : col += 2;
|
||||
}
|
||||
|
||||
for (int i = 0; i < gvars; i++) {
|
||||
updateLine(i);
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::updateLine(int index)
|
||||
{
|
||||
if (index < 0 || index >= gvars)
|
||||
return;
|
||||
|
||||
lock = true;
|
||||
leName[index]->setText(model->gvarData[index].name);
|
||||
cboUnit[index]->setCurrentIndex(model->gvarData[index].unit);
|
||||
cboPrec[index]->setCurrentIndex(model->gvarData[index].prec);
|
||||
setMinMax(dsbMin[index], GVAR_MIN_VALUE, model->gvarData[index].getMax(),
|
||||
model->gvarData[index].getMin());
|
||||
setMinMax(dsbMax[index], model->gvarData[index].getMin(), GVAR_MAX_VALUE,
|
||||
model->gvarData[index].getMax());
|
||||
chkPopup[index]->setChecked(model->gvarData[index].popup);
|
||||
|
||||
for (int j = 0; j < modes; j++) {
|
||||
if (!model->isGVarLinked(j, index)) {
|
||||
if (j > 0) {
|
||||
chkUseMode[index][j]->setChecked(false);
|
||||
cboMode[index][j]->setCurrentIndex(0);
|
||||
cboMode[index][j]->setVisible(false);
|
||||
}
|
||||
|
||||
dsbValue[index][j]->setVisible(true);
|
||||
setValue(dsbValue[index][j], model->getGVarValue(j, index));
|
||||
} else {
|
||||
chkUseMode[index][j]->setChecked(true);
|
||||
cboMode[index][j]->setVisible(true);
|
||||
cboMode[index][j]->setCurrentIndex(cboMode[index][j]->findData(model->flightModeData[j].gvars[index]));
|
||||
dsbValue[index][j]->setValue(0);
|
||||
dsbValue[index][j]->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
lock = false;
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::updateItemModels()
|
||||
{
|
||||
sharedItemModels->update(AbstractItemModel::IMUE_GVars);
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::useModeToggled(bool checked)
|
||||
{
|
||||
if (!lock) {
|
||||
QCheckBox *chk = qobject_cast<QCheckBox*>(sender());
|
||||
int gidx = 0;
|
||||
int midx = 0;
|
||||
|
||||
if (getIndexes(chk, gidx, midx)) {
|
||||
int val = checked ? model->flightModeData->linkedGVarFlightModeZero(midx) : 0;
|
||||
model->flightModeData[midx].gvars[gidx] = val;
|
||||
updateLine(gidx);
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalVariablesPanel::valueEditingFinished()
|
||||
{
|
||||
if (!lock) {
|
||||
QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox*>(sender());
|
||||
int gidx = 0;
|
||||
int midx = 0;
|
||||
|
||||
if (getIndexes(dsb, gidx, midx)) {
|
||||
model->flightModeData[midx].gvars[gidx] = dsb->value() *
|
||||
model->gvarData[gidx].multiplierSet();
|
||||
updateLine(gidx);
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "constants.h"
|
||||
#include "boards.h"
|
||||
|
||||
class CompoundItemModelFactory;
|
||||
class FilteredItemModel;
|
||||
class TableLayout;
|
||||
|
||||
constexpr char MIMETYPE_GLOBAL_VARIABLE[] = "application/x-companion-global-variable";
|
||||
|
||||
class GlobalVariablesPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GlobalVariablesPanel(QWidget *parent, ModelData & model,
|
||||
GeneralSettings & generalSettings,
|
||||
Firmware * firmware,
|
||||
CompoundItemModelFactory * sharedItemModels);
|
||||
virtual ~GlobalVariablesPanel();
|
||||
|
||||
virtual void update();
|
||||
|
||||
private slots:
|
||||
void cmClear(bool prompt = true);
|
||||
void cmClearAll();
|
||||
void cmCopy();
|
||||
void cmCut();
|
||||
void cmDelete();
|
||||
void cmInsert();
|
||||
void cmMoveDown();
|
||||
void cmMoveUp();
|
||||
void cmPaste();
|
||||
void maxEditingFinished();
|
||||
void minEditingFinished();
|
||||
void modeCurrentIndexChanged(int index);
|
||||
void nameEditingFinished();
|
||||
void onCustomContextMenuRequested(QPoint pos);
|
||||
void onItemModelAboutToBeUpdated();
|
||||
void onItemModelUpdateComplete();
|
||||
void popupToggled(bool checked);
|
||||
void precCurrentIndexChanged(int index);
|
||||
void unitCurrentIndexChanged(int index);
|
||||
void useModeToggled(bool checked);
|
||||
void valueEditingFinished();
|
||||
|
||||
private:
|
||||
CompoundItemModelFactory *sharedItemModels;
|
||||
int selectedIndex;
|
||||
int modelsUpdateCnt;
|
||||
int gvars;
|
||||
int modes;
|
||||
QString modeName;
|
||||
QString modePrefix;
|
||||
|
||||
TableLayout *tableLayout;
|
||||
QLineEdit *leName[CPN_MAX_GVARS];
|
||||
QComboBox *cboUnit[CPN_MAX_GVARS];
|
||||
QComboBox *cboPrec[CPN_MAX_GVARS];
|
||||
QDoubleSpinBox *dsbMin[CPN_MAX_GVARS];
|
||||
QDoubleSpinBox *dsbMax[CPN_MAX_GVARS];
|
||||
QCheckBox *chkPopup[CPN_MAX_GVARS];
|
||||
QCheckBox *chkUseMode[CPN_MAX_GVARS][CPN_MAX_FLIGHT_MODES];
|
||||
QComboBox *cboMode[CPN_MAX_GVARS][CPN_MAX_FLIGHT_MODES];
|
||||
QDoubleSpinBox *dsbValue[CPN_MAX_GVARS][CPN_MAX_FLIGHT_MODES];
|
||||
|
||||
void connectItemModelEvents(const FilteredItemModel * itemModel);
|
||||
bool deleteAllowed() const;
|
||||
bool getIndexes(QWidget * widget, int &gvarIdx, int &modeIdx);
|
||||
bool hasClipboardData(QByteArray * data = nullptr) const;
|
||||
bool moveDownAllowed() const;
|
||||
bool moveUpAllowed() const;
|
||||
void setIndexes(QWidget * widget, int gvarIdx, int modeIdx);
|
||||
void setValue(QDoubleSpinBox * spinBox, int val);
|
||||
void setMinMax(QDoubleSpinBox * spinBox, int min, int max, int val);
|
||||
void swapData(int index1, int index2);
|
||||
void updateLine(const int index);
|
||||
void updateItemModels();
|
||||
};
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "mixes.h"
|
||||
#include "channels.h"
|
||||
#include "curves.h"
|
||||
#include "verticalscrollarea.h"
|
||||
#include "scrollarea.h"
|
||||
#include "logicalswitches.h"
|
||||
#include "customfunctions.h"
|
||||
#include "telemetry.h"
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "modeloptions.h"
|
||||
#include "appdata.h"
|
||||
#include "compounditemmodels.h"
|
||||
#include "gvars.h"
|
||||
|
||||
ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmware * firmware) :
|
||||
QDialog(parent),
|
||||
@@ -57,6 +58,7 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw
|
||||
|
||||
GeneralSettings &generalSettings = radioData.generalSettings;
|
||||
ModelData &model = radioData.models[modelId];
|
||||
QString radioMode = Boards::getRadioModeString(firmware->getBoard());
|
||||
|
||||
sharedItemModels = new CompoundItemModelFactory(&generalSettings, &model);
|
||||
sharedItemModels->addItemModel(AbstractItemModel::IMID_RawSource);
|
||||
@@ -81,10 +83,10 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw
|
||||
s1.report("Heli");
|
||||
}
|
||||
|
||||
QString radioType = QString(tr("%1 Modes").arg(Boards::getRadioTypeString(firmware->getBoard())));
|
||||
FlightModesPanel *flightModesPanel = new FlightModesPanel(this, model, generalSettings, firmware, sharedItemModels);
|
||||
addTab(flightModesPanel, radioType);
|
||||
s1.report(radioType);
|
||||
QString tabTitle = QString(tr("%1 Modes").arg(Boards::getRadioModeString(firmware->getBoard())));
|
||||
FlightModesPanel *flightModesPanel = new FlightModesPanel(this, model, generalSettings, firmware, sharedItemModels, radioMode);
|
||||
addTab(flightModesPanel, tabTitle);
|
||||
s1.report(tabTitle);
|
||||
|
||||
addTab(new InputsPanel(this, model, generalSettings, firmware, sharedItemModels), tr("Inputs"));
|
||||
s1.report("Inputs");
|
||||
@@ -99,6 +101,11 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw
|
||||
addTab(new CurvesPanel(this, model, generalSettings, firmware, sharedItemModels), tr("Curves"));
|
||||
s1.report("Curves");
|
||||
|
||||
if (firmware->getCapability(Gvars)) {
|
||||
addTab(new GlobalVariablesPanel(this, model, generalSettings, firmware, sharedItemModels), tr("Global Variables"));
|
||||
s1.report("Global Variables");
|
||||
}
|
||||
|
||||
addTab(new LogicalSwitchesPanel(this, model, generalSettings, firmware, sharedItemModels), tr("Logical Switches"));
|
||||
s1.report("Logical Switches");
|
||||
|
||||
@@ -149,7 +156,7 @@ void ModelEdit::addTab(GenericPanel *panel, QString text)
|
||||
panels << panel;
|
||||
QWidget * widget = new QWidget(ui->tabWidget);
|
||||
QVBoxLayout *baseLayout = new QVBoxLayout(widget);
|
||||
VerticalScrollArea * area = new VerticalScrollArea(widget, panel);
|
||||
ScrollArea * area = new ScrollArea(widget, panel);
|
||||
baseLayout->addWidget(area);
|
||||
ui->tabWidget->addTab(widget, text);
|
||||
connect(panel, &GenericPanel::modified, this, &ModelEdit::modified);
|
||||
|
||||
@@ -82,7 +82,7 @@ ModelOptionsPanel::ModelOptionsPanel(QWidget * parent, ModelData & model, Genera
|
||||
addParams();
|
||||
}
|
||||
|
||||
addLabel(tr("%1 Modes").arg(Boards::getRadioTypeString(firmware->getBoard())));
|
||||
addLabel(tr("%1 Modes").arg(Boards::getRadioModeString(firmware->getBoard())));
|
||||
AutoComboBox *fmDisable = new AutoComboBox(this);
|
||||
fmDisable->setModel(mdl);
|
||||
fmDisable->setField(model.modelFMDisabled, this);
|
||||
|
||||
@@ -199,8 +199,8 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
const int ttlFlexInputs = Boards::getBoardCapability(board, Board::FlexInputs);
|
||||
const int ttlInputs = ttlSticks + ttlFlexInputs;
|
||||
|
||||
for (int i = 0; i < ttlInputs + firmware->getCapability(RotaryEncoders); i++) {
|
||||
RawSource src((i < ttlInputs) ? SOURCE_TYPE_INPUT : SOURCE_TYPE_ROTARY_ENCODER, (i < ttlInputs) ? i + 1 : i - ttlInputs);
|
||||
for (int i = 0; i < ttlInputs; i++) {
|
||||
RawSource src(SOURCE_TYPE_INPUT, i + 1);
|
||||
QCheckBox * checkbox = new QCheckBox(this);
|
||||
checkbox->setProperty("index", i);
|
||||
checkbox->setText(src.toString(&model, &generalSettings));
|
||||
|
||||
Reference in New Issue
Block a user