The wizard should use the channel order defined in preferences

This commit is contained in:
bsongis
2014-03-14 14:54:45 +01:00
parent 8a38c6a13b
commit eb0cb8312a
2 changed files with 48 additions and 27 deletions
+25 -12
View File
@@ -18,7 +18,8 @@
WizardDialog::WizardDialog(const GeneralSettings & settings, unsigned int modelId, QWidget *parent) WizardDialog::WizardDialog(const GeneralSettings & settings, unsigned int modelId, QWidget *parent)
: QWizard(parent), : QWizard(parent),
mix(settings, modelId) mix(settings, modelId),
settings(settings)
{ {
setWindowTitle(tr("Model Wizard")); setWindowTitle(tr("Model Wizard"));
@@ -123,14 +124,13 @@ void WizardDialog::showHelp()
} }
StandardPage::StandardPage(WizardPage currentPage, WizardDialog *dlg, QString image, QString title, QString text, int nextPage ) StandardPage::StandardPage(WizardPage currentPage, WizardDialog *dlg, QString image, QString title, QString text, int nextPage )
: QWizardPage() : QWizardPage(),
wizDlg(dlg),
pageCurrent(currentPage),
pageFollower(nextPage)
{ {
pageCurrent = currentPage;
pageFollower = nextPage;
wizDlg = dlg;
setTitle(title); setTitle(title);
setPixmap(QWizard::WatermarkPixmap, QPixmap(QString(":/images/wizard/") + image + QString(".png"))); setPixmap(QWizard::WatermarkPixmap, QPixmap(QString(":/images/wizard/%1.png").arg(image)));
topLabel = new QLabel(text+"<br>"); topLabel = new QLabel(text+"<br>");
topLabel->setWordWrap(true); topLabel->setWordWrap(true);
@@ -139,14 +139,27 @@ StandardPage::StandardPage(WizardPage currentPage, WizardDialog *dlg, QString im
setLayout(layout); setLayout(layout);
} }
void StandardPage::populateCB( QComboBox *CB ) int StandardPage::getDefaultChannel(const Input input)
{ {
for (int j=0; j<WIZ_MAX_CHANNELS; j++) for (int channel=0; channel<4; channel++) {
CB->removeItem(0); unsigned int stick_index = chout_ar[4*wizDlg->settings.templateSetup + channel];
if (input == stick_index)
return channel;
}
return -1;
}
void StandardPage::populateCB(QComboBox *cb, int preferred)
{
cb->clear();
for (int i=0; i<WIZ_MAX_CHANNELS; i++) { for (int i=0; i<WIZ_MAX_CHANNELS; i++) {
if (wizDlg->mix.channel[i].page == Page_None) { if (wizDlg->mix.channel[i].page == Page_None) {
CB->addItem(tr("Channel %1").arg(i+1), i); // this channel is not already used
cb->addItem(tr("Channel %1").arg(i+1), i);
if (preferred == i) {
cb->setCurrentIndex(cb->count()-1);
}
} }
} }
} }
@@ -323,7 +336,7 @@ ThrottlePage::ThrottlePage(WizardDialog *dlg, QString image, QString title, QStr
void ThrottlePage::initializePage() void ThrottlePage::initializePage()
{ {
populateCB(throttleCB); populateCB(throttleCB, getDefaultChannel(THROTTLE));
} }
bool ThrottlePage::validatePage() bool ThrottlePage::validatePage()
+23 -15
View File
@@ -28,10 +28,11 @@ QT_END_NAMESPACE
class WizardDialog : public QWizard class WizardDialog : public QWizard
{ {
Q_OBJECT Q_OBJECT
public:
WizMix mix; public:
WizardDialog(const GeneralSettings & settings, const unsigned int modelId, QWidget *parent = 0); WizMix mix;
WizardDialog(const GeneralSettings & settings, const unsigned int modelId, QWidget *parent = 0);
const GeneralSettings & settings;
private slots: private slots:
void showHelp(); void showHelp();
@@ -40,18 +41,25 @@ public:
class StandardPage: public QWizardPage class StandardPage: public QWizardPage
{ {
Q_OBJECT Q_OBJECT
public:
StandardPage(WizardPage curPage, WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1); public:
WizardDialog *wizDlg; StandardPage(WizardPage curPage, WizardDialog *dlg, QString image, QString title, QString text, int nextPage=-1);
void populateCB( QComboBox *); WizardDialog *wizDlg;
bool bookChannel(QString label, Input input1, int weight1, Input input2=NOINPUT, int weight2=0 );
void releaseChannels(); // TODO public for these 3 ones?
void cleanupPage(); bool bookChannel(QString label, Input input1, int weight1, Input input2=NOINPUT, int weight2=0 );
private: void releaseChannels();
QLabel *topLabel; void cleanupPage();
WizardPage pageCurrent;
int pageFollower; protected:
int nextId() const; int getDefaultChannel(const Input input);
void populateCB(QComboBox * cb, int preferred=-1);
private:
QLabel *topLabel;
WizardPage pageCurrent;
int pageFollower;
int nextId() const;
}; };
class ModelSelectionPage: public StandardPage class ModelSelectionPage: public StandardPage