From 56bc0d817fc402af5879f6b0a4e55cc8331ba864 Mon Sep 17 00:00:00 2001 From: Grieb Date: Sat, 14 Mar 2015 16:37:20 -0300 Subject: [PATCH] Fix #2091 --- companion/src/wizarddialog.cpp | 32 +++++++++++++++++++++++++++++++- companion/src/wizarddialog.h | 4 ++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/companion/src/wizarddialog.cpp b/companion/src/wizarddialog.cpp index c49dd2565..179efa974 100644 --- a/companion/src/wizarddialog.cpp +++ b/companion/src/wizarddialog.cpp @@ -181,6 +181,16 @@ int StandardPage::nextFreeChannel(int channel) return -1; } +int StandardPage::totalChannelsAvailable() +{ + int c = 0; + for(int i=0; imix.channel[i].page == Page_None) + c++; + + return c; +} + void StandardPage::populateCB(QComboBox *cb, int preferred) { cb->clear(); @@ -708,11 +718,13 @@ TailPage::TailPage(WizardDialog *dlg, QString image, QString title, QString text elevatorCB = new QComboBox(); rudderCB = new QComboBox(); - QLayout *l = layout(); + l = layout(); l->addWidget(new QLabel(tr("Rudder Channel:"))); l->addWidget(rudderCB); l->addWidget(new QLabel(tr("Elevator Channel:"))); l->addWidget(elevatorCB); + + errorMessage = NULL; } void TailPage::initializePage() @@ -720,6 +732,13 @@ void TailPage::initializePage() populateCB(elevatorCB, getDefaultChannel(ELEVATOR_INPUT)); populateCB(rudderCB, getDefaultChannel(RUDDER_INPUT)); StandardPage::initializePage(); + + if (totalChannelsAvailable() < 2) { + errorMessage = new QLabel(tr("Only one channel still available!
" + "You probably should configure your model without using the wizard.")); + errorMessage->setStyleSheet("QLabel { color : red; }"); + l->addWidget(errorMessage); + } } bool TailPage::validatePage() @@ -729,6 +748,17 @@ bool TailPage::validatePage() bookChannel(rudderCB, RUDDER_INPUT, 100)); } +void TailPage::cleanupPage() +{ + if (errorMessage) + { + l->removeWidget(errorMessage); + delete errorMessage; + errorMessage = NULL; + } + StandardPage::cleanupPage(); +} + SimpleTailPage::SimpleTailPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage) : StandardPage(Page_Simpletail, dlg, image, title, text, nextPage) { diff --git a/companion/src/wizarddialog.h b/companion/src/wizarddialog.h index 0b3c4f9c1..f96f170ba 100644 --- a/companion/src/wizarddialog.h +++ b/companion/src/wizarddialog.h @@ -55,6 +55,7 @@ class StandardPage: public QWizardPage int nextFreeChannel(int channel = 0); void populateCB(QComboBox * cb, int preferred=-1); bool bookChannel(QComboBox * cb, Input input1, int weight1, Input input2=NO_INPUT, int weight2=0); + int totalChannelsAvailable(); private: QLabel *topLabel; @@ -231,10 +232,13 @@ class TailPage: public StandardPage public: TailPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); void initializePage(); + void cleanupPage(); bool validatePage(); private: QComboBox *elevatorCB; QComboBox *rudderCB; + QLayout *l; + QLabel *errorMessage; }; class VTailPage: public StandardPage