[Companion] Refactoring - fixes the X9E=>X7 conversion segfault
This commit is contained in:
@@ -334,17 +334,17 @@ void SimulatorDialog::setupRadioWidgets()
|
||||
// Now set up new widgets.
|
||||
|
||||
// switches
|
||||
Firmware::Switch swinfo;
|
||||
SwitchInfo switchInfo;
|
||||
// FIXME : CPN_MAX_SWITCHES == 32 but GeneralSettings::switchConfig[18] !!
|
||||
for (i = 0; i < firmware->getCapability(Capability(Switches)) && i < 18 /*CPN_MAX_SWITCHES*/; ++i) {
|
||||
if (radioSettings.switchConfig[i] == GeneralSettings::SWITCH_NONE)
|
||||
if (radioSettings.switchConfig[i] == SWITCH_NONE)
|
||||
continue;
|
||||
|
||||
if ((wname = QString(radioSettings.switchName[i])).isEmpty()) {
|
||||
swinfo = firmware->getSwitch(i);
|
||||
wname = QString(swinfo.name);
|
||||
switchInfo = getSwitchInfo(board, i);
|
||||
wname = QString(switchInfo.name);
|
||||
}
|
||||
RadioSwitchWidget * sw = new RadioSwitchWidget(GeneralSettings::SwitchConfig(radioSettings.switchConfig[i]), wname, 0, ui->radioWidgetsHT);
|
||||
RadioSwitchWidget * sw = new RadioSwitchWidget(SwitchConfig(radioSettings.switchConfig[i]), wname, 0, ui->radioWidgetsHT);
|
||||
sw->setIndex(i);
|
||||
ui->radioWidgetsHTLayout->addWidget(sw);
|
||||
switches.append(sw);
|
||||
@@ -361,7 +361,7 @@ void SimulatorDialog::setupRadioWidgets()
|
||||
if ((wname = QString(radioSettings.potName[i])).isEmpty())
|
||||
wname = firmware->getAnalogInputName(4 + aIdx + i);
|
||||
|
||||
RadioKnobWidget * pot = new RadioKnobWidget(GeneralSettings::PotConfig(radioSettings.potConfig[i]), wname, 0, ui->radioWidgetsHT);
|
||||
RadioKnobWidget * pot = new RadioKnobWidget(PotConfig(radioSettings.potConfig[i]), wname, 0, ui->radioWidgetsHT);
|
||||
pot->setIndex(aIdx + i);
|
||||
// FIXME : total hack here -- this needs to follow the exception in radio/src/mixer.cpp:evalInputs()
|
||||
if (i == 0 && IS_TARANIS(board) && !IS_TARANIS_X7(board))
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#ifndef _SIMULATORINTERFACE_H_
|
||||
#define _SIMULATORINTERFACE_H_
|
||||
|
||||
#include "boards.h"
|
||||
#include "constants.h"
|
||||
#include <inttypes.h>
|
||||
#include <QString>
|
||||
|
||||
@@ -35,15 +35,13 @@ class RadioKnobWidget : public RadioWidget
|
||||
|
||||
public:
|
||||
|
||||
using potType_t = GeneralSettings::PotConfig;
|
||||
|
||||
explicit RadioKnobWidget(potType_t type = potType_t::POT_WITH_DETENT, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) :
|
||||
explicit RadioKnobWidget(PotConfig type = POT_WITH_DETENT, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) :
|
||||
RadioWidget(parent, f),
|
||||
m_potType(type)
|
||||
{
|
||||
init();
|
||||
}
|
||||
explicit RadioKnobWidget(potType_t type, const QString &labelText, int value = 0, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) :
|
||||
explicit RadioKnobWidget(PotConfig type, const QString &labelText, int value = 0, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) :
|
||||
RadioWidget(labelText, value, parent, f),
|
||||
m_potType(type)
|
||||
{
|
||||
@@ -65,20 +63,19 @@ class RadioKnobWidget : public RadioWidget
|
||||
|
||||
private:
|
||||
|
||||
potType_t m_potType;
|
||||
PotConfig m_potType;
|
||||
|
||||
|
||||
class KnobWidget : public QDial
|
||||
{
|
||||
friend class RadioKnobWidget;
|
||||
using potType_t = RadioKnobWidget::potType_t;
|
||||
|
||||
public:
|
||||
|
||||
explicit KnobWidget(potType_t type, QWidget * parent = 0):
|
||||
explicit KnobWidget(PotConfig type, QWidget * parent = 0):
|
||||
QDial(parent),
|
||||
m_type(type),
|
||||
m_positions(type == potType_t::POT_MULTIPOS_SWITCH ? 5 : 0)
|
||||
m_positions(type == POT_MULTIPOS_SWITCH ? 5 : 0)
|
||||
{
|
||||
setToolTip(tr("Right-double-click to reset to center."));
|
||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
@@ -117,7 +114,7 @@ class RadioKnobWidget : public RadioWidget
|
||||
QDial::mousePressEvent(event);
|
||||
}
|
||||
|
||||
potType_t m_type;
|
||||
PotConfig m_type;
|
||||
quint8 m_positions;
|
||||
};
|
||||
|
||||
|
||||
@@ -32,17 +32,16 @@ class RadioSwitchWidget : public RadioWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
typedef GeneralSettings::SwitchConfig swType_t;
|
||||
|
||||
explicit RadioSwitchWidget(swType_t type = swType_t::SWITCH_3POS, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) :
|
||||
explicit RadioSwitchWidget(SwitchConfig type = SWITCH_3POS, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) :
|
||||
RadioWidget(parent, f),
|
||||
swType(type)
|
||||
switchConfig(type)
|
||||
{
|
||||
init();
|
||||
}
|
||||
explicit RadioSwitchWidget(swType_t type, const QString &labelText, int value = 0, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) :
|
||||
explicit RadioSwitchWidget(SwitchConfig type, const QString &labelText, int value = 0, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) :
|
||||
RadioWidget(labelText, value, parent, f),
|
||||
swType(type)
|
||||
switchConfig(type)
|
||||
{
|
||||
init();
|
||||
}
|
||||
@@ -59,7 +58,7 @@ class RadioSwitchWidget : public RadioWidget
|
||||
sl->setInvertedControls(true);
|
||||
sl->setTickPosition(QSlider::TicksBothSides);
|
||||
sl->setPageStep(1);
|
||||
sl->setMinimum((swType == swType_t::SWITCH_3POS ? -1 : 0));
|
||||
sl->setMinimum((switchConfig == SWITCH_3POS ? -1 : 0));
|
||||
sl->setMaximum(1);
|
||||
sl->setTickInterval(1);
|
||||
sl->setValue(m_value);
|
||||
@@ -71,7 +70,7 @@ class RadioSwitchWidget : public RadioWidget
|
||||
}
|
||||
|
||||
private:
|
||||
swType_t swType;
|
||||
SwitchConfig switchConfig;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user