feat: Add options to disable radio and model menu tabs (#3484)

* Add options to disable radio and model menu tabs.
- Update radio and model data structs
- UI for color LCD radios
- Convert existing 'noGlobalFunctions' property.
- Language strings.

* Make 'theme' control specific to color LCD radios.

* Add B&W radio UI.

* Simplify code, reduce compiled code size.
Fix page count display on model select tab.
Fix GVARS for 212x64 radios.

* Collapse timer sections if timer is off.

* Remove 'Use global functions' checkbox from B&W model setup.

* Make preflight checks, throttle and view options sections expand & collapse (default collapsed).

* Fix build.

* Add view options to companion data classes, save and load values in YAML files.
Fix scrolling for radio setup view options.

* Add Companion UI for view option settings.

* Remove 'Mixes' from list of tabs that can be hidden.

* Updated Companion UI from elecpower.

* Use view options flags to enable/disable functionality:
- skip heli mixer logic if heli not enabled
- Remove heli, gvars and telemetry options from source selection if not enabled

* Remove 'flight mode', 'curve' and 'global variable' settings from input & mix editors if option disabled.

* Rename 'View Options' to 'Enabled Features'.
Put GVAR option under Flight Mode and indent text.
Make relationship between FM and GV more obvious.

* Remove global variable option dependency on flight modes.
Hide FM1-FM8 in global variables if flight modes hidden.

* Hide 'Custom Mixer Scripts' in source selection menu popup if disabled.

* Add translation strings for Hebrew language file.

* Fix typo. Add comment for double call to setCurrentTab.
This commit is contained in:
philmoz
2023-05-22 20:08:16 +10:00
committed by GitHub
parent 04359757c4
commit 5327c890f2
98 changed files with 2459 additions and 452 deletions
@@ -286,6 +286,21 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
if (hasColorLcd)
node["selectedTheme"] = rhs.selectedTheme;
// Radio level tabs control (global settings)
if (hasColorLcd)
node["radioThemesDisabled"] = (int)rhs.radioThemesDisabled;
node["radioGFDisabled"] = (int)rhs.radioGFDisabled;
node["radioTrainerDisabled"] = (int)rhs.radioTrainerDisabled;
// Model level tabs control (global setting)
node["modelHeliDisabled"] = (int)rhs.modelHeliDisabled;
node["modelFMDisabled"] = (int)rhs.modelFMDisabled;
node["modelCurvesDisabled"] = (int)rhs.modelCurvesDisabled;
node["modelGVDisabled"] = (int)rhs.modelGVDisabled;
node["modelLSDisabled"] = (int)rhs.modelLSDisabled;
node["modelSFDisabled"] = (int)rhs.modelSFDisabled;
node["modelCustomScriptsDisabled"] = (int)rhs.modelCustomScriptsDisabled;
node["modelTelemetryDisabled"] = (int)rhs.modelTelemetryDisabled;
return node;
}
@@ -503,6 +518,20 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
node["selectedTheme"] >> rhs.selectedTheme;
// Radio level tabs control (global settings)
node["radioThemesDisabled"] >> rhs.radioThemesDisabled;
node["radioGFDisabled"] >> rhs.radioGFDisabled;
node["radioTrainerDisabled"] >> rhs.radioTrainerDisabled;
// Model level tabs control (global setting)
node["modelHeliDisabled"] >> rhs.modelHeliDisabled;
node["modelFMDisabled"] >> rhs.modelFMDisabled;
node["modelCurvesDisabled"] >> rhs.modelCurvesDisabled;
node["modelGVDisabled"] >> rhs.modelGVDisabled;
node["modelLSDisabled"] >> rhs.modelLSDisabled;
node["modelSFDisabled"] >> rhs.modelSFDisabled;
node["modelCustomScriptsDisabled"] >> rhs.modelCustomScriptsDisabled;
node["modelTelemetryDisabled"] >> rhs.modelTelemetryDisabled;
return true;
}
} // namespace YAML
@@ -74,7 +74,7 @@ static const YamlLookupTable potsWarningModeLut = {
{ 2, "WARN_AUTO" },
};
static const YamlLookupTable jitterFilterLut = {
static const YamlLookupTable globalOnOffFilterLut = {
{ 0, "GLOBAL" },
{ 1, "OFF" },
{ 2, "ON" },
@@ -782,6 +782,8 @@ Node convert<ModelData>::encode(const ModelData& rhs)
Node node;
auto board = getCurrentBoard();
bool hasColorLcd = Boards::getCapability(board, Board::HasColorLcd);
node["semver"] = VERSION;
Node header;
@@ -896,7 +898,7 @@ Node convert<ModelData>::encode(const ModelData& rhs)
node["thrTrimSw"] = rhs.thrTrimSwitch;
node["potsWarnMode"] = potsWarningModeLut << rhs.potsWarningMode;
node["jitterFilter"] = jitterFilterLut << rhs.jitterFilter;
node["jitterFilter"] = globalOnOffFilterLut << rhs.jitterFilter;
YamlPotsWarnEnabled potsWarnEnabled(&rhs.potsWarnEnabled[0]);
node["potsWarnEnabled"] = potsWarnEnabled.value;
@@ -943,7 +945,7 @@ Node convert<ModelData>::encode(const ModelData& rhs)
node["varioData"] = vario;
node["rssiSource"] = YamlTelemSource(rhs.rssiSource);
if (IS_TARANIS_X9(getCurrentBoard())) {
if (IS_TARANIS_X9(board)) {
node["voltsSource"] = YamlTelemSource(rhs.frsky.voltsSource);
node["altitudeSource"] = YamlTelemSource(rhs.frsky.altitudeSource);
}
@@ -986,7 +988,7 @@ Node convert<ModelData>::encode(const ModelData& rhs)
node["toplcdTimer"] = rhs.toplcdTimer;
}
if (IS_FAMILY_HORUS_OR_T16(getCurrentBoard())) {
if (IS_FAMILY_HORUS_OR_T16(board)) {
for (int i=0; i<MAX_CUSTOM_SCREENS; i++) {
const auto& csd = rhs.customScreens.customScreenData[i];
if (!csd.isEmpty()) {
@@ -1003,7 +1005,7 @@ Node convert<ModelData>::encode(const ModelData& rhs)
node["modelRegistrationID"] = rhs.registrationId;
if (Boards::getCapability(getCurrentBoard(), Board::FunctionSwitches)) {
if (Boards::getCapability(board, Board::FunctionSwitches)) {
node["functionSwitchConfig"] = rhs.functionSwitchConfig;
node["functionSwitchGroup"] = rhs.functionSwitchGroup;
node["functionSwitchStartConfig"] = rhs.functionSwitchStartConfig;
@@ -1026,6 +1028,21 @@ Node convert<ModelData>::encode(const ModelData& rhs)
}
}
// Radio level tabs control (global settings)
if (hasColorLcd)
node["radioThemesDisabled"] = globalOnOffFilterLut << rhs.radioThemesDisabled;
node["radioGFDisabled"] = globalOnOffFilterLut << rhs.radioGFDisabled;
node["radioTrainerDisabled"] = globalOnOffFilterLut << rhs.radioTrainerDisabled;
// Model level tabs control (global setting)
node["modelHeliDisabled"] = globalOnOffFilterLut << rhs.modelHeliDisabled;
node["modelFMDisabled"] = globalOnOffFilterLut << rhs.modelFMDisabled;
node["modelCurvesDisabled"] = globalOnOffFilterLut << rhs.modelCurvesDisabled;
node["modelGVDisabled"] = globalOnOffFilterLut << rhs.modelGVDisabled;
node["modelLSDisabled"] = globalOnOffFilterLut << rhs.modelLSDisabled;
node["modelSFDisabled"] = globalOnOffFilterLut << rhs.modelSFDisabled;
node["modelCustomScriptsDisabled"] = globalOnOffFilterLut << rhs.modelCustomScriptsDisabled;
node["modelTelemetryDisabled"] = globalOnOffFilterLut << rhs.modelTelemetryDisabled;
return node;
}
@@ -1099,7 +1116,7 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
node["thrTrimSw"] >> rhs.thrTrimSwitch;
node["potsWarnMode"] >> potsWarningModeLut >> rhs.potsWarningMode;
node["jitterFilter"] >> jitterFilterLut >> rhs.jitterFilter;
node["jitterFilter"] >> globalOnOffFilterLut >> rhs.jitterFilter;
YamlPotsWarnEnabled potsWarnEnabled;
node["potsWarnEnabled"] >> potsWarnEnabled.value;
@@ -1219,6 +1236,20 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
node["usbJoystickCircularCut"] >> rhs.usbJoystickCircularCut;
node["usbJoystickCh"] >> rhs.usbJoystickCh;
// Radio level tabs control (global settings)
node["radioThemesDisabled"] >> globalOnOffFilterLut >> rhs.radioThemesDisabled;
node["radioGFDisabled"] >> globalOnOffFilterLut >> rhs.radioGFDisabled;
node["radioTrainerDisabled"] >> globalOnOffFilterLut >> rhs.radioTrainerDisabled;
// Model level tabs control (global setting)
node["modelHeliDisabled"] >> globalOnOffFilterLut >> rhs.modelHeliDisabled;
node["modelFMDisabled"] >> globalOnOffFilterLut >> rhs.modelFMDisabled;
node["modelCurvesDisabled"] >> globalOnOffFilterLut >> rhs.modelCurvesDisabled;
node["modelGVDisabled"] >> globalOnOffFilterLut >> rhs.modelGVDisabled;
node["modelLSDisabled"] >> globalOnOffFilterLut >> rhs.modelLSDisabled;
node["modelSFDisabled"] >> globalOnOffFilterLut >> rhs.modelSFDisabled;
node["modelCustomScriptsDisabled"] >> globalOnOffFilterLut >> rhs.modelCustomScriptsDisabled;
node["modelTelemetryDisabled"] >> globalOnOffFilterLut >> rhs.modelTelemetryDisabled;
// preferably perform conversions here to avoid cluttering the field decodes
if (SemanticVersion(QString(rhs.semver)) < SemanticVersion("2.8.0")) {
+14
View File
@@ -286,6 +286,20 @@ class GeneralSettings {
char selectedTheme[SELECTED_THEME_NAME_LEN + 1];
// Radio level tabs control (global settings)
bool radioThemesDisabled;
bool radioGFDisabled;
bool radioTrainerDisabled;
// Model level tabs control (global setting)
bool modelHeliDisabled;
bool modelFMDisabled;
bool modelCurvesDisabled;
bool modelGVDisabled;
bool modelLSDisabled;
bool modelSFDisabled;
bool modelCustomScriptsDisabled;
bool modelTelemetryDisabled;
bool switchPositionAllowedTaranis(int index) const;
bool switchSourceAllowedTaranis(int index) const;
bool isPotAvailable(int index) const;
+14
View File
@@ -191,6 +191,20 @@ class ModelData {
char registrationId[8+1];
// Radio level tabs control (global settings)
unsigned int radioThemesDisabled;
unsigned int radioGFDisabled;
unsigned int radioTrainerDisabled;
// Model level tabs control (global setting)
unsigned int modelHeliDisabled;
unsigned int modelFMDisabled;
unsigned int modelCurvesDisabled;
unsigned int modelGVDisabled;
unsigned int modelLSDisabled;
unsigned int modelSFDisabled;
unsigned int modelCustomScriptsDisabled;
unsigned int modelTelemetryDisabled;
enum FunctionSwitchConfig {
FUNC_SWITCH_CONFIG_NONE,
FUNC_SWITCH_CONFIG_FIRST = FUNC_SWITCH_CONFIG_NONE,
+2
View File
@@ -9,12 +9,14 @@ set(generaledit_SRCS
calibration.cpp
hardware.cpp
trainer.cpp
generaloptions.cpp
)
set(generaledit_HDRS
calibration.h
hardware.h
trainer.h
generaloptions.h
)
set(generaledit_UIS
@@ -27,6 +27,7 @@
#include "calibration.h"
#include "hardware.h"
#include "../modeledit/customfunctions.h"
#include "generaloptions.h"
#include "verticalscrollarea.h"
#include "compounditemmodels.h"
@@ -69,6 +70,7 @@ GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * fir
auto hwpnl = new HardwarePanel(this, generalSettings, firmware, editorItemModels);
addTab(hwpnl, tr("Hardware"));
addTab(new CalibrationPanel(this, generalSettings, firmware), tr("Calibration"));
addTab(new GeneralOptionsPanel(this, generalSettings, firmware), tr("Enabled Features"));
connect(hwpnl, &HardwarePanel::internalModuleChanged, this, [&] { intModChanged = true; });
@@ -0,0 +1,160 @@
/*
* 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 "generaloptions.h"
#include "autocheckbox.h"
#include <QLabel>
#include <QGridLayout>
GeneralOptionsPanel::GeneralOptionsPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware):
GeneralPanel(parent, generalSettings, firmware),
board(firmware->getBoard()),
params(new QList<QWidget *>),
row(0),
col(0)
{
grid = new QGridLayout(this);
addSection(tr("Radio Menus"));
if (Boards::getCapability(board, Board::HasColorLcd)) {
addLabel(tr("Themes"));
AutoCheckBox *themesDisable = new AutoCheckBox(this);
themesDisable->setField(generalSettings.radioThemesDisabled, this, true);
params->append(themesDisable);
addParams();
}
addLabel(tr("Global Functions"));
AutoCheckBox *globalFuncsDisable = new AutoCheckBox(this);
globalFuncsDisable->setField(generalSettings.radioGFDisabled, this, true);
params->append(globalFuncsDisable);
addParams();
addLabel(tr("Trainer"));
AutoCheckBox *trainerDisable = new AutoCheckBox(this);
trainerDisable->setField(generalSettings.radioTrainerDisabled, this, true);
params->append(trainerDisable);
addParams();
row = 0;
col = 2;
addSection(tr("Model Menus"));
if (firmware->getCapability(Heli)) {
addLabel(tr("Heli"));
AutoCheckBox *heliDisable = new AutoCheckBox(this);
heliDisable->setField(generalSettings.modelHeliDisabled, this, true);
params->append(heliDisable);
addParams();
}
addLabel(tr("Flight Modes"));
AutoCheckBox *fmDisable = new AutoCheckBox(this);
fmDisable->setField(generalSettings.modelFMDisabled, this, true);
params->append(fmDisable);
addParams();
addLabel(tr("Curves"));
AutoCheckBox *curvesDisable = new AutoCheckBox(this);
curvesDisable->setField(generalSettings.modelCurvesDisabled, this, true);
params->append(curvesDisable);
addParams();
if (firmware->getCapability(Gvars)) {
addLabel(tr("Global Variables"));
AutoCheckBox *gvDisable = new AutoCheckBox(this);
gvDisable->setField(generalSettings.modelGVDisabled, this, true);
params->append(gvDisable);
addParams();
}
addLabel(tr("Logical Switches"));
AutoCheckBox *lsDisable = new AutoCheckBox(this);
lsDisable->setField(generalSettings.modelLSDisabled, this, true);
params->append(lsDisable);
addParams();
addLabel(tr("Special Functions"));
AutoCheckBox *sfDisable = new AutoCheckBox(this);
sfDisable->setField(generalSettings.modelSFDisabled, this, true);
params->append(sfDisable);
addParams();
addLabel(tr("Custom Mix Scripts"));
AutoCheckBox *cmsDisable = new AutoCheckBox(this);
cmsDisable->setField(generalSettings.modelCustomScriptsDisabled, this, true);
params->append(cmsDisable);
addParams();
addLabel(tr("Telemetry"));
AutoCheckBox *teleDisable = new AutoCheckBox(this);
teleDisable->setField(generalSettings.modelTelemetryDisabled, this, true);
params->append(teleDisable);
addParams();
addVSpring(grid, 0, grid->rowCount());
addHSpring(grid, grid->columnCount(), 0);
disableMouseScrolling();
}
GeneralOptionsPanel::~GeneralOptionsPanel()
{
}
void GeneralOptionsPanel::addLabel(QString text)
{
QLabel *label = new QLabel(this);
label->setText(text);
grid->addWidget(label, row, col);
}
void GeneralOptionsPanel::addLine()
{
QFrame *line = new QFrame(this);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
line->setLineWidth(1);
line->setMidLineWidth(0);
grid->addWidget(line, row++, 0, 1, grid->columnCount());
}
void GeneralOptionsPanel::addParams()
{
int col = 0;
QGridLayout *subgrid = new QGridLayout();
for (int i = 0; i < params->size(); i++) {
subgrid->addWidget(params->at(i), 0, col++);
}
addHSpring(subgrid, col, 0);
grid->addLayout(subgrid, row++, this->col + 1);
params->clear();
}
void GeneralOptionsPanel::addSection(QString text)
{
addLabel(QString("<b>%1</b>").arg(text));
row++;
}
@@ -0,0 +1,47 @@
/*
* 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 "generaledit.h"
class QGridLayout;
class GeneralOptionsPanel : public GeneralPanel
{
Q_OBJECT
public:
GeneralOptionsPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware);
virtual ~GeneralOptionsPanel();
private:
Board::Type board;
QGridLayout *grid;
QList<QWidget *> *params;
int row;
int col;
void addLabel(QString text);
void addLine();
void addParams();
void addSection(QString text);
};
+2
View File
@@ -27,6 +27,7 @@ set(modeledit_SRCS
colorcustomscreens.cpp
telemetry_customscreens.cpp
curves.cpp
modeloptions.cpp
)
set(modeledit_HDRS
@@ -41,6 +42,7 @@ set(modeledit_HDRS
colorcustomscreens.h
telemetry_customscreens.h
curves.h
modeloptions.h
)
set(modeledit_UIS
+4
View File
@@ -34,6 +34,7 @@
#include "telemetry.h"
#include "colorcustomscreens.h"
#include "telemetry_customscreens.h"
#include "modeloptions.h"
#include "appdata.h"
#include "compounditemmodels.h"
@@ -116,6 +117,9 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw
s1.report("Telemetry Custom Screens");
}
addTab(new ModelOptionsPanel(this, model, generalSettings, firmware), tr("Enabled Features"));
s1.report("Enabled Features");
connect(setupPanel, &SetupPanel::extendedLimitsToggled, channelsPanel, &ChannelsPanel::refreshExtendedLimits);
connect(ui->tabWidget, &QTabWidget::currentChanged, this, &ModelEdit::onTabIndexChanged);
connect(ui->pushButton, &QPushButton::clicked, this, &ModelEdit::launchSimulation);
+181
View File
@@ -0,0 +1,181 @@
/*
* 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 "modeloptions.h"
#include "autocombobox.h"
#include "compounditemmodels.h"
#include <QLabel>
#include <QGridLayout>
ModelOptionsPanel::ModelOptionsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware):
ModelPanel(parent, model, generalSettings, firmware),
board(firmware->getBoard()),
params(new QList<QWidget *>),
row(0),
col(0)
{
// grid within a grid to compact the inner grid layout more than a single grid
QGridLayout* panelgrid = new QGridLayout(this);
grid = new QGridLayout();
panelgrid->addLayout(grid, 0, 0);
AbstractStaticItemModel * mdl = new AbstractStaticItemModel();
mdl->appendToItemList(tr("Global"), 0);
mdl->appendToItemList(tr("Off"), 1);
mdl->appendToItemList(tr("On"), 2);
mdl->loadItemList();
addSection(tr("Radio Menus"));
if (Boards::getCapability(board, Board::HasColorLcd)) {
addLabel(tr("Themes"));
AutoComboBox *themesDisable = new AutoComboBox(this);
themesDisable->setModel(mdl);
themesDisable->setField(model.radioThemesDisabled, this);
params->append(themesDisable);
addParams();
}
addLabel(tr("Global Functions"));
AutoComboBox *globalFuncsDisable = new AutoComboBox(this);
globalFuncsDisable->setModel(mdl);
globalFuncsDisable->setField(model.radioGFDisabled, this);
params->append(globalFuncsDisable);
addParams();
addLabel(tr("Trainer"));
AutoComboBox *trainerDisable = new AutoComboBox(this);
trainerDisable->setModel(mdl);
trainerDisable->setField(model.radioTrainerDisabled, this);
params->append(trainerDisable);
addParams();
row = 0;
col = 2;
addSection(tr("Model Menus"));
if (firmware->getCapability(Heli)) {
addLabel(tr("Heli"));
AutoComboBox *heliDisable = new AutoComboBox(this);
heliDisable->setModel(mdl);
heliDisable->setField(model.modelHeliDisabled, this);
params->append(heliDisable);
addParams();
}
addLabel(tr("Flight Modes"));
AutoComboBox *fmDisable = new AutoComboBox(this);
fmDisable->setModel(mdl);
fmDisable->setField(model.modelFMDisabled, this);
params->append(fmDisable);
addParams();
addLabel(tr("Curves"));
AutoComboBox *curvesDisable = new AutoComboBox(this);
curvesDisable->setModel(mdl);
curvesDisable->setField(model.modelCurvesDisabled, this);
params->append(curvesDisable);
addParams();
if (firmware->getCapability(Gvars)) {
addLabel(tr("Global Variables"));
AutoComboBox *gvDisable = new AutoComboBox(this);
gvDisable->setModel(mdl);
gvDisable->setField(model.modelGVDisabled, this);
params->append(gvDisable);
addParams();
}
addLabel(tr("Logical Switches"));
AutoComboBox *lsDisable = new AutoComboBox(this);
lsDisable->setModel(mdl);
lsDisable->setField(model.modelLSDisabled, this);
params->append(lsDisable);
addParams();
addLabel(tr("Special Functions"));
AutoComboBox *sfDisable = new AutoComboBox(this);
sfDisable->setModel(mdl);
sfDisable->setField(model.modelSFDisabled, this);
params->append(sfDisable);
addParams();
addLabel(tr("Custom Mix Scripts"));
AutoComboBox *cmsDisable = new AutoComboBox(this);
cmsDisable->setModel(mdl);
cmsDisable->setField(model.modelCustomScriptsDisabled, this);
params->append(cmsDisable);
addParams();
addLabel(tr("Telemetry"));
AutoComboBox *teleDisable = new AutoComboBox(this);
teleDisable->setModel(mdl);
teleDisable->setField(model.modelTelemetryDisabled, this);
params->append(teleDisable);
addParams();
addVSpring(panelgrid, 0, panelgrid->rowCount());
addHSpring(panelgrid, panelgrid->columnCount(), 0);
disableMouseScrolling();
}
ModelOptionsPanel::~ModelOptionsPanel()
{
}
void ModelOptionsPanel::addLabel(QString text)
{
QLabel *label = new QLabel(this);
label->setText(text);
grid->addWidget(label, row, col);
}
void ModelOptionsPanel::addLine()
{
QFrame *line = new QFrame(this);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
line->setLineWidth(1);
line->setMidLineWidth(0);
grid->addWidget(line, row++, 0, 1, grid->columnCount());
}
void ModelOptionsPanel::addParams()
{
int col = 0;
QGridLayout *subgrid = new QGridLayout();
for (int i = 0; i < params->size(); i++) {
subgrid->addWidget(params->at(i), 0, col++);
}
addHSpring(subgrid, col, 0);
grid->addLayout(subgrid, row++, this->col + 1);
params->clear();
}
void ModelOptionsPanel::addSection(QString text)
{
addLabel(QString("<b>%1</b>").arg(text));
row++;
}
+49
View File
@@ -0,0 +1,49 @@
/*
* 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 "eeprominterface.h"
class QGridLayout;
class ModelOptionsPanel : public ModelPanel
{
Q_OBJECT
public:
ModelOptionsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
virtual ~ModelOptionsPanel();
private:
Board::Type board;
QGridLayout *grid;
QList<QWidget *> *params;
int row;
int col;
void addLabel(QString text);
void addLine();
void addParams();
void addSection(QString text);
};