mirror of
https://github.com/opentx/opentx.git
synced 2025-07-16 12:55:12 +03:00
Telemetry refactoring - Fixes #1634
This commit is contained in:
parent
7d8ca6931b
commit
88d9691d16
105 changed files with 5789 additions and 3449 deletions
|
@ -616,7 +616,25 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData *
|
|||
}
|
||||
}
|
||||
|
||||
if (flags & POPULATE_TELEMETRYEXT) {
|
||||
if (IS_ARM(GetCurrentFirmware()->getBoard())) {
|
||||
if ((flags & POPULATE_TELEMETRY) || (flags & POPULATE_TELEMETRYEXT)) {
|
||||
for (int i=0; i<5; ++i) {
|
||||
item = RawSource(SOURCE_TYPE_SPECIAL, i);
|
||||
b->addItem(item.toString(model), item.toValue());
|
||||
if (item == source) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
for (int i=0; i<C9X_MAX_SENSORS; ++i) {
|
||||
if (model->sensorData[i].isAvailable()) {
|
||||
for (int j=0; j<3; ++j) {
|
||||
item = RawSource(SOURCE_TYPE_TELEMETRY, 3*i+j);
|
||||
b->addItem(item.toString(model), item.toValue());
|
||||
if (item == source) b->setCurrentIndex(b->count()-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (flags & POPULATE_TELEMETRYEXT) {
|
||||
for (int i=0; i<TELEMETRY_SOURCE_ACC; i++) {
|
||||
if (i==TELEMETRY_SOURCE_RSSI_TX && IS_TARANIS(board))
|
||||
continue;
|
||||
|
@ -1001,119 +1019,3 @@ QString generateProcessUniqueTempFileName(const QString & fileName)
|
|||
sanitizedFileName.remove('/');
|
||||
return QDir::tempPath() + QString("/%1-").arg(QCoreApplication::applicationPid()) + sanitizedFileName;
|
||||
}
|
||||
|
||||
GenericPanel::GenericPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, FirmwareInterface * firmware):
|
||||
QWidget(parent),
|
||||
model(model),
|
||||
generalSettings(generalSettings),
|
||||
firmware(firmware),
|
||||
lock(false)
|
||||
{
|
||||
}
|
||||
|
||||
GenericPanel::~GenericPanel()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericPanel::update()
|
||||
{
|
||||
}
|
||||
|
||||
void GenericPanel::addLabel(QGridLayout * gridLayout, QString text, int col, bool minimize)
|
||||
{
|
||||
QLabel *label = new QLabel(this);
|
||||
label->setFrameShape(QFrame::Panel);
|
||||
label->setFrameShadow(QFrame::Raised);
|
||||
label->setMidLineWidth(0);
|
||||
label->setAlignment(Qt::AlignCenter);
|
||||
label->setMargin(5);
|
||||
label->setText(text);
|
||||
if (!minimize)
|
||||
label->setMinimumWidth(100);
|
||||
gridLayout->addWidget(label, 0, col, 1, 1);
|
||||
}
|
||||
|
||||
void GenericPanel::addEmptyLabel(QGridLayout * gridLayout, int col)
|
||||
{
|
||||
QLabel *label = new QLabel(this);
|
||||
label->setText("");
|
||||
gridLayout->addWidget(label, 0, col, 1, 1);
|
||||
}
|
||||
|
||||
void GenericPanel::addHSpring(QGridLayout * gridLayout, int col, int row)
|
||||
{
|
||||
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
|
||||
gridLayout->addItem(spacer, row, col);
|
||||
}
|
||||
|
||||
void GenericPanel::addVSpring(QGridLayout * gridLayout, int col, int row)
|
||||
{
|
||||
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
|
||||
gridLayout->addItem(spacer, row, col);
|
||||
}
|
||||
|
||||
void GenericPanel::addDoubleSpring(QGridLayout * gridLayout, int col, int row)
|
||||
{
|
||||
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding );
|
||||
gridLayout->addItem(spacer, row, col);
|
||||
}
|
||||
|
||||
bool GenericPanel::eventFilter(QObject *object, QEvent * event)
|
||||
{
|
||||
QWidget * widget = qobject_cast<QWidget*>(object);
|
||||
if (widget) {
|
||||
if (event->type() == QEvent::Wheel) {
|
||||
if (widget->focusPolicy() == Qt::WheelFocus) {
|
||||
event->accept();
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
event->ignore();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (event->type() == QEvent::FocusIn) {
|
||||
widget->setFocusPolicy(Qt::WheelFocus);
|
||||
}
|
||||
else if (event->type() == QEvent::FocusOut) {
|
||||
widget->setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(object, event);
|
||||
}
|
||||
|
||||
void GenericPanel::disableMouseScrolling()
|
||||
{
|
||||
Q_FOREACH(QComboBox * cb, findChildren<QComboBox*>()) {
|
||||
cb->installEventFilter(this);
|
||||
cb->setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
|
||||
Q_FOREACH(QAbstractSpinBox * sb, findChildren<QAbstractSpinBox*>()) {
|
||||
sb->installEventFilter(this);
|
||||
sb->setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
|
||||
Q_FOREACH(QSlider * slider, findChildren<QSlider*>()) {
|
||||
slider->installEventFilter(this);
|
||||
slider->setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
}
|
||||
VerticalScrollArea::VerticalScrollArea(QWidget * parent, GenericPanel * panel):
|
||||
QScrollArea(parent),
|
||||
panel(panel),
|
||||
parent(parent)
|
||||
{
|
||||
setWidgetResizable(true);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setWidget(panel);
|
||||
panel->installEventFilter(this);
|
||||
}
|
||||
|
||||
bool VerticalScrollArea::eventFilter(QObject *o, QEvent *e)
|
||||
{
|
||||
if (o == panel && e->type() == QEvent::Resize) {
|
||||
setMinimumWidth(panel->minimumSizeHint().width() + verticalScrollBar()->width());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue