feat: simple global control for backlight/brightness and volume (#6684)

This commit is contained in:
philmoz
2026-01-04 17:56:50 +10:00
committed by GitHub
parent 586a567b0b
commit e80406b274
71 changed files with 812 additions and 374 deletions
+2 -1
View File
@@ -51,8 +51,9 @@ GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * fir
editorItemModels->addItemModel(AbstractItemModel::IMID_RawSwitch);
editorItemModels->addItemModel(AbstractItemModel::IMID_CustomFuncAction);
editorItemModels->addItemModel(AbstractItemModel::IMID_CustomFuncResetParam);
editorItemModels->addItemModel(AbstractItemModel::IMID_ControlSource);
addTab(new GeneralSetupPanel(this, generalSettings, firmware), tr("Setup"));
addTab(new GeneralSetupPanel(this, generalSettings, firmware, editorItemModels), tr("Setup"));
addTab(new CustomFunctionsPanel(this, nullptr, generalSettings, firmware, editorItemModels), tr("Global Functions"));
addTab(new TrainerPanel(this, generalSettings, firmware, editorItemModels), tr("Trainer"));
auto hwpnl = new HardwarePanel(this, generalSettings, firmware, editorItemModels);
+34 -4
View File
@@ -25,22 +25,22 @@
#include "filtereditemmodels.h"
#include "autocombobox.h"
#include "namevalidator.h"
#include "helpers.h"
constexpr char FIM_HATSMODE[] {"Hats Mode"};
constexpr char FIM_STICKMODE[] {"Stick Mode"};
constexpr char FIM_TEMPLATESETUP[] {"Template Setup"};
constexpr char FIM_BACKLIGHTMODE[] {"Backlight Mode"};
constexpr char FIM_CONTROLSRC[] {"Control Source"};
GeneralSetupPanel::GeneralSetupPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware):
GeneralSetupPanel::GeneralSetupPanel(QWidget * parent, GeneralSettings & generalSettings,
Firmware * firmware, CompoundItemModelFactory * sharedItemModels):
GeneralPanel(parent, generalSettings, firmware),
ui(new Ui::GeneralSetup)
{
ui->setupUi(this);
Board::Type board = firmware->getBoard();
panelFilteredModels = new FilteredItemModelFactory();
panelFilteredModels->registerItemModel(new FilteredItemModel(GeneralSettings::hatsModeItemModel()), FIM_HATSMODE);
panelFilteredModels->registerItemModel(new FilteredItemModel(GeneralSettings::stickModeItemModel()), FIM_STICKMODE);
panelFilteredModels->registerItemModel(new FilteredItemModel(GeneralSettings::templateSetupItemModel(),
@@ -48,6 +48,8 @@ ui(new Ui::GeneralSetup)
GeneralSettings::RadioTypeContextSurface),
FIM_TEMPLATESETUP);
panelFilteredModels->registerItemModel(new FilteredItemModel(GeneralSettings::backlightModeItemModel()), FIM_BACKLIGHTMODE);
panelFilteredModels->registerItemModel(new FilteredItemModel(sharedItemModels->getItemModel(AbstractItemModel::IMID_ControlSource)),
FIM_CONTROLSRC);
QLabel *pmsl[] = {ui->ro_label, ui->ro1_label, ui->ro2_label, ui->ro3_label, ui->ro4_label, ui->ro5_label, ui->ro6_label, ui->ro7_label, ui->ro8_label, NULL};
QSlider *tpmsld[] = {ui->chkSA, ui->chkSB, ui->chkSC, ui->chkSD, ui->chkSE, ui->chkSF, ui->chkSG, ui->chkSH, NULL};
@@ -93,6 +95,18 @@ ui(new Ui::GeneralSetup)
lock = true;
ui->volumeCtrl_CB->setSizeAdjustPolicy(QComboBox::AdjustToContents);
ui->volumeCtrl_CB->setModel(panelFilteredModels->getItemModel(FIM_CONTROLSRC));
ui->volumeCtrl_CB->setCurrentIndex(ui->volumeCtrl_CB->findData(generalSettings.volumeSrc.toValue()));
if (ui->volumeCtrl_CB->currentIndex() < 0 && generalSettings.volumeSrc.toValue() == 0)
ui->volumeCtrl_CB->setCurrentIndex(Helpers::getFirstPosValueIndex(ui->volumeCtrl_CB));
ui->brightCtrl_CB->setSizeAdjustPolicy(QComboBox::AdjustToContents);
ui->brightCtrl_CB->setModel(panelFilteredModels->getItemModel(FIM_CONTROLSRC));
ui->brightCtrl_CB->setCurrentIndex(ui->brightCtrl_CB->findData(generalSettings.backlightSrc.toValue()));
if (ui->brightCtrl_CB->currentIndex() < 0 && generalSettings.backlightSrc.toValue() == 0)
ui->brightCtrl_CB->setCurrentIndex(Helpers::getFirstPosValueIndex(ui->brightCtrl_CB));
ui->backlightswCB->setModel(panelFilteredModels->getItemModel(FIM_BACKLIGHTMODE));
ui->backlightswCB->setCurrentIndex(ui->backlightswCB->findData(generalSettings.backlightMode));
@@ -729,6 +743,22 @@ void GeneralSetupPanel::on_OFFBright_SB_editingFinished()
}
}
void GeneralSetupPanel::on_volumeCtrl_CB_currentIndexChanged(int index)
{
if (!lock) {
generalSettings.volumeSrc = RawSource(ui->volumeCtrl_CB->itemData(ui->volumeCtrl_CB->currentIndex()).toInt());
emit modified();
}
}
void GeneralSetupPanel::on_brightCtrl_CB_currentIndexChanged(int index)
{
if (!lock) {
generalSettings.backlightSrc = RawSource(ui->brightCtrl_CB->itemData(ui->brightCtrl_CB->currentIndex()).toInt());
emit modified();
}
}
void GeneralSetupPanel::on_volume_SL_valueChanged()
{
if (!lock) {
+3 -1
View File
@@ -35,7 +35,7 @@ class GeneralSetupPanel : public GeneralPanel
Q_OBJECT
public:
GeneralSetupPanel(QWidget *parent, GeneralSettings & generalSettings, Firmware * firmware);
GeneralSetupPanel(QWidget *parent, GeneralSettings & generalSettings, Firmware * firmware, CompoundItemModelFactory * sharedItemModels);
virtual ~GeneralSetupPanel();
private slots:
@@ -47,6 +47,8 @@ class GeneralSetupPanel : public GeneralPanel
void on_displayTypeCB_currentIndexChanged(int index);
void on_BLBright_SB_editingFinished();
void on_OFFBright_SB_editingFinished();
void on_brightCtrl_CB_currentIndexChanged(int index);
void on_volumeCtrl_CB_currentIndexChanged(int index);
void on_countrycode_CB_currentIndexChanged(int index);
void on_units_CB_currentIndexChanged(int index);
void on_ppm_units_CB_currentIndexChanged(int index);
+24 -2
View File
@@ -651,6 +651,10 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="volumeCtrl_CB">
</widget>
</item>
<item row="14" column="1">
<widget class="QSpinBox" name="BLBright_SB">
<property name="maximum">
@@ -722,13 +726,20 @@
</property>
</widget>
</item>
<item row="16" column="0">
<item row="15" column="0">
<widget class="QLabel" name="label_OFFBright">
<property name="text">
<string>Backlight OFF Brightness</string>
</property>
</widget>
</item>
<item row="16" column="0">
<widget class="QLabel" name="label_BrightCtrl">
<property name="text">
<string>Backlight Control</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QComboBox" name="backlightswCB">
<property name="toolTip">
@@ -932,7 +943,7 @@
</property>
</widget>
</item>
<item row="16" column="1">
<item row="15" column="1">
<widget class="QSpinBox" name="OFFBright_SB">
<property name="minimum">
<number>5</number>
@@ -942,6 +953,10 @@
</property>
</widget>
</item>
<item row="16" column="1">
<widget class="QComboBox" name="brightCtrl_CB">
</widget>
</item>
<item row="19" column="0">
<widget class="QLabel" name="stickReverseLB">
<property name="sizePolicy">
@@ -1147,6 +1162,13 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_volumeCtrl">
<property name="text">
<string>Volume Control</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="speakerPitchSB">
<property name="toolTip">
+22 -3
View File
@@ -365,6 +365,10 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings
addParams();
}
connect(this, &HardwarePanel::inputFlexTypeChanged, [=](AutoComboBox *cb, int index)
{ setFlexTypeModel(cb, index); }
);
connect(this, &HardwarePanel::refreshItemModels, [=]() { updateItemModels(); });
addVSpring(grid, 0, grid->rowCount());
addHSpring(grid, grid->columnCount(), 0);
disableMouseScrolling();
@@ -446,6 +450,7 @@ void HardwarePanel::addFlex(int index)
name->setValidator(new NameValidator(board, this));
name->setField(config.name, HARDWARE_NAME_LEN, this);
params->append(name);
connect(name, &AutoLineEdit::editingFinished, [=] () { emit refreshItemModels(); });
AutoComboBox *type = new AutoComboBox(this);
setFlexTypeModel(type, index);
@@ -465,11 +470,10 @@ void HardwarePanel::addFlex(int index)
} else {
invertToggles[index - Boards::getCapability(board, Board::Sticks)]->show();
}
emit InputFlexTypeChanged();
emit inputFlexTypeChanged(type, index);
emit refreshItemModels();
});
connect(this, &HardwarePanel::InputFlexTypeChanged, [=]() { setFlexTypeModel(type, index); });
params->append(type);
AutoCheckBox *inverted = new AutoCheckBox(this);
@@ -508,6 +512,7 @@ void HardwarePanel::addSwitch(int index)
name->setValidator(new NameValidator(board, this));
name->setField(config.name, HARDWARE_NAME_LEN, this);
params->append(name);
connect(name, &AutoLineEdit::editingFinished, [=] () { emit refreshItemModels(); });
AutoComboBox *input = nullptr;
@@ -538,6 +543,12 @@ void HardwarePanel::addSwitch(int index)
type->setField(config.type, this);
params->append(type);
if (!generalSettings.isSwitchFunc(index)) {
connect(type, &AutoComboBox::currentDataChanged, [=] (int val) {
emit refreshItemModels();
});
}
if (generalSettings.isSwitchFlex(index)) {
connect(input, &AutoComboBox::currentDataChanged, [=] (int val) {
if (val < 0) {
@@ -547,6 +558,8 @@ void HardwarePanel::addSwitch(int index)
}
else
type->setModel(tabFilteredModels->getItemModel(FIM_SWITCHTYPE3POS));
emit refreshItemModels();
});
}
@@ -562,6 +575,7 @@ void HardwarePanel::addSwitch(int index)
connect(type, &AutoComboBox::currentDataChanged, [=] (int val) {
start->setEnabled(val == Board::SWITCH_2POS);
emit refreshItemModels();
});
if (Boards::getCapability(board, Board::FunctionSwitchColors)) {
@@ -677,3 +691,8 @@ void HardwarePanel::updateSerialPortUSBVCP()
view->setRowHidden(i, false);
}
}
void HardwarePanel::updateItemModels()
{
editorItemModels->update(AbstractItemModel::IMUE_Hardware);
}
+3 -1
View File
@@ -41,7 +41,8 @@ class HardwarePanel : public GeneralPanel
signals:
void internalModuleChanged();
void InputFlexTypeChanged();
void inputFlexTypeChanged(AutoComboBox *cb, int index);
void refreshItemModels();
private slots:
void on_internalModuleChanged();
@@ -73,4 +74,5 @@ class HardwarePanel : public GeneralPanel
void setFlexTypeModel(AutoComboBox * cb, int index);
void updateSerialPortUSBVCP();
void updateItemModels();
};