1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 16:25:16 +03:00

Virtual Inputs added inside Companion

This commit is contained in:
Bertrand Songis 2014-01-20 21:54:38 +01:00
parent efa484a710
commit 6bba2b14ca
13 changed files with 101 additions and 64 deletions

View file

@ -8,7 +8,8 @@ contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnu
{
ui->setupUi(this);
switch (contest) {
case 0: {
case 0:
{
QFile file(":/DONATIONS.txt");
QString str;
str.append("<html><head>");
@ -20,7 +21,7 @@ contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnu
str.append("<tr><td class=\"myhead\">"+tr("People who have contributed to this project")+"</td></tr>");
str.append("</table>");
str.append("<table width=\"100%\" border=0 cellspacing=0 cellpadding=2>");
if(file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
int columns=6;
float cwidth=100.0/columns;
while (!file.atEnd()) {
@ -66,26 +67,29 @@ contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnu
}
}
str.append("<tr><td class=\"mycss\">&nbsp;</td></tr>");
str.append("<tr><td colspan=3 class=\"mycss\">"+tr("Honors go to Rafal Tomczak (RadioClone) and Thomas Husterer (th9x) \nof course. Also to Erez Raviv (er9x) and it's fantastic eePe, from which\nOpenTX Companion was forked out.")+"</td></tr>");
str.append("<tr><td colspan=3 class=\"mycss\">"+tr("Thank you all !!!")+"</td></tr>");
str.append("<tr><td colspan=3 class=\"mycss\">" + tr("Honors go to Rafal Tomczak (RadioClone), Thomas Husterer (th9x) and Erez Raviv (er9x and eePe)") + "<br/></td></tr>");
str.append("<tr><td colspan=3 class=\"mycss\">" + tr("Thank you all !!!") + "</td></tr>");
str.append("</table>");
str.append("</body></html>");
ui->textEditor->setHtml(str);
ui->textEditor->scroll(0,0);
this->setWindowTitle(tr("Contributors"));
}
ui->textEditor->scroll(0, 0);
setWindowTitle(tr("Contributors"));
break;
}
case 1:{
case 1:
{
QFile file(":/releasenotes.txt");
if(file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
ui->textEditor->setHtml(file.readAll());
}
ui->textEditor->scroll(0,0);
this->setWindowTitle(tr("Companion Release Notes"));
}
setWindowTitle(tr("Companion Release Notes"));
break;
case 2:{
}
case 2:
{
if (!rnurl.isEmpty()) {
this->setWindowTitle(tr("OpenTX Release Notes"));
manager = new QNetworkAccessManager(this);
@ -94,7 +98,8 @@ contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnu
QNetworkRequest request(url);
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
manager->get(request);
} else {
}
else {
QTimer::singleShot(0, this, SLOT(forceClose()));
}
break;
@ -104,7 +109,7 @@ contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnu
void contributorsDialog::showEvent ( QShowEvent * )
{
ui->textEditor->scroll(0,0);
ui->textEditor->scroll(0, 0);
}
contributorsDialog::~contributorsDialog()
@ -117,6 +122,7 @@ void contributorsDialog::replyFinished(QNetworkReply * reply)
ui->textEditor->setHtml(reply->readAll());
}
void contributorsDialog::forceClose() {
void contributorsDialog::forceClose()
{
accept();;
}

View file

@ -287,7 +287,12 @@ QString RawSource::toString()
if (index<0) {
return QObject::tr("----");
}
switch(type) {
switch (type) {
case SOURCE_TYPE_VIRTUAL_INPUT:
if (model && strlen(model->inputNames[index]) > 0)
return QString(model->inputNames[index]);
else
return QObject::tr("Virtual Input %1").arg(index+1);
case SOURCE_TYPE_STICK:
return AnalogString(index);
case SOURCE_TYPE_TRIM:

View file

@ -286,19 +286,22 @@ class RawSource {
public:
RawSource():
type(SOURCE_TYPE_NONE),
index(0)
index(0),
model(NULL)
{
}
RawSource(int value):
RawSource(int value, const ModelData * model=NULL):
type(RawSourceType(abs(value)/65536)),
index(value >= 0 ? abs(value)%65536 : -(abs(value)%65536))
index(value >= 0 ? abs(value)%65536 : -(abs(value)%65536)),
model(model)
{
}
RawSource(RawSourceType type, int index=0):
RawSource(RawSourceType type, int index=0, const ModelData * model=NULL):
type(type),
index(index)
index(index),
model(model)
{
}
@ -322,6 +325,7 @@ class RawSource {
RawSourceType type;
int index;
const ModelData * model;
};
enum RawSwitchType {

View file

@ -399,7 +399,7 @@ void populateFuncParamArmTCB(QComboBox *b, ModelData * g_model, char * value, QS
}
}
void populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsigned int adjustmode)
void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode)
{
QStringList qs;
b->clear();
@ -423,18 +423,18 @@ void populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsign
b->setCurrentIndex(value);
}
else if (function==FuncVolume) {
populateSourceCB(b, RawSource(value), POPULATE_SOURCES|POPULATE_TRIMS);
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_TRIMS);
}
else if (function==FuncPlayValue) {
populateSourceCB(b, RawSource(value), POPULATE_SOURCES|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRYEXT);
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRYEXT);
}
else if (function>=FuncAdjustGV1 && function<=FuncAdjustGVLast) {
switch (adjustmode) {
case 1:
populateSourceCB(b, RawSource(value), POPULATE_SOURCES|POPULATE_TRIMS|POPULATE_SWITCHES);
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_TRIMS|POPULATE_SWITCHES);
break;
case 2:
populateSourceCB(b, RawSource(value), POPULATE_GVARS);
populateSourceCB(b, RawSource(value), model, POPULATE_GVARS);
break;
case 3:
b->clear();
@ -998,8 +998,7 @@ void populateGVCB(QComboBox *b, int value)
b->setCurrentIndex(nullitem);
}
void populateSourceCB(QComboBox *b, const RawSource &source, unsigned int flags)
void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData & model, unsigned int flags)
{
RawSource item;
@ -1009,7 +1008,18 @@ void populateSourceCB(QComboBox *b, const RawSource &source, unsigned int flags)
item = RawSource(SOURCE_TYPE_NONE);
b->addItem(item.toString(), item.toValue());
if (item == source) b->setCurrentIndex(b->count()-1);
}
if (flags & POPULATE_VIRTUAL_INPUTS) {
int virtualInputs = GetEepromInterface()->getCapability(VirtualInputs);
for (int i=0; i<virtualInputs; i++) {
item = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, i, &model);
b->addItem(item.toString(), item.toValue());
if (item == source) b->setCurrentIndex(b->count()-1);
}
}
if (flags & POPULATE_SOURCES) {
for (int i=0; i<4+GetEepromInterface()->getCapability(Pots); i++) {
item = RawSource(SOURCE_TYPE_STICK, i);
b->addItem(item.toString(), item.toValue());

View file

@ -87,7 +87,7 @@ void populateFuncCB(QComboBox *b, unsigned int value);
void populateRepeatCB(QComboBox *b, unsigned int value);
void populateGVmodeCB(QComboBox *b, unsigned int value);
QString FuncParam(uint function, int value, QString paramT="",unsigned int adjustmode=0);
void populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsigned int adjustmode=0);
void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode=0);
void populateFuncParamArmTCB(QComboBox *b, ModelData * g_model, char * value, QStringList & paramsList);
void populatePhasesCB(QComboBox *b, int value);
void populateTrimUseCB(QComboBox *b, unsigned int phase);
@ -104,13 +104,14 @@ QString getPhasesStr(unsigned int phases, ModelData & model);
#define POPULATE_GVARS 8
#define POPULATE_TELEMETRY 16
#define POPULATE_TELEMETRYEXT 32
#define POPULATE_VIRTUAL_INPUTS 64
#define GVARS_VARIANT 0x0001
#define FRSKY_VARIANT 0x0002
// void populateGVarCB(QComboBox *b, int value, int min, int max,int pgvars=5); //TODO: Clean Up
void populateGVCB(QComboBox *b, int value);
void populateSourceCB(QComboBox *b, const RawSource &source, unsigned int flags);
void populateSourceCB(QComboBox *b, const RawSource &source, const ModelData & model, unsigned int flags);
void populateCSWCB(QComboBox *b, int value);
QString getTimerMode(int tm);
QString getTimerModeB(int tm);

View file

@ -1537,7 +1537,7 @@ void MainWindow::about()
QString aboutStr = "<center><img src=\":/images/companion-title.png\"></center><br/>";
aboutStr.append(tr("OpenTX Home Page: <a href='%1'>%1</a>").arg("http://www.open-tx.org"));
aboutStr.append("<br/><br/>");
aboutStr.append(tr("The OpenTX Companion project was originally forked from <a href='%1'>companion9x</a> and <a href='%2'>eePe</a>").arg("http://code.google.com/p/companion9x").arg("http://code.google.com/p/eepe"));
aboutStr.append(tr("The OpenTX Companion project was originally forked from <a href='%2'>eePe</a>").arg("http://code.google.com/p/eepe"));
aboutStr.append("<br/><br/>");
aboutStr.append(tr("If you've found this program useful, please support by <a href='%1'>donating</a>").arg(DONATE_STR));
aboutStr.append("<br/><br/>");

View file

@ -110,7 +110,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
fswtchParamT[i] = new QComboBox(this);
fswtchParamT[i]->setProperty("index", i);
paramLayout->addWidget(fswtchParamT[i]);
populateFuncParamCB(fswtchParamT[i], func, model.funcSw[i].param, model.funcSw[i].adjustMode);
populateFuncParamCB(fswtchParamT[i], model, func, model.funcSw[i].param, model.funcSw[i].adjustMode);
connect(fswtchParamT[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
fswtchParamArmT[i] = new QComboBox(this);
@ -295,20 +295,24 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
fswtchParam[i]->setMaximum(125);
fswtchParam[i]->setValue(model.funcSw[i].param);
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM;
} else {
}
else {
if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param, model.funcSw[i].adjustMode);
populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param, model.funcSw[i].adjustMode);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
}
} else if (index==FuncReset) {
}
else if (index==FuncReset) {
if (modified) model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex();
populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param);
populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
} else if (index==FuncVolume) {
}
else if (index==FuncVolume) {
if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param);
populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_ENABLE;
} else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
}
else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
if (modified) model.funcSw[i].repeatParam = fswtchRepeat[i]->itemData(fswtchRepeat[i]->currentIndex()).toInt();
if (index != FuncBackgroundMusic) {
if (GetEepromInterface()->getCapability(HasFuncRepeat)) {
@ -317,7 +321,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
}
if (index==FuncPlayValue) {
if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param);
populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_REPEAT;
} else if (index==FuncPlayPrompt || index==FuncPlayBoth) {
if (GetEepromInterface()->getCapability(VoicesAsNumbers)) {
@ -374,16 +378,19 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
}
}
}
} else if (index==FuncPlaySound) {
}
else if (index==FuncPlaySound) {
if (modified) model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex();
populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
} else if (index==FuncPlayHaptic) {
if (modified) model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex();
populateFuncParamCB(fswtchParamT[i], index, model.funcSw[i].param);
populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
}
} else if (model.funcSw[i].swtch.type!=SWITCH_TYPE_NONE) {
else if (index==FuncPlayHaptic) {
if (modified) model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex();
populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param);
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
}
}
else if (model.funcSw[i].swtch.type!=SWITCH_TYPE_NONE) {
if (modified) model.funcSw[i].param = fswtchParam[i]->value();
fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1);

