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
+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);
};