Companion hardware internal module continued (#1342)

* Add ability to undo hardware internal module change

* Add internal module protocol check on model edit

* Event driven check and update of all models

* Fix model edit dialog searches

* Add OFF to list of internal modules

* Fix internal module protocol list issue #1382
This commit is contained in:
Neil Horne
2022-01-10 11:13:21 +10:00
committed by GitHub
parent b41cb2a75a
commit fcf8fbdfff
13 changed files with 145 additions and 14 deletions
+6 -1
View File
@@ -66,9 +66,12 @@ GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * fir
addTab(new GeneralSetupPanel(this, generalSettings, firmware), tr("Setup"));
addTab(new CustomFunctionsPanel(this, nullptr, generalSettings, firmware, editorItemModels), tr("Global Functions"));
addTab(new TrainerPanel(this, generalSettings, firmware, editorItemModels), tr("Trainer"));
addTab(new HardwarePanel(this, generalSettings, firmware, editorItemModels), tr("Hardware"));
auto hwpnl = new HardwarePanel(this, generalSettings, firmware, editorItemModels);
addTab(hwpnl, tr("Hardware"));
addTab(new CalibrationPanel(this, generalSettings, firmware), tr("Calibration"));
connect(hwpnl, &HardwarePanel::internalModuleChanged, this, [&] { intModChanged = true; });
ui->tabWidget->setCurrentIndex( g.generalEditTab() );
}
@@ -81,6 +84,8 @@ GeneralEdit::~GeneralEdit()
void GeneralEdit::closeEvent(QCloseEvent *event)
{
g.generalEditTab(ui->tabWidget->currentIndex());
if (intModChanged)
emit internalModuleChanged(); // for MidiChild to trap
}
void GeneralEdit::addTab(GenericPanel *panel, QString text)
+5 -1
View File
@@ -47,6 +47,9 @@ class GeneralEdit : public QDialog
GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * firmware);
~GeneralEdit();
protected:
virtual void closeEvent(QCloseEvent *event) override;
private:
Ui::GeneralEdit *ui;
GeneralSettings & generalSettings;
@@ -60,6 +63,7 @@ class GeneralEdit : public QDialog
signals:
void modified();
void internalModuleChanged();
private slots:
void onTabModified();
@@ -71,6 +75,6 @@ class GeneralEdit : public QDialog
Firmware * firmware;
QVector<GenericPanel *> panels;
void addTab(GenericPanel *panel, QString text);
void closeEvent(QCloseEvent *event);
CompoundItemModelFactory *editorItemModels;
bool intModChanged = false;
};
+18 -5
View File
@@ -132,15 +132,13 @@ HardwarePanel::HardwarePanel(QWidget * parent, GeneralSettings & generalSettings
}
if (Boards::getCapability(board, Board::HasInternalModuleSupport)) {
m_internalModule = generalSettings.internalModule; // to permit undo
addLabel(tr("Internal module"), row, 0);
AutoComboBox *internalModule = new AutoComboBox(this);
internalModule = new AutoComboBox(this);
internalModule->setModel(tabFilteredModels->getItemModel(FIM_INTERNALMODULES));
internalModule->setField(generalSettings.internalModule, this);
addParams(row, internalModule);
connect(internalModule, &AutoComboBox::currentDataChanged, this, [=] () {
QMessageBox::warning(this, CPN_STR_APP_NAME,
tr("ALERT: Check each model's internal module protocol to ensure it is compatible!"));
});
connect(internalModule, &AutoComboBox::currentDataChanged, this, &HardwarePanel::on_internalModuleChanged);
}
if (firmware->getCapability(HasTelemetryBaudrate)) {
@@ -206,6 +204,21 @@ HardwarePanel::~HardwarePanel()
delete tabFilteredModels;
}
void HardwarePanel::on_internalModuleChanged()
{
if (QMessageBox::warning(this, CPN_STR_APP_NAME,
tr("Warning: Changing the Internal module may invalidate the internal module protocol of the models!"),
QMessageBox::Cancel | QMessageBox::Ok, QMessageBox::Cancel) != QMessageBox::Ok) {
generalSettings.internalModule = m_internalModule;
internalModule->updateValue();
}
else {
m_internalModule = generalSettings.internalModule;
emit internalModuleChanged();
}
}
void HardwarePanel::addStick(int index, int & row)
{
int col = 0;
+9
View File
@@ -25,6 +25,7 @@
class CompoundItemModelFactory;
class FilteredItemModelFactory;
class QGridLayout;
class AutoComboBox;
class HardwarePanel : public GeneralPanel
{
@@ -34,11 +35,19 @@ class HardwarePanel : public GeneralPanel
HardwarePanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware, CompoundItemModelFactory * editorItemModels);
virtual ~HardwarePanel();
signals:
void internalModuleChanged();
private slots:
void on_internalModuleChanged();
private:
Board::Type board;
CompoundItemModelFactory *editorItemModels;
FilteredItemModelFactory *tabFilteredModels;
QGridLayout *grid;
AutoComboBox *internalModule;
unsigned int m_internalModule = 0;
void addStick(int index, int & row);
void addPot(int index, int & row);