From 71706d5e9334afc6cb3c647d8dea9eec76a285dd Mon Sep 17 00:00:00 2001 From: Grieb Date: Sat, 15 Aug 2015 11:13:57 -0300 Subject: [PATCH 1/2] Cosmetcs. (editor save removes trailing spaces) --- companion/src/wizarddialog.cpp | 30 ++++++++++---------- companion/src/wizarddialog.h | 50 +++++++++++++++++----------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/companion/src/wizarddialog.cpp b/companion/src/wizarddialog.cpp index ad46d1fb0..c49dd2565 100644 --- a/companion/src/wizarddialog.cpp +++ b/companion/src/wizarddialog.cpp @@ -1,6 +1,6 @@ /* * Author - Kjell Kernen - * + * * 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. @@ -214,7 +214,7 @@ bool StandardPage::bookChannel(QComboBox * cb, Input input1, int weight1, Input { int channel = cb->itemData(cb->currentIndex()).toInt(); if (channel<0 || channel>=WIZ_MAX_CHANNELS) - return false; + return false; if (wizDlg->mix.channel[channel].page != Page_None) return false; @@ -231,7 +231,7 @@ void StandardPage::releaseBookings() { for (int i=0; imix.channel[i].page == pageCurrent) { - wizDlg->mix.channel[i].clear(); + wizDlg->mix.channel[i].clear(); } } } @@ -298,7 +298,7 @@ bool ModelSelectionPage::validatePage() return true; } -int ModelSelectionPage::nextId() const +int ModelSelectionPage::nextId() const { if (helicopterRB->isChecked()) return Page_Cyclic; @@ -432,7 +432,7 @@ AileronsPage::AileronsPage(WizardDialog *dlg, QString image, QString title, QStr l->addWidget(aileron1CB); l->addWidget(new QLabel(tr("Second Aileron Channel:"))); l->addWidget(aileron2CB); - + connect(noAileronsRB, SIGNAL(toggled(bool)), this, SLOT(noAileronChannel())); connect(oneAileronRB, SIGNAL(toggled(bool)), this, SLOT(oneAileronChannel())); connect(twoAileronsRB, SIGNAL(toggled(bool)), this, SLOT(twoAileronChannels())); @@ -448,10 +448,10 @@ void AileronsPage::initializePage() bool AileronsPage::validatePage() { releaseBookings(); - if (noAileronsRB->isChecked()) { + if (noAileronsRB->isChecked()) { return true; } - if (oneAileronRB->isChecked()) { + if (oneAileronRB->isChecked()) { return (bookChannel(aileron1CB, AILERONS_INPUT, 100 )); } return( bookChannel(aileron1CB, AILERONS_INPUT, 100 ) && @@ -497,7 +497,7 @@ FlapsPage::FlapsPage(WizardDialog *dlg, QString image, QString title, QString te l->addWidget(flap1CB); l->addWidget(new QLabel(tr("Second Flap Channel:"))); l->addWidget(flap2CB); - + connect(noFlapsRB, SIGNAL(toggled(bool)), this, SLOT(noFlapChannel())); connect(oneFlapRB, SIGNAL(toggled(bool)), this, SLOT(oneFlapChannel())); connect(twoFlapsRB, SIGNAL(toggled(bool)), this, SLOT(twoFlapChannels())); @@ -512,10 +512,10 @@ void FlapsPage::initializePage() bool FlapsPage::validatePage() { releaseBookings(); - if (noFlapsRB->isChecked()) { + if (noFlapsRB->isChecked()) { return true; } - if (oneFlapRB->isChecked()) { + if (oneFlapRB->isChecked()) { return (bookChannel(flap1CB, FLAPS_INPUT, 100 )); } return( bookChannel(flap1CB, FLAPS_INPUT, 100 ) && @@ -561,7 +561,7 @@ AirbrakesPage::AirbrakesPage(WizardDialog *dlg, QString image, QString title, QS l->addWidget(airbrake1CB); l->addWidget(new QLabel(tr("Second Airbrake Channel:"))); l->addWidget(airbrake2CB); - + connect(noAirbrakesRB, SIGNAL(toggled(bool)), this, SLOT(noAirbrakeChannel())); connect(oneAirbrakeRB, SIGNAL(toggled(bool)), this, SLOT(oneAirbrakeChannel())); connect(twoAirbrakesRB, SIGNAL(toggled(bool)), this, SLOT(twoAirbrakeChannels())); @@ -577,10 +577,10 @@ void AirbrakesPage::initializePage() bool AirbrakesPage::validatePage() { releaseBookings(); - if (noAirbrakesRB->isChecked()) { + if (noAirbrakesRB->isChecked()) { return true; } - if (oneAirbrakeRB->isChecked()) { + if (oneAirbrakeRB->isChecked()) { return (bookChannel(airbrake1CB, AIRBRAKES_INPUT, 100 )); } return( bookChannel(airbrake1CB, AIRBRAKES_INPUT, 100 ) && @@ -731,7 +731,7 @@ bool TailPage::validatePage() SimpleTailPage::SimpleTailPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage) : StandardPage(Page_Simpletail, dlg, image, title, text, nextPage) -{ +{ elevatorCB = new QComboBox(); QLayout *l = layout(); @@ -1001,7 +1001,7 @@ WizardPrinter::WizardPrinter(WizMix *wizMix) { mix = wizMix; } - + QString WizardPrinter::printChannel( Input input1, int weight1, Input input2, int weight2 ) { QString str; diff --git a/companion/src/wizarddialog.h b/companion/src/wizarddialog.h index 8e1f2146f..0b3c4f9c1 100644 --- a/companion/src/wizarddialog.h +++ b/companion/src/wizarddialog.h @@ -1,6 +1,6 @@ /* * Author - Kjell Kernen - * + * * 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. @@ -15,7 +15,7 @@ #ifndef WIZARDDIALOG_H #define WIZARDDIALOG_H #include -#include "wizarddata.h" +#include "wizarddata.h" QT_BEGIN_NAMESPACE class QCheckBox; @@ -46,7 +46,7 @@ class StandardPage: public QWizardPage StandardPage(WizardPage curPage, WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); WizardDialog *wizDlg; - protected: + protected: void releaseBookings(); void releasePreBookings(); void initializePage(); @@ -67,48 +67,48 @@ class ModelSelectionPage: public StandardPage { Q_OBJECT public: - ModelSelectionPage(WizardDialog *dlg, QString image, QString title, QString text); + ModelSelectionPage(WizardDialog *dlg, QString image, QString title, QString text); private: QLineEdit *nameLineEdit; QRadioButton *planeRB; QRadioButton *multirotorRB; QRadioButton *helicopterRB; bool validatePage(); - int nextId() const; + int nextId() const; }; class WingtypeSelectionPage: public StandardPage { Q_OBJECT public: - WingtypeSelectionPage(WizardDialog *dlg, QString image, QString title, QString text); + WingtypeSelectionPage(WizardDialog *dlg, QString image, QString title, QString text); private: QRadioButton *deltaWingRB; QRadioButton *standardWingRB; - int nextId() const; + int nextId() const; }; class TailSelectionPage: public StandardPage { Q_OBJECT public: - TailSelectionPage(WizardDialog *dlg, QString image, QString title, QString text); + TailSelectionPage(WizardDialog *dlg, QString image, QString title, QString text); private: QRadioButton *vTailRB; QRadioButton *standardTailRB; QRadioButton *simpleTailRB; - int nextId() const; + int nextId() const; }; class FlybarSelectionPage: public StandardPage { Q_OBJECT public: - FlybarSelectionPage(WizardDialog *dlg, QString image, QString title, QString text); + FlybarSelectionPage(WizardDialog *dlg, QString image, QString title, QString text); private: QRadioButton *flybarRB; QRadioButton *noFlybarRB; - int nextId() const; + int nextId() const; }; class ThrottlePage: public StandardPage @@ -133,10 +133,10 @@ class AileronsPage: public StandardPage { Q_OBJECT public: - AileronsPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); + AileronsPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); void initializePage(); bool validatePage(); - + protected slots: void noAileronChannel(); void oneAileronChannel(); @@ -154,7 +154,7 @@ class FlapsPage: public StandardPage { Q_OBJECT public: - FlapsPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); + FlapsPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); void initializePage(); bool validatePage(); @@ -175,7 +175,7 @@ class AirbrakesPage: public StandardPage { Q_OBJECT public: - AirbrakesPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); + AirbrakesPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); void initializePage(); bool validatePage(); @@ -229,7 +229,7 @@ class TailPage: public StandardPage { Q_OBJECT public: - TailPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); + TailPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); void initializePage(); bool validatePage(); private: @@ -241,7 +241,7 @@ class VTailPage: public StandardPage { Q_OBJECT public: - VTailPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); + VTailPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); void initializePage(); bool validatePage(); private: @@ -253,7 +253,7 @@ class SimpleTailPage: public StandardPage { Q_OBJECT public: - SimpleTailPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); + SimpleTailPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); void initializePage(); bool validatePage(); private: @@ -264,7 +264,7 @@ class CyclicPage: public StandardPage { Q_OBJECT public: - CyclicPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); + CyclicPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); void initializePage(); bool validatePage(); private: @@ -278,7 +278,7 @@ class GyroPage: public StandardPage { Q_OBJECT public: - GyroPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); + GyroPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); void initializePage(); bool validatePage(); private: @@ -291,7 +291,7 @@ class FblPage: public StandardPage { Q_OBJECT public: - FblPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); + FblPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); void initializePage(); bool validatePage(); private: @@ -305,7 +305,7 @@ class HeliPage: public StandardPage { Q_OBJECT public: - HeliPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); + HeliPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); void initializePage(); bool validatePage(); private: @@ -319,7 +319,7 @@ class MultirotorPage: public StandardPage { Q_OBJECT public: - MultirotorPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); + MultirotorPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); void initializePage(); bool validatePage(); private: @@ -333,7 +333,7 @@ class OptionsPage: public StandardPage { Q_OBJECT public: - OptionsPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); + OptionsPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); void initializePage(); bool validatePage(); private: @@ -346,7 +346,7 @@ class ConclusionPage: public StandardPage { Q_OBJECT public: - ConclusionPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); + ConclusionPage(WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); void initializePage(); bool validatePage(); private: From 56bc0d817fc402af5879f6b0a4e55cc8331ba864 Mon Sep 17 00:00:00 2001 From: Grieb Date: Sat, 14 Mar 2015 16:37:20 -0300 Subject: [PATCH 2/2] 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