Files
edgetx-gx12/companion/src/generaledit/generaloptions.cpp
T
philmozandGitHub 5327c890f2 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.
2023-05-22 20:08:16 +10:00

161 lines
4.5 KiB
C++

/*
* 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++;
}