Companion 2.5 (#555)
* Introduce yaml in Companion * EdgeTX Companion Replace some OpenTX refs Data conversion to v220 Update Timers ui to cater for mode field split * Fix some simulators crashing when started from Companion * Disable firmware and app update checking and downloads from companion * Some more rebranding * Disable manual download actions and another rebrand * Fix cmake warning * Fix mode ON conversion gtests and enable switch in model edit * Stop update message when updates turned off * OpenTX #8580 Fixes missing negative sign for telemetry sources * OpenTX #8604 fix curves tooltip colors * OpenTX #8616 Fix release notes url references * OpenTX #8548 Align file sync folder references * OpenTX #8548 Link field once * OpenTX #8550 Confirmation prompt before write models and settings to radio * OpenTX #8550 Translate strings * Title and splash images * Change DEB package maintainer * Start NV14 * NV14 continued * NV14 sim * Timer countdownStart data conversion and ui fixes * Fix screen width * Merge OpenTX PR 8675 * NV14 sim add computer keys and mouse to activate some functions * Only allow supported protocols for each module on conversion * Clear mismatched modules on conversion * Replace colorlcd theme and layout blobs with detailed data structs in companion * NV14 has 2 topbar zones * Fix layout init * Fix layout init again * Reset to eepromimportexport.h to main branch * Import/export does not like enum fields * Model edit add custom screens tab for color and bw telemetry * Free memory
This commit is contained in:
@@ -25,6 +25,8 @@ set(modeledit_SRCS
|
||||
mixerslistwidget.cpp
|
||||
# node.cpp ## node and edge are built in common lib because also used by simulator
|
||||
# edge.cpp ## commenting them here avoids a "duplicate target" warning eg. from ninja
|
||||
colorcustomscreens.cpp
|
||||
telemetry_customscreens.cpp
|
||||
)
|
||||
|
||||
set(modeledit_HDRS
|
||||
@@ -36,6 +38,8 @@ set(modeledit_HDRS
|
||||
customfunctions.h
|
||||
mixerslistwidget.h
|
||||
# node.h
|
||||
colorcustomscreens.h
|
||||
telemetry_customscreens.h
|
||||
)
|
||||
|
||||
set(modeledit_UIS
|
||||
|
||||
@@ -0,0 +1,456 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "colorcustomscreens.h"
|
||||
#include "customisation_data.h"
|
||||
#include "appdata.h"
|
||||
|
||||
#include <QImage>
|
||||
#include <QFile>
|
||||
|
||||
// used to screen out raw data that cannot be displayed in a user meaningful format at this time TODO remove
|
||||
#define SHOW_RAW_INFO (1==0)
|
||||
|
||||
UserInterfacePanel::UserInterfacePanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
ModelPanel(parent, model, generalSettings, firmware)
|
||||
{
|
||||
RadioTheme::ThemeData & td = generalSettings.themeData;
|
||||
|
||||
grid = new QGridLayout(this);
|
||||
|
||||
int col = 0;
|
||||
int row = 0;
|
||||
|
||||
addGridBlankRow(grid, row);
|
||||
addGridLabel(grid, tr("Theme"), row, col++);
|
||||
addGridLabel(grid, td.themeName, row++, col++);
|
||||
|
||||
col = 0;
|
||||
addGridBlankRow(grid, row);
|
||||
addGridLabel(grid, tr("Background"), row, col++);
|
||||
|
||||
QLabel * img = new QLabel(this);
|
||||
img->setText(tr("background image"));
|
||||
QString path = QString(g.profile[g.id()].sdPath()).trimmed();
|
||||
if (!path.isEmpty()) {
|
||||
path.append(QString("/THEMES/%1/background.png").arg(td.themeName));
|
||||
QFile f(path);
|
||||
if (f.exists()) {
|
||||
QImage image(path);
|
||||
if (!image.isNull()) {
|
||||
img->setText("");
|
||||
img->setFixedSize(QSize(firmware->getCapability(LcdWidth) / 2, firmware->getCapability(LcdHeight) / 2));
|
||||
img->setPixmap(QPixmap::fromImage(image.scaled(firmware->getCapability(LcdWidth) / 2, firmware->getCapability(LcdHeight) / 2)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
grid->addWidget(img, row++, col++);
|
||||
|
||||
col = 0;
|
||||
addGridLabel(grid, tr("Top Bar"), row, col++);
|
||||
|
||||
int widgetdetailsrow = row;
|
||||
int widgetdetailscol = col + 1;
|
||||
int firstenabledbtn = -1;
|
||||
|
||||
QGridLayout * tbgrid = new QGridLayout();
|
||||
|
||||
for (int i = 0; i < firmware->getCapability(TopBarZones); i++) {
|
||||
ZonePersistentData & zpd = model.topBarData.zones[i];
|
||||
QPushButton * btn = new QPushButton(zpd.widgetName, this);
|
||||
btn->setProperty("index", i);
|
||||
btn->setFixedSize(QSize(90, 30));
|
||||
widgetbtns.append(btn);
|
||||
|
||||
if (zpd.widgetName[0] != '\0' && SHOW_RAW_INFO) {
|
||||
if (firstenabledbtn < 0)
|
||||
firstenabledbtn = i;
|
||||
|
||||
QFrame * wgt = new QFrame();
|
||||
wgt->setFrameStyle(QFrame::StyledPanel);
|
||||
wgt->setFrameShadow(QFrame::Plain);
|
||||
wgt->setVisible(false);
|
||||
optswidgets.append(wgt);
|
||||
|
||||
QGridLayout * layout = new QGridLayout(wgt); // must be owned by QWidget so visibility can be set
|
||||
layout->addLayout(addOptionsLayout<WidgetPersistentData>(zpd.widgetData, MAX_WIDGET_OPTIONS, zpd.widgetName), 0, 0);
|
||||
optsgrids.append(layout);
|
||||
|
||||
connect(btn, &QPushButton::clicked, this, [&]() {
|
||||
bool ok;
|
||||
int idx = sender()->property("index").toInt(&ok);
|
||||
if (ok) {
|
||||
if (currindex >= 0) {
|
||||
optswidgets.at(currindex)->setVisible(false);
|
||||
}
|
||||
optswidgets.at(idx)->setVisible(true);
|
||||
currindex = idx;
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (SHOW_RAW_INFO) {
|
||||
btn->setEnabled(false);
|
||||
}
|
||||
|
||||
div_t posn = div(i, MAX_TOPBAR_ZONES);
|
||||
tbgrid->addWidget(btn, posn.quot, posn.rem);
|
||||
}
|
||||
|
||||
grid->addLayout(tbgrid, row++, col++, Qt::AlignTop);
|
||||
|
||||
addGridBlankRow(grid, row);
|
||||
|
||||
col = 0;
|
||||
|
||||
if (SHOW_RAW_INFO) {
|
||||
addGridLabel(grid, tr("Theme"), row, col++);
|
||||
grid->addLayout(addOptionsLayout<RadioTheme::PersistentData>(td.themePersistentData, MAX_THEME_OPTIONS), row, col);
|
||||
}
|
||||
|
||||
// the grid must be fully built for the rowspan to work as required
|
||||
foreach (QWidget * wgt, optswidgets) {
|
||||
grid->addWidget(wgt, widgetdetailsrow, widgetdetailscol, 3, Qt::AlignTop);
|
||||
}
|
||||
|
||||
addHSpring(grid, grid->columnCount(), 0);
|
||||
addVSpring(grid, 0, grid->rowCount());
|
||||
disableMouseScrolling();
|
||||
|
||||
if (firstenabledbtn >= 0)
|
||||
widgetbtns.at(firstenabledbtn)->click();
|
||||
}
|
||||
|
||||
UserInterfacePanel::~UserInterfacePanel()
|
||||
{
|
||||
foreach (QGridLayout * grid, optsgrids) {
|
||||
delete grid;
|
||||
}
|
||||
foreach (QFrame * wgt, optswidgets) {
|
||||
delete wgt;
|
||||
}
|
||||
foreach (QPushButton * btn, widgetbtns) {
|
||||
delete btn;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
CustomScreenPanel
|
||||
*/
|
||||
|
||||
CustomScreenPanel::CustomScreenPanel(QWidget * parent, ModelData & model, int index, GeneralSettings & generalSettings, Firmware * firmware):
|
||||
ModelPanel(parent, model, generalSettings, firmware)
|
||||
{
|
||||
RadioLayout::CustomScreens & scrns = model.customScreens;
|
||||
|
||||
grid = new QGridLayout(this);
|
||||
|
||||
int col = 0;
|
||||
int row = 0;
|
||||
|
||||
addGridBlankRow(grid, row);
|
||||
addGridLabel(grid, tr("Layout:"), row, col++);
|
||||
|
||||
// currently no point continuing if no layout but will change if editing becomes possible
|
||||
if (model.customScreens.customScreenData[index].layoutId[0] == '\0') {
|
||||
addGridLabel(grid, tr("None"), row, col);
|
||||
addHSpring(grid, grid->columnCount(), 0);
|
||||
addVSpring(grid, 0, grid->rowCount());
|
||||
return;
|
||||
}
|
||||
|
||||
QLabel * img = new QLabel(this);
|
||||
|
||||
QString path(QString(":/layouts/mask_%1.png").arg(QString(scrns.customScreenData[index].layoutId).toLower()));
|
||||
QFile f(path);
|
||||
if (f.exists()) {
|
||||
QImage image(path);
|
||||
if (!image.isNull()) {
|
||||
img->setFixedSize(QSize(firmware->getCapability(LcdWidth) / 5, firmware->getCapability(LcdHeight) / 5));
|
||||
img->setPixmap(QPixmap::fromImage(image.scaled(firmware->getCapability(LcdWidth) / 5, firmware->getCapability(LcdHeight) / 5)));
|
||||
}
|
||||
}
|
||||
|
||||
grid->addWidget(img, row++, col++);
|
||||
|
||||
LayoutPersistentData & lpd = scrns.customScreenData[index].layoutPersistentData;
|
||||
|
||||
addGridBlankRow(grid, row);
|
||||
|
||||
col = 0;
|
||||
addGridLabel(grid, tr("Widgets:"), row, col++);
|
||||
|
||||
int widgetdetailsrow = row;
|
||||
int widgetdetailscol = col + 1;
|
||||
int firstenabledbtn = -1;
|
||||
|
||||
QGridLayout * tbgrid = new QGridLayout();
|
||||
|
||||
for (int i = 0; i < MAX_LAYOUT_ZONES; i++) {
|
||||
ZonePersistentData & zpd = lpd.zones[i];
|
||||
QPushButton * btn = new QPushButton(zpd.widgetName, this);
|
||||
btn->setProperty("index", i);
|
||||
btn->setFixedSize(QSize(90, 30));
|
||||
widgetbtns.append(btn);
|
||||
|
||||
if (zpd.widgetName[0] != '\0' && SHOW_RAW_INFO) {
|
||||
if (firstenabledbtn < 0)
|
||||
firstenabledbtn = i;
|
||||
|
||||
QFrame * wgt = new QFrame();
|
||||
wgt->setFrameStyle(QFrame::StyledPanel);
|
||||
wgt->setFrameShadow(QFrame::Plain);
|
||||
wgt->setVisible(false);
|
||||
optswidgets.append(wgt);
|
||||
|
||||
QGridLayout * layout = new QGridLayout(wgt); // must be owned by QWidget so isibility can be set
|
||||
layout->addLayout(addOptionsLayout<WidgetPersistentData>(zpd.widgetData, MAX_WIDGET_OPTIONS, zpd.widgetName), 0, 0, Qt::AlignTop);
|
||||
optsgrids.append(layout);
|
||||
|
||||
connect(btn, &QPushButton::clicked, this, [&]() {
|
||||
bool ok;
|
||||
int idx = sender()->property("index").toInt(&ok);
|
||||
if (ok) {
|
||||
if (currindex >= 0) {
|
||||
optswidgets.at(currindex)->setVisible(false);
|
||||
}
|
||||
optswidgets.at(idx)->setVisible(true);
|
||||
currindex = idx;
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (SHOW_RAW_INFO) {
|
||||
btn->setEnabled(false);
|
||||
}
|
||||
|
||||
div_t posn = div(i, MAX_LAYOUT_ZONES / 2);
|
||||
tbgrid->addWidget(btn, posn.quot, posn.rem);
|
||||
}
|
||||
|
||||
grid->addLayout(tbgrid, row++, col++, Qt::AlignTop);
|
||||
|
||||
addGridBlankRow(grid, row);
|
||||
|
||||
// Note: options are defined by each layout but we do not have access to the definitions yet!
|
||||
// We assumed the first five to be the common options and the description of any extras is unknown
|
||||
|
||||
int cnt = SHOW_RAW_INFO ? MAX_LAYOUT_OPTIONS : LAYOUT_OPTION_LAST_DEFAULT + 1;
|
||||
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
QString str;
|
||||
switch(i) {
|
||||
case LAYOUT_OPTION_TOPBAR:
|
||||
str = tr("Top bar");
|
||||
break;
|
||||
case LAYOUT_OPTION_FM:
|
||||
str = tr("Flight mode");
|
||||
break;
|
||||
case LAYOUT_OPTION_SLIDERS:
|
||||
str = tr("Sliders");
|
||||
break;
|
||||
case LAYOUT_OPTION_TRIMS:
|
||||
str = tr("Trims");
|
||||
break;
|
||||
case LAYOUT_OPTION_MIRRORED:
|
||||
str = tr("Mirror");
|
||||
break;
|
||||
default:
|
||||
str = tr("Option #%1").arg(i + 1);
|
||||
}
|
||||
|
||||
col = 0;
|
||||
addGridLabel(grid, str, row, col++);
|
||||
|
||||
QCheckBox *chk = nullptr;
|
||||
QLabel *lbl = nullptr;
|
||||
|
||||
switch (lpd.options[i].type) {
|
||||
case ZOV_Bool:
|
||||
chk = new QCheckBox(this);
|
||||
chk->setChecked(lpd.options[i].value.boolValue);
|
||||
break;
|
||||
case ZOV_Unsigned:
|
||||
lbl = new QLabel(this);
|
||||
lbl->setText(QString("%1").arg(lpd.options[i].value.unsignedValue));
|
||||
break;
|
||||
case ZOV_Signed:
|
||||
lbl = new QLabel(this);
|
||||
lbl->setText(QString("%1").arg(lpd.options[i].value.signedValue));
|
||||
break;
|
||||
case ZOV_String:
|
||||
lbl = new QLabel(this);
|
||||
lbl->setText(lpd.options[i].value.stringValue);
|
||||
break;
|
||||
default:
|
||||
lbl = new QLabel(this);
|
||||
lbl->setText(QString("%1").arg(lpd.options[i].value.unsignedValue));
|
||||
}
|
||||
|
||||
if (chk) {
|
||||
chk->setEnabled(false);
|
||||
grid->addWidget(chk, row++, col++);
|
||||
}
|
||||
else {
|
||||
grid->addWidget(lbl, row++, col++);
|
||||
}
|
||||
}
|
||||
|
||||
// the grid must be fully built so the rowspan works
|
||||
foreach (QWidget * wgt, optswidgets) {
|
||||
grid->addWidget(wgt, widgetdetailsrow, widgetdetailscol, MAX_WIDGET_OPTIONS + 2/*title and column headings*/, Qt::AlignTop);
|
||||
}
|
||||
|
||||
addHSpring(grid, grid->columnCount(), 0);
|
||||
addVSpring(grid, 0, grid->rowCount());
|
||||
disableMouseScrolling();
|
||||
|
||||
if (firstenabledbtn >= 0)
|
||||
widgetbtns.at(firstenabledbtn)->click();
|
||||
}
|
||||
|
||||
CustomScreenPanel::~CustomScreenPanel()
|
||||
{
|
||||
foreach (QGridLayout * grid, optsgrids) {
|
||||
delete grid;
|
||||
}
|
||||
foreach (QFrame * wgt, optswidgets) {
|
||||
delete wgt;
|
||||
}
|
||||
foreach (QPushButton * btn, widgetbtns) {
|
||||
delete btn;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
ColorCustomScreensPanel
|
||||
*/
|
||||
|
||||
ColorCustomScreensPanel::ColorCustomScreensPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware,
|
||||
CompoundItemModelFactory * sharedItemModels):
|
||||
ModelPanel(parent, model, generalSettings, firmware)
|
||||
{
|
||||
grid = new QGridLayout(this);
|
||||
tabWidget = new QTabWidget(this);
|
||||
|
||||
UserInterfacePanel * tab = new UserInterfacePanel(tabWidget, model, generalSettings, firmware);
|
||||
tab->setProperty("index", 0);
|
||||
tabWidget->addTab(tab, getTabName(0));
|
||||
panels << tab;
|
||||
|
||||
for (int i = 0; i < MAX_CUSTOM_SCREENS; i++) {
|
||||
CustomScreenPanel * tab = new CustomScreenPanel(tabWidget, model, i, generalSettings, firmware);
|
||||
tab->setProperty("index", i + 1);
|
||||
tabWidget->addTab(tab, getTabName(i + 1));
|
||||
panels << tab;
|
||||
}
|
||||
|
||||
grid->addWidget(tabWidget, 0, 0, 1, 1);
|
||||
}
|
||||
|
||||
ColorCustomScreensPanel::~ColorCustomScreensPanel()
|
||||
{
|
||||
foreach (GenericPanel * pnl, panels) {
|
||||
delete pnl;
|
||||
}
|
||||
}
|
||||
|
||||
QString ColorCustomScreensPanel::getTabName(int index)
|
||||
{
|
||||
if (index == 0)
|
||||
return tr("User Interface");
|
||||
else
|
||||
return tr("Main View %1").arg(index);
|
||||
}
|
||||
|
||||
void addGridLine(QGridLayout * grid, int row, int col, int colspan)
|
||||
{
|
||||
QFrame *line = new QFrame();
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
line->setLineWidth(1);
|
||||
line->setMidLineWidth(0);
|
||||
grid->addWidget(line, row, col, 1, colspan);
|
||||
}
|
||||
|
||||
void addGridLabel(QGridLayout * grid, QString text, int row, int col, int colspan)
|
||||
{
|
||||
QLabel * label = new QLabel();
|
||||
label->setText(text);
|
||||
grid->addWidget(label, row, col, 1, colspan, Qt::AlignTop);
|
||||
}
|
||||
|
||||
void addGridBlankRow(QGridLayout * grid, int & row)
|
||||
{
|
||||
addGridLabel(grid, QString(), row++, 0);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
QGridLayout * addOptionsLayout(T & persistentData, int optioncnt, QString title)
|
||||
{
|
||||
QGridLayout * grid = new QGridLayout();
|
||||
|
||||
int row = 0;
|
||||
int col = 0;
|
||||
|
||||
if (!title.isEmpty()) {
|
||||
QLabel * label = new QLabel();
|
||||
label->setFrameShape(QFrame::Panel);
|
||||
label->setFrameShadow(QFrame::Plain);
|
||||
label->setAlignment(Qt::AlignCenter);
|
||||
label->setMinimumHeight(30);
|
||||
label->setMaximumHeight(30);
|
||||
label->setText(title);
|
||||
grid->addWidget(label, row++, col, 1, 2, Qt::AlignTop);
|
||||
}
|
||||
|
||||
addGridLabel(grid, "Option", row, col++);
|
||||
//addGridLabel(grid, "Type", row, col++);
|
||||
addGridLabel(grid, "Value", row++, col++);
|
||||
|
||||
for (int i = 0; i < optioncnt; i++) {
|
||||
ZoneOptionValueTyped & zovt = persistentData.options[i];
|
||||
|
||||
int col = 0;
|
||||
addGridLabel(grid, QString("#%1").arg(i + 1), row, col++);
|
||||
//addGridLabel(grid, QString("%1:%2").arg(zovt.type).arg(zoneOptionValueEnumToString(zovt.type)), row, col++);
|
||||
QString val;
|
||||
|
||||
switch (zovt.type) {
|
||||
case ZOV_Bool:
|
||||
val = QString("%1").arg(zovt.value.boolValue);
|
||||
break;
|
||||
case ZOV_Unsigned:
|
||||
val = QString("%1").arg(zovt.value.unsignedValue);
|
||||
break;
|
||||
case ZOV_Signed:
|
||||
val = QString("%1").arg(zovt.value.signedValue);
|
||||
break;
|
||||
case ZOV_String:
|
||||
val = QString("%1").arg(zovt.value.stringValue);
|
||||
break;
|
||||
default:
|
||||
val = QString("%1").arg(zovt.value.unsignedValue);
|
||||
}
|
||||
|
||||
addGridLabel(grid, QString("%1").arg(val), row++, col++);
|
||||
}
|
||||
|
||||
return grid;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
class UserInterfacePanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
UserInterfacePanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~UserInterfacePanel();
|
||||
|
||||
private:
|
||||
QGridLayout * grid;
|
||||
int currindex = -1;
|
||||
QVector<QPushButton *> widgetbtns;
|
||||
QVector<QFrame *> optswidgets;
|
||||
QVector<QGridLayout *> optsgrids;
|
||||
};
|
||||
|
||||
class CustomScreenPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CustomScreenPanel(QWidget *parent, ModelData & model, int index, GeneralSettings & generalSettings, Firmware * firmware);
|
||||
virtual ~CustomScreenPanel();
|
||||
|
||||
private:
|
||||
QGridLayout * grid;
|
||||
int currindex = -1;
|
||||
QVector<QPushButton *> widgetbtns;
|
||||
QVector<QFrame *> optswidgets;
|
||||
QVector<QGridLayout *> optsgrids;
|
||||
};
|
||||
|
||||
class ColorCustomScreensPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ColorCustomScreensPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware,
|
||||
CompoundItemModelFactory * sharedItemModels);
|
||||
virtual ~ColorCustomScreensPanel();
|
||||
|
||||
private:
|
||||
QTabWidget *tabWidget;
|
||||
QGridLayout * grid;
|
||||
QVector<GenericPanel *> panels;
|
||||
|
||||
QString getTabName(int index);
|
||||
};
|
||||
|
||||
void addGridLabel(QGridLayout * grid, QString text, int row, int col, int colspan = 1);
|
||||
void addGridBlankRow(QGridLayout * grid, int & row);
|
||||
void addGridLine(QGridLayout * grid, int row, int col, int colspan);
|
||||
|
||||
template <class T>
|
||||
QGridLayout * addOptionsLayout(T & persistentData, int optioncnt, QString title = "");
|
||||
@@ -149,13 +149,18 @@ CurvesPanel::CurvesPanel(QWidget * parent, ModelData & model, GeneralSettings &
|
||||
QPushButton * edit = new QPushButton(this);
|
||||
edit->setProperty("index", i);
|
||||
|
||||
QString style = QString(
|
||||
"QPushButton {"
|
||||
#ifdef __GNUC__
|
||||
// creates more compact and likely consistent buttons across OS flavors
|
||||
edit->setStyleSheet(QString("background-color: %1; color: white; padding: 2px 3px; border-style: outset; border-width: 1px; border-radius: 2px; border-color: inherit;").arg(colors[i].name()));
|
||||
"background-color: %1; color: white; padding: 2px 3px; border-style: outset; border-width: 1px; border-radius: 2px; border-color: inherit;"
|
||||
#else
|
||||
edit->setStyleSheet(QString("background-color: %1; color: white;").arg(colors[i].name()));
|
||||
"background-color: %1; color: white;"
|
||||
#endif
|
||||
"}"
|
||||
"QToolTip { background: white; color: black; }");
|
||||
|
||||
edit->setStyleSheet(style.arg(colors[i].name()));
|
||||
edit->setText(tr("Curve %1").arg(i + 1));
|
||||
edit->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
edit->setToolTip(tr("Popup menu available"));
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
#include "logicalswitches.h"
|
||||
#include "customfunctions.h"
|
||||
#include "telemetry.h"
|
||||
#include "colorcustomscreens.h"
|
||||
#include "telemetry_customscreens.h"
|
||||
#include "appdata.h"
|
||||
#include "compounditemmodels.h"
|
||||
|
||||
@@ -104,6 +106,15 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw
|
||||
s1.report("Telemetry");
|
||||
}
|
||||
|
||||
if (Boards::getCapability(firmware->getBoard(), Board::HasColorLcd)) {
|
||||
addTab(new ColorCustomScreensPanel(this, model, generalSettings, firmware, sharedItemModels), tr("Custom Screens"));
|
||||
s1.report("ColorLcd Custom Screens");
|
||||
}
|
||||
else if (firmware->getCapability(TelemetryCustomScreens)) {
|
||||
addTab(new TelemetryCustomScreensPanel(this, model, generalSettings, firmware, sharedItemModels), tr("Custom Screens"));
|
||||
s1.report("Telemetry Custom Screens");
|
||||
}
|
||||
|
||||
connect(setupPanel, &SetupPanel::extendedLimitsToggled, channelsPanel, &ChannelsPanel::refreshExtendedLimits);
|
||||
connect(ui->tabWidget, &QTabWidget::currentChanged, this, &ModelEdit::onTabIndexChanged);
|
||||
connect(ui->pushButton, &QPushButton::clicked, this, &ModelEdit::launchSimulation);
|
||||
|
||||
@@ -57,8 +57,12 @@ TimerPanel::TimerPanel(QWidget * parent, ModelData & model, TimerData & timer, G
|
||||
ui->value->setField(timer.val, this);
|
||||
ui->value->setMaximumTime(firmware->getMaxTimerStart());
|
||||
|
||||
ui->mode->setModel(panelFilteredModels->getItemModel(FIM_TIMERSWITCH));
|
||||
ui->mode->setModel(panelItemModels->getItemModel(AIM_TIMER_MODE));
|
||||
ui->mode->setField(timer.mode, this);
|
||||
connect(ui->mode, SIGNAL(currentDataChanged(int)), this, SLOT(onModeChanged(int)));
|
||||
|
||||
ui->swtch->setModel(panelFilteredModels->getItemModel(FIM_TIMERSWITCH));
|
||||
ui->swtch->setField(timer.swtch, this);
|
||||
|
||||
ui->countdownBeep->setModel(panelItemModels->getItemModel(AIM_TIMER_COUNTDOWNBEEP));
|
||||
ui->countdownBeep->setField(timer.countdownBeep, this);
|
||||
@@ -102,11 +106,17 @@ void TimerPanel::update()
|
||||
|
||||
ui->name->updateValue();
|
||||
ui->mode->updateValue();
|
||||
ui->swtch->updateValue();
|
||||
ui->value->updateValue();
|
||||
ui->countdownBeep->updateValue();
|
||||
ui->minuteBeep->updateValue();
|
||||
ui->countdownStart->updateValue();
|
||||
|
||||
if (timer.mode == TimerData::TIMERMODE_ON || timer.mode == TimerData::TIMERMODE_START)
|
||||
ui->swtch->setEnabled(true);
|
||||
else
|
||||
ui->swtch->setEnabled(false);
|
||||
|
||||
if (timer.countdownBeep == TimerData::COUNTDOWNBEEP_SILENT) {
|
||||
ui->countdownStartLabel->setEnabled(false);
|
||||
ui->countdownStart->setEnabled(false);
|
||||
@@ -161,6 +171,12 @@ void TimerPanel::onCountdownBeepChanged(int index)
|
||||
update();
|
||||
}
|
||||
|
||||
void TimerPanel::onModeChanged(int index)
|
||||
{
|
||||
timer.modeChanged();
|
||||
update();
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#define FAILSAFE_CHANNEL_HOLD 2000
|
||||
@@ -998,7 +1014,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
panelFilteredModels = new FilteredItemModelFactory();
|
||||
|
||||
panelFilteredModels->registerItemModel(new FilteredItemModel(sharedItemModels->getItemModel(AbstractItemModel::IMID_RawSwitch),
|
||||
RawSwitch::TimersContext),
|
||||
RawSwitch::AllSwitchContexts),
|
||||
FIM_TIMERSWITCH);
|
||||
connectItemModelEvents(panelFilteredModels->getItemModel(FIM_TIMERSWITCH));
|
||||
|
||||
@@ -1010,6 +1026,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
panelItemModels->registerItemModel(TimerData::countdownBeepItemModel());
|
||||
panelItemModels->registerItemModel(TimerData::countdownStartItemModel());
|
||||
panelItemModels->registerItemModel(TimerData::persistentItemModel());
|
||||
panelItemModels->registerItemModel(TimerData::modeItemModel());
|
||||
|
||||
Board::Type board = firmware->getBoard();
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ class TimerPanel : public ModelPanel
|
||||
void onItemModelAboutToBeUpdated();
|
||||
void onItemModelUpdateComplete();
|
||||
void onCountdownBeepChanged(int index);
|
||||
void onModeChanged(int index);
|
||||
|
||||
signals:
|
||||
void nameChanged();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>874</width>
|
||||
<width>1047</width>
|
||||
<height>33</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -58,6 +58,9 @@
|
||||
<item>
|
||||
<widget class="AutoComboBox" name="mode"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AutoComboBox" name="swtch"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="countdownBeepLabel">
|
||||
<property name="text">
|
||||
|
||||
@@ -20,13 +20,10 @@
|
||||
|
||||
#include "telemetry.h"
|
||||
#include "ui_telemetry.h"
|
||||
#include "ui_telemetry_customscreen.h"
|
||||
#include "ui_telemetry_sensor.h"
|
||||
#include "helpers.h"
|
||||
#include "appdata.h"
|
||||
|
||||
#include <TimerEdit>
|
||||
|
||||
constexpr char FIM_RAWSOURCE[] {"Raw Source"};
|
||||
constexpr char FIM_TELEALLSRC[] {"Tele All Source"};
|
||||
constexpr char FIM_TELEPOSSRC[] {"Tele Pos Source"};
|
||||
@@ -37,294 +34,6 @@ constexpr char FIM_SENSORUNIT[] {"Sensor.Unit"};
|
||||
constexpr char FIM_SENSORPRECISION[] {"Sensor.Precision"};
|
||||
constexpr char FIM_RSSISOURCE[] {"Rssi Source"};
|
||||
|
||||
TelemetryCustomScreen::TelemetryCustomScreen(QWidget *parent, ModelData & model, FrSkyScreenData & screen, GeneralSettings & generalSettings,
|
||||
Firmware * firmware, const bool & parentLock, FilteredItemModelFactory * panelFilteredItemModels):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
ui(new Ui::TelemetryCustomScreen),
|
||||
screen(screen),
|
||||
modelsUpdateCnt(0),
|
||||
parentLock(parentLock)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
FilteredItemModel * rawSourceFilteredModel = panelFilteredItemModels->getItemModel(FIM_RAWSOURCE);
|
||||
connectItemModelEvents(rawSourceFilteredModel);
|
||||
|
||||
for (int l = 0; l < firmware->getCapability(TelemetryCustomScreensLines); l++) {
|
||||
for (int c = 0; c < firmware->getCapability(TelemetryCustomScreensFieldsPerLine); c++) {
|
||||
fieldsCB[l][c] = new QComboBox(this);
|
||||
fieldsCB[l][c]->setProperty("index", c + (l << 8));
|
||||
fieldsCB[l][c]->setModel(rawSourceFilteredModel);
|
||||
ui->screenNumsLayout->addWidget(fieldsCB[l][c], l, c, 1, 1);
|
||||
connect(fieldsCB[l][c], SIGNAL(activated(int)), this, SLOT(customFieldChanged(int)));
|
||||
}
|
||||
}
|
||||
|
||||
for (int l = 0; l < firmware->getCapability(TelemetryCustomScreensBars); l++) {
|
||||
barsCB[l] = new QComboBox(this);
|
||||
barsCB[l]->setProperty("index", l);
|
||||
barsCB[l]->setModel(rawSourceFilteredModel);
|
||||
connect(barsCB[l], SIGNAL(activated(int)), this, SLOT(barSourceChanged(int)));
|
||||
ui->screenBarsLayout->addWidget(barsCB[l], l, 0, 1, 1);
|
||||
|
||||
minSB[l] = new QDoubleSpinBox(this);
|
||||
minSB[l]->setProperty("index", l);
|
||||
connect(minSB[l], SIGNAL(valueChanged(double)), this, SLOT(barMinChanged(double)));
|
||||
ui->screenBarsLayout->addWidget(minSB[l], l, 1, 1, 1);
|
||||
|
||||
minTime[l] = new TimerEdit(this);
|
||||
minTime[l]->setProperty("index", l);
|
||||
minTime[l]->setProperty("type", "min");
|
||||
connect(minTime[l], SIGNAL(editingFinished()), this, SLOT(barTimeChanged()));
|
||||
ui->screenBarsLayout->addWidget(minTime[l], l, 1, 1, 1);
|
||||
minTime[l]->hide();
|
||||
|
||||
QLabel * label = new QLabel(this);
|
||||
label->setAutoFillBackground(false);
|
||||
label->setStyleSheet(QString::fromUtf8("Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),)\n"""));
|
||||
label->setFrameShape(QFrame::Panel);
|
||||
label->setFrameShadow(QFrame::Raised);
|
||||
label->setAlignment(Qt::AlignCenter);
|
||||
ui->screenBarsLayout->addWidget(label, l, 2, 1, 1);
|
||||
|
||||
maxSB[l] = new QDoubleSpinBox(this);
|
||||
maxSB[l]->setProperty("index", l);
|
||||
connect(maxSB[l], SIGNAL(valueChanged(double)), this, SLOT(barMaxChanged(double)));
|
||||
ui->screenBarsLayout->addWidget(maxSB[l], l, 3, 1, 1);
|
||||
|
||||
maxTime[l] = new TimerEdit(this);
|
||||
maxTime[l]->setProperty("index", l);
|
||||
maxTime[l]->setProperty("type", "max");
|
||||
connect(maxTime[l], SIGNAL(editingFinished()), this, SLOT(barTimeChanged()));
|
||||
ui->screenBarsLayout->addWidget(maxTime[l], l, 3, 1, 1);
|
||||
maxTime[l]->hide();
|
||||
}
|
||||
|
||||
disableMouseScrolling();
|
||||
|
||||
lock = true;
|
||||
ui->screenType->addItem(tr("None"), TELEMETRY_SCREEN_NONE);
|
||||
ui->screenType->addItem(tr("Numbers"), TELEMETRY_SCREEN_NUMBERS);
|
||||
ui->screenType->addItem(tr("Bars"), TELEMETRY_SCREEN_BARS);
|
||||
if (IS_TARANIS(firmware->getBoard()))
|
||||
ui->screenType->addItem(tr("Script"), TELEMETRY_SCREEN_SCRIPT);
|
||||
ui->screenType->setField(screen.type, this);
|
||||
lock = false;
|
||||
|
||||
if (IS_TARANIS(firmware->getBoard())) {
|
||||
QSet<QString> scriptsSet = getFilesSet(g.profile[g.id()].sdPath() + "/SCRIPTS/TELEMETRY", QStringList() << "*.lua", 6);
|
||||
Helpers::populateFileComboBox(ui->scriptName, scriptsSet, screen.body.script.filename);
|
||||
connect(ui->scriptName, SIGNAL(currentIndexChanged(int)), this, SLOT(scriptNameEdited()));
|
||||
connect(ui->scriptName, SIGNAL(editTextChanged ( const QString)), this, SLOT(scriptNameEdited()));
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
TelemetryCustomScreen::~TelemetryCustomScreen()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TelemetryCustomScreen::update()
|
||||
{
|
||||
lock = true;
|
||||
|
||||
ui->scriptName->setVisible(screen.type == TELEMETRY_SCREEN_SCRIPT);
|
||||
ui->screenNums->setVisible(screen.type == TELEMETRY_SCREEN_NUMBERS);
|
||||
ui->screenBars->setVisible(screen.type == TELEMETRY_SCREEN_BARS);
|
||||
|
||||
for (int l = 0; l < firmware->getCapability(TelemetryCustomScreensLines); l++) {
|
||||
for (int c = 0; c < firmware->getCapability(TelemetryCustomScreensFieldsPerLine); c++) {
|
||||
fieldsCB[l][c]->setCurrentIndex(fieldsCB[l][c]->findData(screen.body.lines[l].source[c].toValue()));
|
||||
}
|
||||
}
|
||||
|
||||
for (int l = 0; l < firmware->getCapability(TelemetryCustomScreensBars); l++) {
|
||||
barsCB[l]->setCurrentIndex(barsCB[l]->findData(screen.body.bars[l].source.toValue()));
|
||||
}
|
||||
|
||||
if (screen.type == TELEMETRY_SCREEN_BARS) {
|
||||
for (int i = 0; i < firmware->getCapability(TelemetryCustomScreensBars); i++) {
|
||||
updateBar(i);
|
||||
}
|
||||
}
|
||||
|
||||
lock = false;
|
||||
}
|
||||
|
||||
void TelemetryCustomScreen::updateBar(int line)
|
||||
{
|
||||
lock = true;
|
||||
|
||||
RawSource source = screen.body.bars[line].source;
|
||||
|
||||
minTime[line]->setVisible(false);
|
||||
maxTime[line]->setVisible(false);
|
||||
|
||||
if (source.type != SOURCE_TYPE_NONE) {
|
||||
RawSourceRange range = source.getRange(model, generalSettings);
|
||||
float minVal = range.getValue(screen.body.bars[line].barMin);
|
||||
float maxVal = screen.body.bars[line].barMax;
|
||||
maxVal = range.getValue(maxVal);
|
||||
|
||||
if (source.isTimeBased()) {
|
||||
minTime[line]->setVisible(true);
|
||||
minTime[line]->setTimeRange(range.min, range.max);
|
||||
minTime[line]->setSingleStep(range.step);
|
||||
minTime[line]->setPageStep(range.step * 60);
|
||||
minTime[line]->setShowSeconds(range.step != 60);
|
||||
minTime[line]->setTime((int)minVal);
|
||||
|
||||
maxTime[line]->setVisible(true);
|
||||
maxTime[line]->setTimeRange(range.min, range.max);
|
||||
maxTime[line]->setSingleStep(range.step);
|
||||
maxTime[line]->setPageStep(range.step * 60);
|
||||
maxTime[line]->setShowSeconds(range.step != 60);
|
||||
maxTime[line]->setTime((int)maxVal);
|
||||
|
||||
minSB[line]->setVisible(false);
|
||||
maxSB[line]->setVisible(false);
|
||||
}
|
||||
else {
|
||||
minSB[line]->setVisible(true);
|
||||
minSB[line]->setEnabled(true);
|
||||
minSB[line]->setDecimals(range.decimals);
|
||||
minSB[line]->setMinimum(range.min);
|
||||
minSB[line]->setMaximum(range.max);
|
||||
minSB[line]->setSingleStep(range.step);
|
||||
minSB[line]->setSuffix(" " + range.unit);
|
||||
minSB[line]->setValue(minVal);
|
||||
|
||||
maxSB[line]->setVisible(true);
|
||||
maxSB[line]->setEnabled(true);
|
||||
maxSB[line]->setDecimals(range.decimals);
|
||||
maxSB[line]->setMinimum(range.min);
|
||||
maxSB[line]->setMaximum(range.max);
|
||||
maxSB[line]->setSingleStep(range.step);
|
||||
maxSB[line]->setSuffix(" " + range.unit);
|
||||
maxSB[line]->setValue(maxVal);
|
||||
}
|
||||
}
|
||||
else {
|
||||
minSB[line]->setDisabled(true);
|
||||
maxSB[line]->setDisabled(true);
|
||||
}
|
||||
|
||||
lock = false;
|
||||
}
|
||||
|
||||
void TelemetryCustomScreen::on_screenType_currentIndexChanged(int index)
|
||||
{
|
||||
if (!isLocked()) {
|
||||
memset(reinterpret_cast<void *>(&screen.body), 0, sizeof(screen.body));
|
||||
update();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryCustomScreen::scriptNameEdited()
|
||||
{
|
||||
if (!isLocked()) {
|
||||
lock = true;
|
||||
Helpers::getFileComboBoxValue(ui->scriptName, screen.body.script.filename, 8);
|
||||
emit modified();
|
||||
lock = false;
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryCustomScreen::customFieldChanged(int value)
|
||||
{
|
||||
if (isLocked() || !sender() || !qobject_cast<QComboBox *>(sender()))
|
||||
return;
|
||||
|
||||
bool ok;
|
||||
const int index = sender()->property("index").toInt(&ok),
|
||||
i = index / 256,
|
||||
m = index % 256;
|
||||
const RawSource src(qobject_cast<QComboBox *>(sender())->itemData(value).toInt());
|
||||
if (ok && screen.body.lines[i].source[m].toValue() != src.toValue()) {
|
||||
screen.body.lines[i].source[m] = src;
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryCustomScreen::barSourceChanged(int value)
|
||||
{
|
||||
if (isLocked() || !sender() || !qobject_cast<QComboBox *>(sender()))
|
||||
return;
|
||||
|
||||
bool ok;
|
||||
const int index = sender()->property("index").toInt(&ok);
|
||||
const RawSource src(qobject_cast<QComboBox *>(sender())->itemData(value).toInt());
|
||||
if (!ok || screen.body.bars[index].source.toValue() == src.toValue())
|
||||
return;
|
||||
|
||||
screen.body.bars[index].source = src;
|
||||
screen.body.bars[index].barMin = 0;
|
||||
screen.body.bars[index].barMax = 0;
|
||||
updateBar(index);
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TelemetryCustomScreen::barMinChanged(double value)
|
||||
{
|
||||
if (!isLocked()) {
|
||||
int line = sender()->property("index").toInt();
|
||||
screen.body.bars[line].barMin = round(value / minSB[line]->singleStep());
|
||||
// TODO set min (maxSB)
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryCustomScreen::barMaxChanged(double value)
|
||||
{
|
||||
if (!isLocked()) {
|
||||
int line = sender()->property("index").toInt();
|
||||
screen.body.bars[line].barMax = round((value) / maxSB[line]->singleStep());
|
||||
// TODO set max (minSB)
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryCustomScreen::barTimeChanged()
|
||||
{
|
||||
if (!isLocked()) {
|
||||
int line = sender()->property("index").toInt();
|
||||
int & valRef = (sender()->property("type").toString() == "min" ? screen.body.bars[line].barMin : screen.body.bars[line].barMax);
|
||||
TimerEdit * te = qobject_cast<TimerEdit *>(sender());
|
||||
if (!te)
|
||||
return;
|
||||
|
||||
valRef = round(te->timeInSeconds() / te->singleStep());
|
||||
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryCustomScreen::connectItemModelEvents(const FilteredItemModel * itemModel)
|
||||
{
|
||||
connect(itemModel, &FilteredItemModel::aboutToBeUpdated, this, &TelemetryCustomScreen::onItemModelAboutToBeUpdated);
|
||||
connect(itemModel, &FilteredItemModel::updateComplete, this, &TelemetryCustomScreen::onItemModelUpdateComplete);
|
||||
}
|
||||
|
||||
void TelemetryCustomScreen::onItemModelAboutToBeUpdated()
|
||||
{
|
||||
lock = true;
|
||||
modelsUpdateCnt++;
|
||||
}
|
||||
|
||||
void TelemetryCustomScreen::onItemModelUpdateComplete()
|
||||
{
|
||||
modelsUpdateCnt--;
|
||||
if (modelsUpdateCnt < 1) {
|
||||
// leave updating to parent
|
||||
lock = false;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************/
|
||||
|
||||
TelemetrySensorPanel::TelemetrySensorPanel(QWidget *parent, SensorData & sensor, int sensorIndex, int sensorCapability, ModelData & model,
|
||||
GeneralSettings & generalSettings, Firmware * firmware, const bool & parentLock,
|
||||
FilteredItemModelFactory * panelFilteredItemModels) :
|
||||
@@ -755,14 +464,6 @@ TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettin
|
||||
ui->topbarGB->hide();
|
||||
}
|
||||
|
||||
for (int i = 0; i < firmware->getCapability(TelemetryCustomScreens); i++) {
|
||||
TelemetryCustomScreen * tab = new TelemetryCustomScreen(this, model, model.frsky.screens[i], generalSettings, firmware, lock,
|
||||
panelFilteredItemModels);
|
||||
ui->customScreens->addTab(tab, tr("Telemetry screen %1").arg(i + 1));
|
||||
telemetryCustomScreens[i] = tab;
|
||||
connect(tab, &TelemetryCustomScreen::modified, this, &TelemetryPanel::onModified);
|
||||
}
|
||||
|
||||
disableMouseScrolling();
|
||||
|
||||
setup();
|
||||
@@ -798,10 +499,6 @@ void TelemetryPanel::update()
|
||||
sensorPanels[i]->update();
|
||||
}
|
||||
|
||||
for (int i = 0; i < firmware->getCapability(TelemetryCustomScreens); i++) {
|
||||
telemetryCustomScreens[i]->update();
|
||||
}
|
||||
|
||||
lock = false;
|
||||
}
|
||||
|
||||
@@ -901,8 +598,6 @@ void TelemetryPanel::on_frskyProtoCB_currentIndexChanged(int index)
|
||||
{
|
||||
if (!isLocked()) {
|
||||
model->frsky.usrProto = index;
|
||||
for (int i = 0; i < firmware->getCapability(TelemetryCustomScreens); i++)
|
||||
telemetryCustomScreens[i]->update();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,49 +30,10 @@ class AutoComboBox;
|
||||
class TimerEdit;
|
||||
|
||||
namespace Ui {
|
||||
class TelemetryCustomScreen;
|
||||
class TelemetrySensor;
|
||||
class Telemetry;
|
||||
}
|
||||
|
||||
class TelemetryCustomScreen: public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TelemetryCustomScreen(QWidget *parent, ModelData & model, FrSkyScreenData & screen, GeneralSettings & generalSettings, Firmware * firmware,
|
||||
const bool & parentLock, FilteredItemModelFactory * panelFilteredItemModels);
|
||||
~TelemetryCustomScreen();
|
||||
void update();
|
||||
|
||||
private slots:
|
||||
void on_screenType_currentIndexChanged(int index);
|
||||
void scriptNameEdited();
|
||||
void customFieldChanged(int index);
|
||||
void barSourceChanged(int index);
|
||||
void barMinChanged(double value);
|
||||
void barMaxChanged(double value);
|
||||
void barTimeChanged();
|
||||
void onItemModelAboutToBeUpdated();
|
||||
void onItemModelUpdateComplete();
|
||||
|
||||
private:
|
||||
void updateBar(int line);
|
||||
Ui::TelemetryCustomScreen * ui;
|
||||
FrSkyScreenData & screen;
|
||||
QComboBox * fieldsCB[4][3];
|
||||
QComboBox * barsCB[4];
|
||||
QDoubleSpinBox * minSB[4];
|
||||
QDoubleSpinBox * maxSB[4];
|
||||
TimerEdit * minTime[4];
|
||||
TimerEdit * maxTime[4];
|
||||
int modelsUpdateCnt;
|
||||
const bool &parentLock;
|
||||
|
||||
inline bool isLocked() { return lock | parentLock; }
|
||||
void connectItemModelEvents(const FilteredItemModel * itemModel);
|
||||
};
|
||||
|
||||
class TelemetrySensorPanel: public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -165,7 +126,6 @@ class TelemetryPanel : public ModelPanel
|
||||
|
||||
private:
|
||||
Ui::Telemetry *ui;
|
||||
TelemetryCustomScreen *telemetryCustomScreens[4];
|
||||
TelemetrySensorPanel *sensorPanels[CPN_MAX_SENSORS];
|
||||
int sensorCapability;
|
||||
CompoundItemModelFactory *sharedItemModels;
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>861</width>
|
||||
<height>737</height>
|
||||
<height>742</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0,0,0,0,0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0,0,0,0">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
@@ -999,19 +999,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="customScreens">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
@@ -1059,7 +1046,6 @@
|
||||
<tabstop>frskyVoltCB</tabstop>
|
||||
<tabstop>frskyCurrentCB</tabstop>
|
||||
<tabstop>bladesCount</tabstop>
|
||||
<tabstop>customScreens</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Custom Screen Type</string>
|
||||
<string>Type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -124,6 +124,19 @@
|
||||
<layout class="QGridLayout" name="screenNumsLayout"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
||||
@@ -0,0 +1,405 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "telemetry_customscreens.h"
|
||||
#include "ui_telemetry_customscreen.h"
|
||||
#include "helpers.h"
|
||||
#include "appdata.h"
|
||||
|
||||
#include <TimerEdit>
|
||||
|
||||
constexpr char FIM_RAWSOURCE[] {"Raw Source"};
|
||||
|
||||
CustomScreen::CustomScreen(QWidget *parent, ModelData & model, FrSkyScreenData & screen, GeneralSettings & generalSettings,
|
||||
Firmware * firmware, const bool & parentLock, FilteredItemModelFactory * panelFilteredItemModels):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
ui(new Ui::TelemetryCustomScreen),
|
||||
screen(screen),
|
||||
modelsUpdateCnt(0),
|
||||
parentLock(parentLock)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
FilteredItemModel * rawSourceFilteredModel = panelFilteredItemModels->getItemModel(FIM_RAWSOURCE);
|
||||
connectItemModelEvents(rawSourceFilteredModel);
|
||||
|
||||
for (int l = 0; l < firmware->getCapability(TelemetryCustomScreensLines); l++) {
|
||||
for (int c = 0; c < firmware->getCapability(TelemetryCustomScreensFieldsPerLine); c++) {
|
||||
fieldsCB[l][c] = new QComboBox(this);
|
||||
fieldsCB[l][c]->setProperty("index", c + (l << 8));
|
||||
fieldsCB[l][c]->setModel(rawSourceFilteredModel);
|
||||
ui->screenNumsLayout->addWidget(fieldsCB[l][c], l, c, 1, 1);
|
||||
connect(fieldsCB[l][c], SIGNAL(activated(int)), this, SLOT(customFieldChanged(int)));
|
||||
}
|
||||
}
|
||||
|
||||
for (int l = 0; l < firmware->getCapability(TelemetryCustomScreensBars); l++) {
|
||||
barsCB[l] = new QComboBox(this);
|
||||
barsCB[l]->setProperty("index", l);
|
||||
barsCB[l]->setModel(rawSourceFilteredModel);
|
||||
connect(barsCB[l], SIGNAL(activated(int)), this, SLOT(barSourceChanged(int)));
|
||||
ui->screenBarsLayout->addWidget(barsCB[l], l+1, 0, 1, 1);
|
||||
|
||||
minSB[l] = new QDoubleSpinBox(this);
|
||||
minSB[l]->setProperty("index", l);
|
||||
connect(minSB[l], SIGNAL(valueChanged(double)), this, SLOT(barMinChanged(double)));
|
||||
ui->screenBarsLayout->addWidget(minSB[l], l+1, 1, 1, 1);
|
||||
|
||||
minTime[l] = new TimerEdit(this);
|
||||
minTime[l]->setProperty("index", l);
|
||||
minTime[l]->setProperty("type", "min");
|
||||
connect(minTime[l], SIGNAL(editingFinished()), this, SLOT(barTimeChanged()));
|
||||
ui->screenBarsLayout->addWidget(minTime[l], l+1, 1, 1, 1);
|
||||
minTime[l]->hide();
|
||||
|
||||
QLabel * label = new QLabel(this);
|
||||
label->setAutoFillBackground(false);
|
||||
label->setStyleSheet(QString::fromUtf8("Background:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 128, 255), stop:0.339795 rgba(0, 0, 128, 255), stop:0.339799 rgba(255, 255, 255, 255), stop:0.662444 rgba(255, 255, 255, 255),)\n"""));
|
||||
label->setFrameShape(QFrame::Panel);
|
||||
label->setFrameShadow(QFrame::Raised);
|
||||
label->setAlignment(Qt::AlignCenter);
|
||||
ui->screenBarsLayout->addWidget(label, l+1, 2, 1, 1);
|
||||
|
||||
maxSB[l] = new QDoubleSpinBox(this);
|
||||
maxSB[l]->setProperty("index", l);
|
||||
connect(maxSB[l], SIGNAL(valueChanged(double)), this, SLOT(barMaxChanged(double)));
|
||||
ui->screenBarsLayout->addWidget(maxSB[l], l+1, 3, 1, 1);
|
||||
|
||||
maxTime[l] = new TimerEdit(this);
|
||||
maxTime[l]->setProperty("index", l);
|
||||
maxTime[l]->setProperty("type", "max");
|
||||
connect(maxTime[l], SIGNAL(editingFinished()), this, SLOT(barTimeChanged()));
|
||||
ui->screenBarsLayout->addWidget(maxTime[l], l+1, 3, 1, 1);
|
||||
maxTime[l]->hide();
|
||||
}
|
||||
|
||||
disableMouseScrolling();
|
||||
|
||||
lock = true;
|
||||
ui->screenType->addItem(tr("None"), TELEMETRY_SCREEN_NONE);
|
||||
ui->screenType->addItem(tr("Numbers"), TELEMETRY_SCREEN_NUMBERS);
|
||||
ui->screenType->addItem(tr("Bars"), TELEMETRY_SCREEN_BARS);
|
||||
if (IS_TARANIS(firmware->getBoard()))
|
||||
ui->screenType->addItem(tr("Script"), TELEMETRY_SCREEN_SCRIPT);
|
||||
ui->screenType->setField(screen.type, this);
|
||||
lock = false;
|
||||
|
||||
if (IS_TARANIS(firmware->getBoard())) {
|
||||
QSet<QString> scriptsSet = getFilesSet(g.profile[g.id()].sdPath() + "/SCRIPTS/TELEMETRY", QStringList() << "*.lua", 6);
|
||||
Helpers::populateFileComboBox(ui->scriptName, scriptsSet, screen.body.script.filename);
|
||||
connect(ui->scriptName, SIGNAL(currentIndexChanged(int)), this, SLOT(scriptNameEdited()));
|
||||
connect(ui->scriptName, SIGNAL(editTextChanged ( const QString)), this, SLOT(scriptNameEdited()));
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
CustomScreen::~CustomScreen()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CustomScreen::update()
|
||||
{
|
||||
lock = true;
|
||||
|
||||
ui->scriptName->setVisible(screen.type == TELEMETRY_SCREEN_SCRIPT);
|
||||
ui->screenNums->setVisible(screen.type == TELEMETRY_SCREEN_NUMBERS);
|
||||
ui->screenBars->setVisible(screen.type == TELEMETRY_SCREEN_BARS);
|
||||
|
||||
for (int l = 0; l < firmware->getCapability(TelemetryCustomScreensLines); l++) {
|
||||
for (int c = 0; c < firmware->getCapability(TelemetryCustomScreensFieldsPerLine); c++) {
|
||||
fieldsCB[l][c]->setCurrentIndex(fieldsCB[l][c]->findData(screen.body.lines[l].source[c].toValue()));
|
||||
}
|
||||
}
|
||||
|
||||
for (int l = 0; l < firmware->getCapability(TelemetryCustomScreensBars); l++) {
|
||||
barsCB[l]->setCurrentIndex(barsCB[l]->findData(screen.body.bars[l].source.toValue()));
|
||||
}
|
||||
|
||||
if (screen.type == TELEMETRY_SCREEN_BARS) {
|
||||
for (int i = 0; i < firmware->getCapability(TelemetryCustomScreensBars); i++) {
|
||||
updateBar(i);
|
||||
}
|
||||
}
|
||||
|
||||
lock = false;
|
||||
}
|
||||
|
||||
void CustomScreen::updateBar(int line)
|
||||
{
|
||||
lock = true;
|
||||
|
||||
RawSource source = screen.body.bars[line].source;
|
||||
|
||||
minTime[line]->setVisible(false);
|
||||
maxTime[line]->setVisible(false);
|
||||
|
||||
if (source.type != SOURCE_TYPE_NONE) {
|
||||
RawSourceRange range = source.getRange(model, generalSettings);
|
||||
float minVal = range.getValue(screen.body.bars[line].barMin);
|
||||
float maxVal = screen.body.bars[line].barMax;
|
||||
maxVal = range.getValue(maxVal);
|
||||
|
||||
if (source.isTimeBased()) {
|
||||
minTime[line]->setVisible(true);
|
||||
minTime[line]->setTimeRange(range.min, range.max);
|
||||
minTime[line]->setSingleStep(range.step);
|
||||
minTime[line]->setPageStep(range.step * 60);
|
||||
minTime[line]->setShowSeconds(range.step != 60);
|
||||
minTime[line]->setTime((int)minVal);
|
||||
|
||||
maxTime[line]->setVisible(true);
|
||||
maxTime[line]->setTimeRange(range.min, range.max);
|
||||
maxTime[line]->setSingleStep(range.step);
|
||||
maxTime[line]->setPageStep(range.step * 60);
|
||||
maxTime[line]->setShowSeconds(range.step != 60);
|
||||
maxTime[line]->setTime((int)maxVal);
|
||||
|
||||
minSB[line]->setVisible(false);
|
||||
maxSB[line]->setVisible(false);
|
||||
}
|
||||
else {
|
||||
minSB[line]->setVisible(true);
|
||||
minSB[line]->setEnabled(true);
|
||||
minSB[line]->setDecimals(range.decimals);
|
||||
minSB[line]->setMinimum(range.min);
|
||||
minSB[line]->setMaximum(range.max);
|
||||
minSB[line]->setSingleStep(range.step);
|
||||
minSB[line]->setSuffix(" " + range.unit);
|
||||
minSB[line]->setValue(minVal);
|
||||
|
||||
maxSB[line]->setVisible(true);
|
||||
maxSB[line]->setEnabled(true);
|
||||
maxSB[line]->setDecimals(range.decimals);
|
||||
maxSB[line]->setMinimum(range.min);
|
||||
maxSB[line]->setMaximum(range.max);
|
||||
maxSB[line]->setSingleStep(range.step);
|
||||
maxSB[line]->setSuffix(" " + range.unit);
|
||||
maxSB[line]->setValue(maxVal);
|
||||
}
|
||||
}
|
||||
else {
|
||||
minSB[line]->setDisabled(true);
|
||||
maxSB[line]->setDisabled(true);
|
||||
}
|
||||
|
||||
lock = false;
|
||||
}
|
||||
|
||||
void CustomScreen::on_screenType_currentIndexChanged(int index)
|
||||
{
|
||||
if (!isLocked()) {
|
||||
memset(reinterpret_cast<void *>(&screen.body), 0, sizeof(screen.body));
|
||||
update();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void CustomScreen::scriptNameEdited()
|
||||
{
|
||||
if (!isLocked()) {
|
||||
lock = true;
|
||||
Helpers::getFileComboBoxValue(ui->scriptName, screen.body.script.filename, 8);
|
||||
emit modified();
|
||||
lock = false;
|
||||
}
|
||||
}
|
||||
|
||||
void CustomScreen::customFieldChanged(int value)
|
||||
{
|
||||
if (isLocked() || !sender() || !qobject_cast<QComboBox *>(sender()))
|
||||
return;
|
||||
|
||||
bool ok;
|
||||
const int index = sender()->property("index").toInt(&ok),
|
||||
i = index / 256,
|
||||
m = index % 256;
|
||||
const RawSource src(qobject_cast<QComboBox *>(sender())->itemData(value).toInt());
|
||||
if (ok && screen.body.lines[i].source[m].toValue() != src.toValue()) {
|
||||
screen.body.lines[i].source[m] = src;
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void CustomScreen::barSourceChanged(int value)
|
||||
{
|
||||
if (isLocked() || !sender() || !qobject_cast<QComboBox *>(sender()))
|
||||
return;
|
||||
|
||||
bool ok;
|
||||
const int index = sender()->property("index").toInt(&ok);
|
||||
const RawSource src(qobject_cast<QComboBox *>(sender())->itemData(value).toInt());
|
||||
if (!ok || screen.body.bars[index].source.toValue() == src.toValue())
|
||||
return;
|
||||
|
||||
screen.body.bars[index].source = src;
|
||||
screen.body.bars[index].barMin = 0;
|
||||
screen.body.bars[index].barMax = 0;
|
||||
updateBar(index);
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void CustomScreen::barMinChanged(double value)
|
||||
{
|
||||
if (!isLocked()) {
|
||||
int line = sender()->property("index").toInt();
|
||||
screen.body.bars[line].barMin = round(value / minSB[line]->singleStep());
|
||||
// TODO set min (maxSB)
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void CustomScreen::barMaxChanged(double value)
|
||||
{
|
||||
if (!isLocked()) {
|
||||
int line = sender()->property("index").toInt();
|
||||
screen.body.bars[line].barMax = round((value) / maxSB[line]->singleStep());
|
||||
// TODO set max (minSB)
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void CustomScreen::barTimeChanged()
|
||||
{
|
||||
if (!isLocked()) {
|
||||
int line = sender()->property("index").toInt();
|
||||
int & valRef = (sender()->property("type").toString() == "min" ? screen.body.bars[line].barMin : screen.body.bars[line].barMax);
|
||||
TimerEdit * te = qobject_cast<TimerEdit *>(sender());
|
||||
if (!te)
|
||||
return;
|
||||
|
||||
valRef = round(te->timeInSeconds() / te->singleStep());
|
||||
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void CustomScreen::connectItemModelEvents(const FilteredItemModel * itemModel)
|
||||
{
|
||||
connect(itemModel, &FilteredItemModel::aboutToBeUpdated, this, &CustomScreen::onItemModelAboutToBeUpdated);
|
||||
connect(itemModel, &FilteredItemModel::updateComplete, this, &CustomScreen::onItemModelUpdateComplete);
|
||||
}
|
||||
|
||||
void CustomScreen::onItemModelAboutToBeUpdated()
|
||||
{
|
||||
lock = true;
|
||||
modelsUpdateCnt++;
|
||||
}
|
||||
|
||||
void CustomScreen::onItemModelUpdateComplete()
|
||||
{
|
||||
modelsUpdateCnt--;
|
||||
if (modelsUpdateCnt < 1) {
|
||||
// leave updating to parent
|
||||
lock = false;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************/
|
||||
|
||||
TelemetryCustomScreensPanel::TelemetryCustomScreensPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware,
|
||||
CompoundItemModelFactory * sharedItemModels):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
sharedItemModels(sharedItemModels),
|
||||
modelsUpdateCnt(0)
|
||||
{
|
||||
panelFilteredItemModels = new FilteredItemModelFactory();
|
||||
int id;
|
||||
|
||||
id = panelFilteredItemModels->registerItemModel(new FilteredItemModel(sharedItemModels->getItemModel(AbstractItemModel::IMID_RawSource)),
|
||||
FIM_RAWSOURCE);
|
||||
connectItemModelEvents(id);
|
||||
|
||||
grid = new QGridLayout(this);
|
||||
tabWidget = new QTabWidget(this);
|
||||
|
||||
for (int i = 0; i < firmware->getCapability(TelemetryCustomScreens); i++) {
|
||||
CustomScreen * tab = new CustomScreen(this, model, model.frsky.screens[i], generalSettings, firmware, lock,
|
||||
panelFilteredItemModels);
|
||||
tab->setProperty("index", i + 1);
|
||||
tabWidget->addTab(tab, getTabName(i + 1));
|
||||
panels << tab;
|
||||
connect(tab, &CustomScreen::modified, this, &TelemetryCustomScreensPanel::onModified);
|
||||
}
|
||||
|
||||
grid->addWidget(tabWidget, 0, 0, 1, 1);
|
||||
|
||||
addHSpring(grid, grid->columnCount(), 0);
|
||||
addVSpring(grid, 0, grid->rowCount());
|
||||
disableMouseScrolling();
|
||||
}
|
||||
|
||||
TelemetryCustomScreensPanel::~TelemetryCustomScreensPanel()
|
||||
{
|
||||
delete panelFilteredItemModels;
|
||||
foreach(GenericPanel * gp, panels) {
|
||||
delete gp;
|
||||
}
|
||||
}
|
||||
|
||||
QString TelemetryCustomScreensPanel::getTabName(int index)
|
||||
{
|
||||
return tr("Telemetry screen %1").arg(index);
|
||||
}
|
||||
|
||||
void TelemetryCustomScreensPanel::update()
|
||||
{
|
||||
lock = true;
|
||||
|
||||
foreach(GenericPanel * pnl, panels) {
|
||||
pnl->update();
|
||||
}
|
||||
|
||||
lock = false;
|
||||
}
|
||||
|
||||
void TelemetryCustomScreensPanel::onModified()
|
||||
{
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TelemetryCustomScreensPanel::on_dataModifiedSensor()
|
||||
{
|
||||
sharedItemModels->update(AbstractItemModel::IMUE_TeleSensors);
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void TelemetryCustomScreensPanel::connectItemModelEvents(const int id)
|
||||
{
|
||||
FilteredItemModel * itemModel = panelFilteredItemModels->getItemModel(id);
|
||||
connect(itemModel, &FilteredItemModel::aboutToBeUpdated, this, &TelemetryCustomScreensPanel::onItemModelAboutToBeUpdated);
|
||||
connect(itemModel, &FilteredItemModel::updateComplete, this, &TelemetryCustomScreensPanel::onItemModelUpdateComplete);
|
||||
}
|
||||
|
||||
void TelemetryCustomScreensPanel::onItemModelAboutToBeUpdated()
|
||||
{
|
||||
lock = true;
|
||||
modelsUpdateCnt++;
|
||||
}
|
||||
|
||||
void TelemetryCustomScreensPanel::onItemModelUpdateComplete()
|
||||
{
|
||||
modelsUpdateCnt--;
|
||||
if (modelsUpdateCnt < 1) {
|
||||
update();
|
||||
lock = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "modeledit.h"
|
||||
#include "eeprominterface.h"
|
||||
#include "filtereditemmodels.h"
|
||||
|
||||
class AutoComboBox;
|
||||
class TimerEdit;
|
||||
|
||||
namespace Ui {
|
||||
class TelemetryCustomScreen;
|
||||
}
|
||||
|
||||
class CustomScreen: public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CustomScreen(QWidget *parent, ModelData & model, FrSkyScreenData & screen, GeneralSettings & generalSettings, Firmware * firmware,
|
||||
const bool & parentLock, FilteredItemModelFactory * panelFilteredItemModels);
|
||||
~CustomScreen();
|
||||
void update();
|
||||
|
||||
private slots:
|
||||
void on_screenType_currentIndexChanged(int index);
|
||||
void scriptNameEdited();
|
||||
void customFieldChanged(int index);
|
||||
void barSourceChanged(int index);
|
||||
void barMinChanged(double value);
|
||||
void barMaxChanged(double value);
|
||||
void barTimeChanged();
|
||||
void onItemModelAboutToBeUpdated();
|
||||
void onItemModelUpdateComplete();
|
||||
|
||||
private:
|
||||
void updateBar(int line);
|
||||
Ui::TelemetryCustomScreen * ui;
|
||||
FrSkyScreenData & screen;
|
||||
QComboBox * fieldsCB[4][3];
|
||||
QComboBox * barsCB[4];
|
||||
QDoubleSpinBox * minSB[4];
|
||||
QDoubleSpinBox * maxSB[4];
|
||||
TimerEdit * minTime[4];
|
||||
TimerEdit * maxTime[4];
|
||||
int modelsUpdateCnt;
|
||||
const bool &parentLock;
|
||||
|
||||
inline bool isLocked() { return lock | parentLock; }
|
||||
void connectItemModelEvents(const FilteredItemModel * itemModel);
|
||||
};
|
||||
|
||||
class TelemetryCustomScreensPanel : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TelemetryCustomScreensPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware,
|
||||
CompoundItemModelFactory * sharedItemModels);
|
||||
virtual ~TelemetryCustomScreensPanel();
|
||||
virtual void update();
|
||||
|
||||
signals:
|
||||
void updated();
|
||||
|
||||
private slots:
|
||||
void onModified();
|
||||
void on_dataModifiedSensor();
|
||||
void onItemModelAboutToBeUpdated();
|
||||
void onItemModelUpdateComplete();
|
||||
|
||||
private:
|
||||
CompoundItemModelFactory *sharedItemModels;
|
||||
FilteredItemModelFactory *panelFilteredItemModels;
|
||||
int modelsUpdateCnt;
|
||||
|
||||
QTabWidget *tabWidget;
|
||||
QGridLayout *grid;
|
||||
QVector<GenericPanel *> panels;
|
||||
|
||||
QString getTabName(int index);
|
||||
|
||||
void setup();
|
||||
void telBarUpdate();
|
||||
void connectItemModelEvents(const int id);
|
||||
inline bool isLocked() { return lock; }
|
||||
};
|
||||
Reference in New Issue
Block a user