feat(radio): optional key lock feature (#7383)

This commit is contained in:
3djc
2026-07-16 18:54:50 +10:00
committed by GitHub
parent 640fc189e7
commit e184cf3976
111 changed files with 750 additions and 66 deletions
+6 -3
View File
@@ -978,7 +978,7 @@ bool BoardJson::loadDefinition()
if (m_board == Board::BOARD_UNKNOWN)
return true;
if (!loadFile(m_board, m_hwdefn, m_inputs, m_switches, m_keys, m_trims, m_display, m_cfs, m_hardware))
if (!loadFile(m_board, m_hwdefn, m_inputs, m_switches, m_keys, m_trims, m_display, m_cfs, m_hardware, m_hasKeyLockCombo))
return false;
afterLoadFixups(m_board, m_inputs, m_switches, m_keys, m_trims);
@@ -1015,7 +1015,7 @@ bool BoardJson::loadDefinition()
// static
bool BoardJson::loadFile(Board::Type board, QString hwdefn, InputsTable * inputs, SwitchesTable * switches,
KeysTable * keys, TrimsTable * trims, DisplayDefn & display, CustomSwitchesDefn & cfs,
HardwareDefn & hardware)
HardwareDefn & hardware, bool & hasKeyLockCombo)
{
if (board == Board::BOARD_UNKNOWN) {
return false;
@@ -1202,6 +1202,9 @@ bool BoardJson::loadFile(Board::Type board, QString hwdefn, InputsTable * inputs
}
}
hasKeyLockCombo = obj.value("key_lock_combo").isArray() &&
obj.value("key_lock_combo").toArray().size() == 2;
if (obj.value("trims").isArray()) {
const QJsonArray &trms = obj.value("trims").toArray();
@@ -1315,4 +1318,4 @@ const QString BoardJson::getCapabilityStr(const Board::Capability capability) co
default:
return QString();
}
}
}
+3 -1
View File
@@ -167,6 +167,7 @@ class BoardJson
const Board::KeyInfo getKeyInfo(int index) const;
const int getKeyIndex(const QString key) const;
bool hasKeyLockCombo() const { return m_hasKeyLockCombo; }
const int getSwitchIndex(const QString val, Board::LookupValueType lvt) const;
const int getCFSIndexForSwitch(int sw) const;
@@ -201,6 +202,7 @@ private:
DisplayDefn m_display;
CustomSwitchesDefn m_cfs;
HardwareDefn m_hardware;
bool m_hasKeyLockCombo = false;
struct InputCounts {
unsigned int flexGyroAxes;
@@ -226,7 +228,7 @@ private:
static bool loadFile(Board::Type board, QString hwdefn, InputsTable * inputs, SwitchesTable * switches,
KeysTable * keys, TrimsTable * trims, DisplayDefn & lcd, CustomSwitchesDefn & cfs,
HardwareDefn & hardware);
HardwareDefn & hardware, bool & hasKeyLockCombo);
static void afterLoadFixups(Board::Type board, InputsTable * inputs, SwitchesTable * switches,
KeysTable * keys, TrimsTable * trims);
@@ -417,6 +417,7 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
}
node["oneLogPerDay"] = (int)rhs.oneLogPerDay;
node["keyLockEnabled"] = (int)rhs.keyLockEnabled;
return node;
}
@@ -780,6 +781,7 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
}
node["oneLogPerDay"] >> rhs.oneLogPerDay;
node["keyLockEnabled"] >> rhs.keyLockEnabled;
// override critical settings after import
// TODO: for consistency move up call stack to use existing eeprom and profile conversions
@@ -459,6 +459,7 @@ class GeneralSettings {
unsigned int qmFavorites[MAX_QMFAVOURITES];
char* qmFavoritesTools[MAX_QMFAVOURITES];
bool oneLogPerDay;
bool keyLockEnabled;
void switchConfigClear();
@@ -26,6 +26,7 @@
#include "autocombobox.h"
#include "namevalidator.h"
#include "helpers.h"
#include "boardjson.h"
constexpr char FIM_HATSMODE[] {"Hats Mode"};
constexpr char FIM_STICKMODE[] {"Stick Mode"};
@@ -474,6 +475,17 @@ void GeneralSetupPanel::setValues()
ui->startSoundCB->setChecked(!generalSettings.dontPlayHello);
ui->modelQuickSelect_CB->setChecked(generalSettings.modelQuickSelect);
ui->chkOneLogPerDay->setChecked(generalSettings.oneLogPerDay);
{
BoardJson* bj = Boards::getBoardJson(board);
bool hasCombo = bj && bj->hasKeyLockCombo();
ui->chkKeyLockEnabled->setChecked(hasCombo && generalSettings.keyLockEnabled);
ui->chkKeyLockEnabled->setEnabled(hasCombo);
ui->label_keyLockEnabled->setEnabled(hasCombo);
if (!hasCombo) {
ui->chkKeyLockEnabled->setToolTip(tr("Not available on this radio (no key combo defined)"));
ui->label_keyLockEnabled->setToolTip(tr("Not available on this radio (no key combo defined)"));
}
}
if (Boards::getCapability(board, Board::HasColorLcd)) {
ui->modelSelectLayout_CB->setCurrentIndex(generalSettings.modelSelectLayout);
@@ -951,3 +963,11 @@ void GeneralSetupPanel::on_chkOneLogPerDay_stateChanged(int)
emit modified();
}
}
void GeneralSetupPanel::on_chkKeyLockEnabled_stateChanged(int)
{
if (!lock) {
generalSettings.keyLockEnabled = ui->chkKeyLockEnabled->isChecked();
emit modified();
}
}
+1
View File
@@ -103,6 +103,7 @@ class GeneralSetupPanel : public GeneralPanel
void on_pwrOffIfInactiveSB_editingFinished();
void on_chkOneLogPerDay_stateChanged(int);
void on_chkKeyLockEnabled_stateChanged(int);
private:
Ui::GeneralSetup *ui;
+14
View File
@@ -1326,6 +1326,20 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="30" column="0">
<widget class="QLabel" name="label_keyLockEnabled">
<property name="text">
<string>Key lock</string>
</property>
</widget>
</item>
<item row="30" column="1">
<widget class="QCheckBox" name="chkKeyLockEnabled">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">