View file

@ -254,7 +254,7 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
cswitchSource2[i]->setVisible(false);
cswitchValue[i]->setVisible(false);
cswitchOffset[i]->setVisible(true);
populateSourceCB(cswitchSource1[i], source, POPULATE_SOURCES | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
populateSourceCB(cswitchSource1[i], source, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
cswitchOffset[i]->setDecimals(source.getDecimals(model));
cswitchOffset[i]->setSingleStep(source.getStep(model));
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
@ -280,8 +280,8 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
cswitchSource2[i]->setVisible(true);
cswitchValue[i]->setVisible(false);
cswitchOffset[i]->setVisible(false);
populateSourceCB(cswitchSource1[i], RawSource(model.customSw[i].val1), POPULATE_SOURCES | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
populateSourceCB(cswitchSource2[i], RawSource(model.customSw[i].val2), POPULATE_SOURCES | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
populateSourceCB(cswitchSource1[i], RawSource(model.customSw[i].val1), model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
populateSourceCB(cswitchSource2[i], RawSource(model.customSw[i].val2), model, POPULATE_SOURCES | POPULATE_TRIMS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
break;
case CS_FAMILY_TIMERS:
cswitchSource1[i]->setVisible(false);

View file

@ -48,7 +48,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, i
ui->sideLabel->hide();
ui->sideCB->hide();
ui->inputName->setMaxLength(4);
populateSourceCB(ui->sourceCB, ed->srcRaw, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | (GetEepromInterface()->getCapability(GvarsAsSources) ? POPULATE_GVARS : 0));
populateSourceCB(ui->sourceCB, ed->srcRaw, model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | (GetEepromInterface()->getCapability(GvarsAsSources) ? POPULATE_GVARS : 0));
ui->sourceCB->removeItem(0);
}
else {

View file

@ -26,7 +26,7 @@ void HeliPanel::update()
lock = true;
ui->swashTypeCB->setCurrentIndex(model.swashRingData.type);
populateSourceCB(ui->swashCollectiveCB, model.swashRingData.collectiveSource, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS);
populateSourceCB(ui->swashCollectiveCB, model.swashRingData.collectiveSource, model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS);
ui->swashRingValSB->setValue(model.swashRingData.value);
ui->swashInvertELE->setChecked(model.swashRingData.invertELE);
ui->swashInvertAIL->setChecked(model.swashRingData.invertAIL);

View file

@ -3,9 +3,10 @@
#include "eeprominterface.h"
#include "helpers.h"
MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, int stickMode) :
QDialog(parent),
ui(new Ui::MixerDialog),
model(model),
md(mixdata),
lock(false)
{
@ -19,7 +20,7 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
else
this->setWindowTitle(tr("DEST -> CH%1%2").arg(md->destCh/10).arg(md->destCh%10));
populateSourceCB(ui->sourceCB, md->srcRaw, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | (GetEepromInterface()->getCapability(GvarsAsSources) ? POPULATE_GVARS : 0));
populateSourceCB(ui->sourceCB, md->srcRaw, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS | (GetEepromInterface()->getCapability(GvarsAsSources) ? POPULATE_GVARS : 0));
ui->sourceCB->removeItem(0);
int limit = GetEepromInterface()->getCapability(OffsetWeight);
@ -145,16 +146,18 @@ void MixerDialog::valuesChanged()
if (!lock) {
lock = true;
QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };
md->srcRaw = RawSource(ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt());
md->srcRaw = RawSource(ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt(), &model);
if ((ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt()-65536)<4) {
if (!GetEepromInterface()->getCapability(MixesWithoutExpo)) {
ui->MixDR_CB->hide();
ui->label_MixDR->hide();
} else {
}
else {
ui->MixDR_CB->setVisible(true);
ui->label_MixDR->setVisible(true);
}
} else {
}
else {
ui->MixDR_CB->setHidden(true);
ui->label_MixDR->setHidden(true);
}

View file

@ -14,7 +14,7 @@ namespace Ui {
class MixerDialog : public QDialog {
Q_OBJECT
public:
MixerDialog(QWidget *parent, MixData *mixdata, int stickMode);
MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, int stickMode);
~MixerDialog();
protected:
@ -26,6 +26,7 @@ class MixerDialog : public QDialog {
private:
Ui::MixerDialog *ui;
ModelData & model;
MixData *md;
bool lock;
GVarGroup * gvWeightGroup;

View file

@ -204,7 +204,7 @@ void MixesPanel::gm_openMix(int index)
emit modified();
update();
MixerDialog *g = new MixerDialog(this, &mixd, generalSettings.stickMode);
MixerDialog *g = new MixerDialog(this, model, &mixd, generalSettings.stickMode);
if(g->exec()) {
model.mixData[index] = mixd;
emit modified();